Hello Peter Rozsa, Nandor Kollar, Impala Public Jenkins,

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

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

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

Change subject: IMPALA-14996: Optimize count(*) for Iceberg V3 DV-only tables
......................................................................

IMPALA-14996: Optimize count(*) for Iceberg V3 DV-only tables

Enable compile-time count(*) optimization for Iceberg V3 tables
whose only delete files are Deletion Vectors (DVs). As for V1
tables, plain count(*) is rewritten to a constant:

  live rows = total data records - rows deleted by DVs

The deleted row count only includes DVs that reference live data
files.

Key changes:
- IcebergContentFileStore: add hasOnlyDeletionVectors(). Sum the
  record counts of the DVs while they are added to the store, in
  both the constructor and fromThrift(), and expose the sum via
  getDeletionVectorDeletedRecordCount().
- FeIcebergTable.Utils: add getTimeTravelContentFiles(), which
  scans the manifests of a time travel snapshot once. Its result
  is passed to hasDeleteFiles(), the new hasOnlyDeletionVectors(),
  getRecordCountV2() and the new getRecordCountForDvOnlyTable(),
  so a time travel count(*) scans the manifests only once. For
  the current snapshot these use the content file store. For time
  travel the record counts are summed from the snapshot's data
  files and from the DVs of its file scan tasks, which only cover
  live data files.
- SelectStmt: route plain count(*) as no delete files -> V1
  constant, DV-only -> DV constant, otherwise -> V2 rewrite.
  hasDeleteFiles() is checked first because
  hasOnlyDeletionVectors() needs a manifest scan for time travel.
- Calcite planner: transformForV1CountStarOptimization() is renamed to
  transformForConstantCountStarOptimization(). CalciteIcebergTable
  caches hasOnlyDeletionVectors(), computes the record count for
  DV-only tables and does not enable the V2 count(*) optimization
  for them.

Testing:
- Extended iceberg-v3-plain-count-star-optimization.test with
  runtime profile checks for the constant rewrite on both
  planners, mixed aggregates, a partitioned DV table queried with
  and without partition filters, and time travel with
  FOR SYSTEM_TIME AS OF now().
- test_v3_plain_count_star_optimization time travels to older
  snapshots by id (before any delete, after one DV and after the
  DV is rewritten) and checks that no data is read.

Change-Id: I0e6239629ee779a64808a0a4bbe041ef756c5bb2
Assited-by: Composer 2.5 (Cursor)
---
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/IcebergContentFileStore.java
M fe/src/main/java/org/apache/impala/rewrite/CountStarToConstRule.java
M 
java/calcite-planner/src/main/java/org/apache/impala/calcite/rules/IcebergCountStarOptimizer.java
M 
java/calcite-planner/src/main/java/org/apache/impala/calcite/schema/CalciteIcebergTable.java
M 
testdata/workloads/functional-query/queries/QueryTest/iceberg-v3-plain-count-star-optimization.test
M tests/query_test/test_iceberg.py
8 files changed, 288 insertions(+), 68 deletions(-)


  git pull ssh://gerrit.cloudera.org:29418/Impala-ASF refs/changes/33/24733/7
--
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: newpatchset
Gerrit-Change-Id: I0e6239629ee779a64808a0a4bbe041ef756c5bb2
Gerrit-Change-Number: 24733
Gerrit-PatchSet: 7
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]>

Reply via email to