Arnab Karmakar has posted comments on this change. ( http://gerrit.cloudera.org:8080/24733 )
Change subject: IMPALA-14996: Optimize count(*) for Iceberg V3 DV-only tables ...................................................................... Patch Set 9: > Overall, LGTM. > > One comment worth to mention: time-travel queries that can't be > optimized still pay for a manifest scan. For example, 'select i > from t for system_version as of …' scans all manifests for nothing. > https://gerrit.cloudera.org/c/25104/ is supposed to address this > problem, worth keep an eye on it! Ack > Actually Opus found an interesting and possibly problematic edge > case: > "The current-snapshot count can mix two different snapshots (local > catalog mode) > > getRecordCountForDvOnlyTable() (FeIcebergTable.java:1344-1359) > computes total-records minus the DV row count, but the two numbers > come from different sources: > - total-records comes from > table.getIcebergApiTable().currentSnapshot().summary() > (:1347 ? getIcebergSnapshot(), :1394); > - the DV row count comes from table.getContentFileStore() (:1351). > > With the local catalog (CatalogdMetaProvider), those aren't > guaranteed to match: > - LocalIcebergTable.snapshotId() returns catalogSnapshotId_, and > the file store is catalogd's, both shipped by catalogd > (LocalIcebergTable.java:103, :165, :170, :288). > - The API table is loaded separately on the coordinator, with > IcebergUtil.loadTable(...) (CatalogdMetaProvider.java:1352-1369). > That reads whatever metadata is current at that moment, and > the result is cached per catalog version. > > So suppose an external engine (Spark, Hive, Trino) commits between > catalogd's load (snapshot S1) and the coordinator's load (S2). Then > total-records is from S2 and the DVs are from S1. > Example: Spark compacts the table (rewrite_data_files) in S2, so > the old DVs are gone and total-records = 90. Impala computes 90 ? > 10 (the stale S1 DVs) = 80, which is wrong for both > snapshots. Because the API table is cached per catalog version, the > wrong result persists until the next version change: an > event-processor update or a REFRESH. With event processing off, > that can be a long time." > > Considering this, I think if we don't use the same source (either > Iceberg snapshots or our content file store) count(*) can give > incorrect results. AI can really work well sometimes at finding edge cases! Done. Data row count and deleted row count now always come from the same file metadata: For timeTravelFiles == null, we are utilising IcebergContentFileStore and GroupedContentFiles for time-travel. Summing per-file record_count is slightly more work than reading total-records from summary, but it stays consistent with catalogd’s file list. Dangling deletes are still excluded on the delete side because we only count DVs in the store / grouped files, not total-position-deletes. -- To view, visit http://gerrit.cloudera.org:8080/24733 To unsubscribe, visit http://gerrit.cloudera.org:8080/settings Gerrit-Project: Impala-ASF Gerrit-Branch: master Gerrit-MessageType: comment Gerrit-Change-Id: I0e6239629ee779a64808a0a4bbe041ef756c5bb2 Gerrit-Change-Number: 24733 Gerrit-PatchSet: 9 Gerrit-Owner: Arnab Karmakar <[email protected]> Gerrit-Reviewer: Arnab Karmakar <[email protected]> Gerrit-Reviewer: Impala Public Jenkins <[email protected]> Gerrit-Reviewer: Nandor Kollar <[email protected]> Gerrit-Reviewer: Peter Rozsa <[email protected]> Gerrit-Comment-Date: Fri, 30 Oct 2026 07:23:15 +0000 Gerrit-HasComments: No
