# Create Table NOT as iceberg

**URL:** https://community.dremio.com/t/create-table-not-as-iceberg/12882
**Category:** Uncategorized
**Created:** [March 20, 2025, 6:01am UTC](https://community.dremio.com/t/create-table-not-as-iceberg/12882 "2025-03-20T06:01:20Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![Ken](https://sea2.discourse-cdn.com/flex020/user_avatar/community.dremio.com/ken/32/5784_2.png) [@Ken](https://community.dremio.com/u/Ken)
#### Post date: [March 20, 2025, 6:01am UTC](https://community.dremio.com/t/create-table-not-as-iceberg/12882/1 "2025-03-20T06:01:20Z")

</div>

Hi team,

I have been using the OSS version of dremio for 1+ year, and I am loving it. It is easy to host and doing big data analytics is made easy.

However, I am always having trouble with the iceberg table format, especially with its size increase. I tried various ways to keep the size small (e.g. vaccuming + optimising the tables immediately after insertion), but it has always been painful.

Is there a way for dremio to create table NOT as iceberg, but as parquet or other file formats? For this format, I need dremio to support the normal DML operations (e.g. select, insert, update, merge).

Does dremio support this?

Thank you so much!

---

<div class="post-metadata">

### Author: ![balaji.ramaswamy](https://sea2.discourse-cdn.com/flex020/user_avatar/community.dremio.com/balaji.ramaswamy/32/843_2.png) [@balaji.ramaswamy](https://community.dremio.com/u/balaji.ramaswamy)
#### Post date: [March 24, 2025, 5:00am UTC](https://community.dremio.com/t/create-table-not-as-iceberg/12882/2 "2025-03-24T05:00:24Z")

</div>

@Ken PARQUET is immutable, ICEBERG supports DML. When you say size? Is it the actual table data or the metadata that is growing?

---

<div class="post-metadata">

### Author: ![rdkworld](https://avatars.discourse-cdn.com/v4/letter/r/6de8d8/32.png) [@rdkworld](https://community.dremio.com/u/rdkworld)
#### Post date: [March 24, 2025, 2:29pm UTC](https://community.dremio.com/t/create-table-not-as-iceberg/12882/3 "2025-03-24T14:29:21Z")

</div>

@balaji.ramaswamy related question, i have s3 added as a source for querying. How do I create iceberg table by inserting data into say iceberg folder in same s3 bucket. I dont have any catalog added

---

<div class="post-metadata">

### Author: ![balaji.ramaswamy](https://sea2.discourse-cdn.com/flex020/user_avatar/community.dremio.com/balaji.ramaswamy/32/843_2.png) [@balaji.ramaswamy](https://community.dremio.com/u/balaji.ramaswamy)
#### Post date: [March 26, 2025, 5:11am UTC](https://community.dremio.com/t/create-table-not-as-iceberg/12882/4 "2025-03-26T05:11:33Z")

</div>

@rdkworld You can just do `CREATE TABLE S3_source_name.<folder_under>.<TABLE_NAME>`

---

<div class="post-metadata">

### Author: ![Ken](https://sea2.discourse-cdn.com/flex020/user_avatar/community.dremio.com/ken/32/5784_2.png) [@Ken](https://community.dremio.com/u/Ken)
#### Post date: [March 26, 2025, 1:34pm UTC](https://community.dremio.com/t/create-table-not-as-iceberg/12882/5 "2025-03-26T13:34:39Z")

</div>

![image](https://us1.discourse-cdn.com/flex020/uploads/dremio/original/2X/7/72ab66bb7f1f68154cddc6b456148459cba4cf40.png)

@balaji.ramaswamy

Using two iceberg tables as an illustration.

THe one in `l0` is constantly getting new data via `MERGE`.

I perform vacuum (expire snapshot retain 1) and optimise after every MERGE.

However, it’s data size grows to 31GiB.

 ![image](https://us1.discourse-cdn.com/flex020/uploads/dremio/original/2X/a/aba796381519205c1b409b541542748953f7216b.png)

I ran this SQL to determine the `file_size_in_bytes`

```auto

select sum("record_count"), sum("file_size_in_bytes") from TABLE( table_files( 'Minio.finance.l0.XXXX' ) );

```

It says it is around 3.5GB (which is **VERY DIFFERENT** from the actual size of 31GiB).

========

However, after I recreate the table (and put it in the `backup_2025_03_26`)

```auto
create table Minio.finance.backup_2025_03_26."XXXXXX"

as (SELECT * FROM Minio.finance.l0."XXXXXX")

```

The file sized shrank to `3.3GiB`. This is more inline with what the original statistics is saying.

Note that I have always expired all snapshots and it should not bloat to 31GiB.

I feel that I hit something similar to what is reported here ([Iceberg file size on dremio - #13 by dacopan](https://community.dremio.com/t/iceberg-file-size-on-dremio/11758/13))

=======

In the original iceberg table (with regular MERGE of new data)

 ![image](https://us1.discourse-cdn.com/flex020/uploads/dremio/original/2X/f/fdb5d52f1602c7add5ddb7bb0bb2955564fb9d44.jpeg)

—\> The data files folder are multiple. Those **XLDIR** directories were created after `vacuum operation`, where snapshots got deleted.

However, I think there are still dangling snapshots in the data files.

Meanwhile, in the **recreated table** (via CTAS), there’s just ONE data file folder

 ![image](https://us1.discourse-cdn.com/flex020/uploads/dremio/original/2X/2/2dab82fceaaa2978bcf8f3f19f07f4533205b962.png)

So I suppose that many data files folder in the original iceberg tables are actually useless (or else they would have been copied to the new iceberg table via CTAS)

---

<div class="post-metadata">

### Author: ![balaji.ramaswamy](https://sea2.discourse-cdn.com/flex020/user_avatar/community.dremio.com/balaji.ramaswamy/32/843_2.png) [@balaji.ramaswamy](https://community.dremio.com/u/balaji.ramaswamy)
#### Post date: [March 28, 2025, 5:35am UTC](https://community.dremio.com/t/create-table-not-as-iceberg/12882/6 "2025-03-28T05:35:29Z")

</div>

Thanks for the clear steps @Ken Let me see if someone can try and repro this

---

<div class="post-metadata">

### Author: ![rdkworld](https://avatars.discourse-cdn.com/v4/letter/r/6de8d8/32.png) [@rdkworld](https://community.dremio.com/u/rdkworld)
#### Post date: [March 28, 2025, 11:30pm UTC](https://community.dremio.com/t/create-table-not-as-iceberg/12882/7 "2025-03-28T23:30:26Z")

</div>

Thanks Balaji, it worked

---

<div class="post-metadata">

### Author: ![Ken](https://sea2.discourse-cdn.com/flex020/user_avatar/community.dremio.com/ken/32/5784_2.png) [@Ken](https://community.dremio.com/u/Ken)
#### Post date: [April 3, 2025, 2:10pm UTC](https://community.dremio.com/t/create-table-not-as-iceberg/12882/8 "2025-04-03T14:10:41Z")

</div>

@balaji.ramaswamy

In the below screenshot, it shows clearly that

In Minio storage, the file exists.

However, dremio cannot detect that.

 ![image](https://us1.discourse-cdn.com/flex020/uploads/dremio/original/2X/3/3d6d9349acf52e9e411d0da32ac7c7b08cb89513.png)

Why cannot it delete this orphan data file?

I tried

```auto
VACUUM TABLE Minio.finance.l0.yahoo_stock_price_1m_history_2025_03 EXPIRE SNAPSHOTS RETAIN_LAST 1

```

but it is still there.

 ![image](https://us1.discourse-cdn.com/flex020/uploads/dremio/original/2X/6/63b8206af2cf0dde8ced794ab456714fde236f99.png)

============

**I manually deleted this data file using `mcli` and the result number of data counts remain the SAME!!!**

 ![image](https://us1.discourse-cdn.com/flex020/uploads/dremio/original/2X/a/a97ba4d70f552bf7314df7bac94bee1bc3e0a564.png)

```auto
minio@minio-prod:~$ mcli rm --dangerous --force -r /mnt/data/finance/l0/yahoo_stock_price_1m_history_2025_03/1812f77a-4b1f-2a34-94b0-cfe8048cff00

```

So I confirm this is an orphan data file.

@balaji.ramaswamy Does Dremio support deleting orphan data files?

---

<div class="post-metadata">

### Author: ![Ken](https://sea2.discourse-cdn.com/flex020/user_avatar/community.dremio.com/ken/32/5784_2.png) [@Ken](https://community.dremio.com/u/Ken)
#### Post date: [April 3, 2025, 2:48pm UTC](https://community.dremio.com/t/create-table-not-as-iceberg/12882/9 "2025-04-03T14:48:34Z")

</div>

This screenshot shows this

- Left: It is the result of this query

```auto
select * from table(table_files('Minio.finance.l0.yahoo_stock_price_1m_history_2025_03'))

```

It shows the data files actively tracked by Dremio

- Right. It is the list of data files in Minio using the Minio Client.

```auto
mcli du /mnt/data/finance/l0/yahoo_stock_price_1m_history_2025_03/*

```

 ![image](https://us1.discourse-cdn.com/flex020/uploads/dremio/original/2X/b/ba9024926aa3d10cfce9489dde1e8e97826ed0a7.png)

The two highlighted rows are the actual data files tracked by Dremio and the rest are orphan files.

For now, I think I will just write a python script to delete these files not tracked by dremio. Hopefully it will work.

---

<div class="post-metadata">

### Author: ![Ken](https://sea2.discourse-cdn.com/flex020/user_avatar/community.dremio.com/ken/32/5784_2.png) [@Ken](https://community.dremio.com/u/Ken)
#### Post date: [April 5, 2025, 3:57pm UTC](https://community.dremio.com/t/create-table-not-as-iceberg/12882/10 "2025-04-05T15:57:05Z")

</div>

> [@Ken](#):
>
> For now, I think I will just write a python script to delete these files not tracked by dremio. Hopefully it will work.

I confirm that this approach works!

In short, the approach is to delete data files not longer tracked by Dremio, but still remains in Minio.

Step 1. Query the data\_files in Dremio

```auto
select "file_path" from table( table_files('XXXX'))

```

This list represents the list of data files tracked by Dremio.

Step 2. Use the list\_objects function in Minio Client to list all the objects under the iceberg table folder

```auto
objects = self.client.list_objects(
            bucket_name,
            prefix=bucket_subpath,
            recursive=recursive
        )

```

Step 3: Perform reconciliation which matches each data file tracked by Dremio in Step 1 with the listed object in Step 2

Step 4: Except the Metadata files, delete all data files in Minio which are NOT tracked by Dremio. Use the remove\_object method.

```auto
  self.client.remove_object(
            bucket_name=bucket_name,
            object_name= file_path,
        )

```

**Validation**

- File Size dropped

I have a superset dashboard which tracks the actual table size in Minio via `du -sh` command once every hour. The below graph shows that all table folders drop in size significantly after the above logic is applied.

 ![image](https://us1.discourse-cdn.com/flex020/uploads/dremio/original/2X/a/a50f9899274740d27e121e917373f861c4b39122.jpeg)

Below is another graph which shows the **available percentage** of disk space in the whole Minio VM. It is obtained via `df -h` and by looking at the `/` mount.

 ![image](https://us1.discourse-cdn.com/flex020/uploads/dremio/original/2X/7/7f361fabeae199707de1457852bd8d74efa20b68.png)

- Row Count increases

Most importantly, row count for all tables did not drop.

Below is the growth in row count of 2 of the tables.

 ![image](https://us1.discourse-cdn.com/flex020/uploads/dremio/original/2X/1/13531460da67b509e1525195e02a7de25a44e673.png)
