Hello Arnab Karmakar, Peter Rozsa, Nandor Kollar, Impala Public Jenkins,

I'd like you to reexamine a change. Please visit

    http://gerrit.cloudera.org:8080/25104

to look at the new patch set (#2).

Change subject: IMPALA-15542: Avoid unnecessary Iceberg manifest loading in 
count(*) optimization
......................................................................

IMPALA-15542: Avoid unnecessary Iceberg manifest loading in count(*) 
optimization

SelectStmt.optimizePlainCountStarQueryForIcebergTable() called
Utils.hasDeleteFiles() before validating the select list. For time travel
queries hasDeleteFiles() loads the Iceberg manifest files via
IcebergUtil.getIcebergFiles(), which can be expensive, even though the
result is only needed for queries that are eligible for the count(*)
optimization.

Validate the select list first so ineligible queries return without
loading any Iceberg metadata. Handle IcebergV2CountStarAccumulator items
of re-analyzed statements (alreadyOptimized) so their behavior is
unchanged.

For eligible time travel queries load the Iceberg content files only once
and reuse the result both for the delete file check and for the V2 record
count. Previously the manifest files were loaded twice for V2 time travel
queries (once in hasDeleteFiles(), once in getRecordCountV2()).

V1/V2 semantics are unchanged: V1 still allows aggregate functions other
than count(*), but they prevent the count(*) rewrite. V2 still only allows
count(*), constants, and the accumulator.

Move hasDeleteFiles() from FeIcebergTable.Utils into GroupedContentFiles so
the class answers the question itself instead of delegating to a utility
method. Add GroupedContentFilesTest for the new method.

Testing:
 * Added GroupedContentFilesTest, covering data files (with and without
   deletes), position delete files, equality delete files, and deletion
   vectors.
 * Added IcebergCountStarOptimizationTest, which verifies with a static
   mock of IcebergUtil that ineligible time travel queries do not load the
   Iceberg file metadata and eligible ones load it once per analysis. The
   tests fail on the unmodified code with 1/2/4 loads instead of 0/1/2.
 * Extended PlannerTest/iceberg-v2-tables.test with time travel cases:
   ineligible select lists, other aggregate functions, and pure
   constants/other aggregates on the current snapshot.
 * Ran GroupedContentFilesTest (4 tests), FeIcebergTableUtilsTest (4
   tests), IcebergCountStarOptimizationTest (3 tests),
   PlannerTest#testIcebergV2TableScans,
   testIcebergV2TableScansWithResources, testIcebergV2TableScansHashJoin,
   and AnalyzeStmtsTest#testIcebergTimeTravel; all pass.

Change-Id: I239139dcddba313827c19307c4d90dd4dbf62e9e
Assisted-by: DeepSeek V4.1 Flash (opencode)
---
M fe/src/main/java/org/apache/impala/analysis/SelectStmt.java
M fe/src/main/java/org/apache/impala/catalog/FeIcebergTable.java
M fe/src/main/java/org/apache/impala/catalog/iceberg/GroupedContentFiles.java
A 
fe/src/test/java/org/apache/impala/analysis/IcebergCountStarOptimizationTest.java
A 
fe/src/test/java/org/apache/impala/catalog/iceberg/GroupedContentFilesTest.java
M 
testdata/workloads/functional-planner/queries/PlannerTest/iceberg-v2-tables.test
6 files changed, 543 insertions(+), 45 deletions(-)


  git pull ssh://gerrit.cloudera.org:29418/Impala-ASF refs/changes/04/25104/2
--
To view, visit http://gerrit.cloudera.org:8080/25104
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I239139dcddba313827c19307c4d90dd4dbf62e9e
Gerrit-Change-Number: 25104
Gerrit-PatchSet: 2
Gerrit-Owner: Xianqing He <[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]>

Reply via email to