# Iceberg table file count mismatch with Athena

**URL:** https://community.dremio.com/t/iceberg-table-file-count-mismatch-with-athena/12702
**Category:** Uncategorized
**Created:** [January 16, 2025, 4:15pm UTC](https://community.dremio.com/t/iceberg-table-file-count-mismatch-with-athena/12702 "2025-01-16T16:15:25Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![vladislav-stolyarov](https://sea2.discourse-cdn.com/flex020/user_avatar/community.dremio.com/vladislav-stolyarov/32/2351_2.png) [@vladislav-stolyarov](https://community.dremio.com/u/vladislav-stolyarov)
#### Post date: [January 16, 2025, 4:15pm UTC](https://community.dremio.com/t/iceberg-table-file-count-mismatch-with-athena/12702/1 "2025-01-16T16:15:25Z")

</div>

I see weird behavior.  
I have Iceberg table in aws glue (created in Glue from Athena).  
This table is being updated every 1 hour from Athena(DELETE+INSERT).  
Also Table Optimization is enabled in AWS glue(runs Optimize periodically)  
My problem is that in Athena  
`select * from "table$files" ` outputs 181 rows.

While when i run this command from Dremio:  
`select * from TABLE(table_files('"..table'))`  
it outputs 970 rows.

Table was created recently so it seems that this number(970) is growing…  
When i ran OPTIMIZE from Athena number of files decrease in Athena `select * from "table$files" ` query, but not in Dremio.

table\_manifests, table\_snapshots outputs are same in Athena and Dremio…

Can someone explain this behavior?  
Can it be that dremio shows files from all metadata files, while Athena shows latest(still strange cos i ran VACUUM and number fo files outputted by Dremio has not decreased)

Maybe this is important note - DELETEs are issues from Athena and they use MOR mode(COR is not supported by Athena) While Dremio doesn’t support MOR delete mode, maybe this can have any side effect

---

<div class="post-metadata">

### Author: ![vladislav-stolyarov](https://sea2.discourse-cdn.com/flex020/user_avatar/community.dremio.com/vladislav-stolyarov/32/2351_2.png) [@vladislav-stolyarov](https://community.dremio.com/u/vladislav-stolyarov)
#### Post date: [January 17, 2025, 12:06pm UTC](https://community.dremio.com/t/iceberg-table-file-count-mismatch-with-athena/12702/2 "2025-01-17T12:06:26Z")

</div>

Okay i found the reason for this.

The difference between files was because Athena is showing only Data files(which is weird cos it should according to specs) but not Delete files.

Also i use Aws Glue Table Optimization feature that automatically do compaction of the data files and

> - Compaction will not merge [delete files](https://iceberg.apache.org/spec/#delete-formats). Tables with deleted data will be compacted, but data files that have delete files associated with them will be skipped.

So number of delete files is always growing and never cleaned up. Running OPTIMIZE manually fixes the difference by removing delete files from output.
