Xianqing He has uploaded this change for review. ( http://gerrit.cloudera.org:8080/25104
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. Testing: * 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. * 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. * Ran PlannerTest#testIcebergV2TableScans, testIcebergV2TableScansWithResources, testIcebergV2TableScansHashJoin, AnalyzeStmtsTest#testIcebergTimeTravel and IcebergCountStarOptimizationTest; all pass. The planner tests also pass on the unmodified code, confirming behavior is preserved. 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 A fe/src/test/java/org/apache/impala/analysis/IcebergCountStarOptimizationTest.java M testdata/workloads/functional-planner/queries/PlannerTest/iceberg-v2-tables.test 4 files changed, 486 insertions(+), 44 deletions(-) git pull ssh://gerrit.cloudera.org:29418/Impala-ASF refs/changes/04/25104/1 -- 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: newchange Gerrit-Change-Id: I239139dcddba313827c19307c4d90dd4dbf62e9e Gerrit-Change-Number: 25104 Gerrit-PatchSet: 1 Gerrit-Owner: Xianqing He <[email protected]>
