You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@impala.apache.org by "Zoltan Borok-Nagy (Code Review)" <ge...@cloudera.org> on 2025/11/21 12:44:49 UTC

[Impala-ASF-CR] IMPALA-13756: Fix Iceberg V2 count(*) optimization for complex queries

Zoltan Borok-Nagy has uploaded this change for review. ( http://gerrit.cloudera.org:8080/23705


Change subject: IMPALA-13756: Fix Iceberg V2 count(*) optimization for complex queries
......................................................................

IMPALA-13756: Fix Iceberg V2 count(*) optimization for complex queries

In SelectStmt we enable count(*) optimization for Iceberg V2 queries
if certain criteria is met. We store this information in the query
context. Then IcebergScanPlanner applies count(*) optimization based
on the information in the query context.

This mechanism works for simple queries, but can turn on count(*)
optimization for all Iceberg V2 tables in complex queries if at
least one subquery enables count(*) optimization during analysis.

With this patch SelectStmt enables count(*) optimization via the
TableRef object which is later given the IcebergScanPlanner.

The count(*) expression also needs to be rewritten to show the proper
count of the table:

       AGGREGATE
       COUNT(*)
           |
       UNION ALL
      /        \
     /          \
    /            \
   SCAN all  ANTI JOIN
   datafiles  /      \
   without   /        \
   deletes  SCAN      SCAN
            datafiles deletes

            ||
          rewrite
            ||
            \/

  ArithmethicExpr: LHS + RHS
      /             \
     /               \
    /                 \
   record_count  AGGREGATE
   of all        COUNT(*)
   datafiles         |
   without       ANTI JOIN
   deletes      /         \
               /           \
               SCAN        SCAN
               datafiles   deletes

With this patch, instead of using ArithmethicExpr, we introduce
IcebergV2CountStarAdjuster so we know if the above optimization is
already applied.

Testing
 * e2e tests

Change-Id: I1940031298eb634aa82c3d32bbbf16bce8eaf874
---
M common/thrift/Query.thrift
A fe/src/main/java/org/apache/impala/analysis/IcebergV2CountStarAdjuster.java
M fe/src/main/java/org/apache/impala/analysis/SelectStmt.java
M fe/src/main/java/org/apache/impala/analysis/TableRef.java
M fe/src/main/java/org/apache/impala/planner/IcebergScanPlanner.java
M fe/src/main/java/org/apache/impala/rewrite/CountStarToConstRule.java
A testdata/workloads/functional-query/queries/QueryTest/iceberg-v2-count-star-optimization-in-complex-query.test
M tests/query_test/test_iceberg.py
8 files changed, 193 insertions(+), 11 deletions(-)



  git pull ssh://gerrit.cloudera.org:29418/Impala-ASF refs/changes/05/23705/1
-- 
To view, visit http://gerrit.cloudera.org:8080/23705
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I1940031298eb634aa82c3d32bbbf16bce8eaf874
Gerrit-Change-Number: 23705
Gerrit-PatchSet: 1
Gerrit-Owner: Zoltan Borok-Nagy <bo...@cloudera.com>

[Impala-ASF-CR] IMPALA-13756: Fix Iceberg V2 count(*) optimization for complex queries

Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/23705 )

Change subject: IMPALA-13756: Fix Iceberg V2 count(*) optimization for complex queries
......................................................................


Patch Set 7: Verified+1


-- 
To view, visit http://gerrit.cloudera.org:8080/23705
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I1940031298eb634aa82c3d32bbbf16bce8eaf874
Gerrit-Change-Number: 23705
Gerrit-PatchSet: 7
Gerrit-Owner: Zoltan Borok-Nagy <bo...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Peter Rozsa <pr...@cloudera.com>
Gerrit-Reviewer: Riza Suminto <ri...@cloudera.com>
Gerrit-Reviewer: Zoltan Borok-Nagy <bo...@cloudera.com>
Gerrit-Comment-Date: Fri, 19 Dec 2025 17:50:28 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-13756: Fix Iceberg V2 count(*) optimization for complex queries

Posted by "Zoltan Borok-Nagy (Code Review)" <ge...@cloudera.org>.
Zoltan Borok-Nagy has posted comments on this change. ( http://gerrit.cloudera.org:8080/23705 )

Change subject: IMPALA-13756: Fix Iceberg V2 count(*) optimization for complex queries
......................................................................


Patch Set 4:

(2 comments)

Thanks for the comments!

http://gerrit.cloudera.org:8080/#/c/23705/3//COMMIT_MSG
Commit Message:

http://gerrit.cloudera.org:8080/#/c/23705/3//COMMIT_MSG@69
PS3, Line 69: IcebergV2CountStarAccumula
> nit: should be IcebergV2CountStarAccumulator
Thanks for catching this, done.


http://gerrit.cloudera.org:8080/#/c/23705/3/fe/src/main/java/org/apache/impala/rewrite/CountStarToConstRule.java
File fe/src/main/java/org/apache/impala/rewrite/CountStarToConstRule.java:

http://gerrit.cloudera.org:8080/#/c/23705/3/fe/src/main/java/org/apache/impala/rewrite/CountStarToConstRule.java@56
PS3, Line 56: IcebergV2CountStarAccumula
> nit: should be IcebergV2CountStarAccumulator
Done



-- 
To view, visit http://gerrit.cloudera.org:8080/23705
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I1940031298eb634aa82c3d32bbbf16bce8eaf874
Gerrit-Change-Number: 23705
Gerrit-PatchSet: 4
Gerrit-Owner: Zoltan Borok-Nagy <bo...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Peter Rozsa <pr...@cloudera.com>
Gerrit-Reviewer: Riza Suminto <ri...@cloudera.com>
Gerrit-Reviewer: Zoltan Borok-Nagy <bo...@cloudera.com>
Gerrit-Comment-Date: Wed, 17 Dec 2025 17:32:27 +0000
Gerrit-HasComments: Yes

[Impala-ASF-CR] IMPALA-13756: Fix Iceberg V2 count(*) optimization for complex queries

Posted by "Riza Suminto (Code Review)" <ge...@cloudera.org>.
Riza Suminto has posted comments on this change. ( http://gerrit.cloudera.org:8080/23705 )

Change subject: IMPALA-13756: Fix Iceberg V2 count(*) optimization for complex queries
......................................................................


Patch Set 4: Code-Review+2


-- 
To view, visit http://gerrit.cloudera.org:8080/23705
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I1940031298eb634aa82c3d32bbbf16bce8eaf874
Gerrit-Change-Number: 23705
Gerrit-PatchSet: 4
Gerrit-Owner: Zoltan Borok-Nagy <bo...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Peter Rozsa <pr...@cloudera.com>
Gerrit-Reviewer: Riza Suminto <ri...@cloudera.com>
Gerrit-Reviewer: Zoltan Borok-Nagy <bo...@cloudera.com>
Gerrit-Comment-Date: Wed, 17 Dec 2025 17:34:02 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-13756: Fix Iceberg V2 count(*) optimization for complex queries

Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/23705 )

Change subject: IMPALA-13756: Fix Iceberg V2 count(*) optimization for complex queries
......................................................................


Patch Set 4:

Build Successful 

https://jenkins.impala.io/job/gerrit-code-review-checks/21201/ : Initial code review checks passed. Use gerrit-verify-dryrun-external or gerrit-verify-dryrun to run full precommit tests.


-- 
To view, visit http://gerrit.cloudera.org:8080/23705
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I1940031298eb634aa82c3d32bbbf16bce8eaf874
Gerrit-Change-Number: 23705
Gerrit-PatchSet: 4
Gerrit-Owner: Zoltan Borok-Nagy <bo...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Peter Rozsa <pr...@cloudera.com>
Gerrit-Reviewer: Riza Suminto <ri...@cloudera.com>
Gerrit-Reviewer: Zoltan Borok-Nagy <bo...@cloudera.com>
Gerrit-Comment-Date: Wed, 17 Dec 2025 17:58:04 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-13756: Fix Iceberg V2 count(*) optimization for complex queries

Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/23705 )

Change subject: IMPALA-13756: Fix Iceberg V2 count(*) optimization for complex queries
......................................................................


Patch Set 3:

Build Successful 

https://jenkins.impala.io/job/gerrit-code-review-checks/21123/ : Initial code review checks passed. Use gerrit-verify-dryrun-external or gerrit-verify-dryrun to run full precommit tests.


-- 
To view, visit http://gerrit.cloudera.org:8080/23705
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I1940031298eb634aa82c3d32bbbf16bce8eaf874
Gerrit-Change-Number: 23705
Gerrit-PatchSet: 3
Gerrit-Owner: Zoltan Borok-Nagy <bo...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Riza Suminto <ri...@cloudera.com>
Gerrit-Reviewer: Zoltan Borok-Nagy <bo...@cloudera.com>
Gerrit-Comment-Date: Wed, 10 Dec 2025 12:13:33 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-13756: Fix Iceberg V2 count(*) optimization for complex queries

Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/23705 )

Change subject: IMPALA-13756: Fix Iceberg V2 count(*) optimization for complex queries
......................................................................


Patch Set 5:

Build started: https://jenkins.impala.io/job/gerrit-verify-dryrun/12811/ DRY_RUN=false


-- 
To view, visit http://gerrit.cloudera.org:8080/23705
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I1940031298eb634aa82c3d32bbbf16bce8eaf874
Gerrit-Change-Number: 23705
Gerrit-PatchSet: 5
Gerrit-Owner: Zoltan Borok-Nagy <bo...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Peter Rozsa <pr...@cloudera.com>
Gerrit-Reviewer: Riza Suminto <ri...@cloudera.com>
Gerrit-Reviewer: Zoltan Borok-Nagy <bo...@cloudera.com>
Gerrit-Comment-Date: Thu, 18 Dec 2025 10:48:15 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-13756: Fix Iceberg V2 count(*) optimization for complex queries

Posted by "Peter Rozsa (Code Review)" <ge...@cloudera.org>.
Peter Rozsa has posted comments on this change. ( http://gerrit.cloudera.org:8080/23705 )

Change subject: IMPALA-13756: Fix Iceberg V2 count(*) optimization for complex queries
......................................................................


Patch Set 3: Code-Review+1

(2 comments)

http://gerrit.cloudera.org:8080/#/c/23705/3//COMMIT_MSG
Commit Message:

http://gerrit.cloudera.org:8080/#/c/23705/3//COMMIT_MSG@69
PS3, Line 69: IcebergV2CountStarAdjuster
nit: should be IcebergV2CountStarAccumulator


http://gerrit.cloudera.org:8080/#/c/23705/3/fe/src/main/java/org/apache/impala/rewrite/CountStarToConstRule.java
File fe/src/main/java/org/apache/impala/rewrite/CountStarToConstRule.java:

http://gerrit.cloudera.org:8080/#/c/23705/3/fe/src/main/java/org/apache/impala/rewrite/CountStarToConstRule.java@56
PS3, Line 56: IcebergV2CountStarAdjuster
nit: should be IcebergV2CountStarAccumulator



-- 
To view, visit http://gerrit.cloudera.org:8080/23705
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I1940031298eb634aa82c3d32bbbf16bce8eaf874
Gerrit-Change-Number: 23705
Gerrit-PatchSet: 3
Gerrit-Owner: Zoltan Borok-Nagy <bo...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Peter Rozsa <pr...@cloudera.com>
Gerrit-Reviewer: Riza Suminto <ri...@cloudera.com>
Gerrit-Reviewer: Zoltan Borok-Nagy <bo...@cloudera.com>
Gerrit-Comment-Date: Wed, 17 Dec 2025 15:12:55 +0000
Gerrit-HasComments: Yes

[Impala-ASF-CR] IMPALA-13756: Fix Iceberg V2 count(*) optimization for complex queries

Posted by "Zoltan Borok-Nagy (Code Review)" <ge...@cloudera.org>.
Zoltan Borok-Nagy has posted comments on this change. ( http://gerrit.cloudera.org:8080/23705 )

Change subject: IMPALA-13756: Fix Iceberg V2 count(*) optimization for complex queries
......................................................................


Patch Set 7: Code-Review+2

Carry +2 as I only added a trivial unit test fix.


-- 
To view, visit http://gerrit.cloudera.org:8080/23705
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I1940031298eb634aa82c3d32bbbf16bce8eaf874
Gerrit-Change-Number: 23705
Gerrit-PatchSet: 7
Gerrit-Owner: Zoltan Borok-Nagy <bo...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Peter Rozsa <pr...@cloudera.com>
Gerrit-Reviewer: Riza Suminto <ri...@cloudera.com>
Gerrit-Reviewer: Zoltan Borok-Nagy <bo...@cloudera.com>
Gerrit-Comment-Date: Fri, 19 Dec 2025 17:53:48 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-13756: Fix Iceberg V2 count(*) optimization for complex queries

Posted by "Zoltan Borok-Nagy (Code Review)" <ge...@cloudera.org>.
Hello Riza Suminto, Peter Rozsa, Impala Public Jenkins, 

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

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

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

Change subject: IMPALA-13756: Fix Iceberg V2 count(*) optimization for complex queries
......................................................................

IMPALA-13756: Fix Iceberg V2 count(*) optimization for complex queries

We optimize plain count(*) queries on Iceberg tables the following way:

       AGGREGATE
       COUNT(*)
           |
       UNION ALL
      /        \
     /          \
    /            \
   SCAN all  ANTI JOIN
   datafiles  /      \
   without   /        \
   deletes  SCAN      SCAN
            datafiles deletes

            ||
          rewrite
            ||
            \/

  ArithmethicExpr: LHS + RHS
      /             \
     /               \
    /                 \
   record_count  AGGREGATE
   of all        COUNT(*)
   datafiles         |
   without       ANTI JOIN
   deletes      /         \
               /           \
               SCAN        SCAN
               datafiles   deletes

This optimization consists of two parts:
 1 Rewriting count(*) expression to count(*) + "record_count" (of data
   files without deletes)
 2 In IcebergScanPlanner we only need to consruct the right side of
   the original UNION ALL operator, i.e.:

            ANTI JOIN
           /         \
          /           \
         SCAN        SCAN
         datafiles   deletes

SelectStmt decides whether we can do the count(*) optimization, and if
so, does the following:

 1: SelectStmt sets 'TotalRecordsNumV2' in the analyzer, then during the
    expression rewrite phase the CountStarToConstRule rewrites the
    count(*) to count(*) + record_count
 2: SelectStmt sets "OptimizeCountStarForIcebergV2" in the query context
    then IcebergScanPlanner creates plan accordingly.

This mechanism works for simple queries, but can turn on count(*)
optimization in IcebergScanPlanner for all Iceberg V2 tables in complex
queries. Even if only one subquery enables count(*) optimization during
analysis.

With this patch the followings change:
 1: We introduce IcebergV2CountStarAccumulator which we use instead of
    the ArithmethicExpr. So after rewrite we still know if count(*)
    optimization should be enabled for the planner.
 2: Instead of using the query context, we pass the information to the
    IcebergScanPlanner via the TableRef object.

Testing
 * e2e tests

Change-Id: I1940031298eb634aa82c3d32bbbf16bce8eaf874
---
M common/thrift/Query.thrift
A fe/src/main/java/org/apache/impala/analysis/IcebergV2CountStarAccumulator.java
M fe/src/main/java/org/apache/impala/analysis/SelectStmt.java
M fe/src/main/java/org/apache/impala/analysis/TableRef.java
M fe/src/main/java/org/apache/impala/planner/IcebergScanPlanner.java
M fe/src/main/java/org/apache/impala/rewrite/CountStarToConstRule.java
M fe/src/test/java/org/apache/impala/analysis/AnalyzeStmtsTest.java
A testdata/workloads/functional-query/queries/QueryTest/iceberg-v2-count-star-optimization-in-complex-query.test
M tests/query_test/test_iceberg.py
9 files changed, 197 insertions(+), 12 deletions(-)


  git pull ssh://gerrit.cloudera.org:29418/Impala-ASF refs/changes/05/23705/6
-- 
To view, visit http://gerrit.cloudera.org:8080/23705
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I1940031298eb634aa82c3d32bbbf16bce8eaf874
Gerrit-Change-Number: 23705
Gerrit-PatchSet: 6
Gerrit-Owner: Zoltan Borok-Nagy <bo...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Peter Rozsa <pr...@cloudera.com>
Gerrit-Reviewer: Riza Suminto <ri...@cloudera.com>
Gerrit-Reviewer: Zoltan Borok-Nagy <bo...@cloudera.com>

[Impala-ASF-CR] IMPALA-13756: Fix Iceberg V2 count(*) optimization for complex queries

Posted by "Zoltan Borok-Nagy (Code Review)" <ge...@cloudera.org>.
Hello Impala Public Jenkins, 

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

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

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

Change subject: IMPALA-13756: Fix Iceberg V2 count(*) optimization for complex queries
......................................................................

IMPALA-13756: Fix Iceberg V2 count(*) optimization for complex queries

We optimize plain count(*) queries on Iceberg tables the following way:

       AGGREGATE
       COUNT(*)
           |
       UNION ALL
      /        \
     /          \
    /            \
   SCAN all  ANTI JOIN
   datafiles  /      \
   without   /        \
   deletes  SCAN      SCAN
            datafiles deletes

            ||
          rewrite
            ||
            \/

  ArithmethicExpr: LHS + RHS
      /             \
     /               \
    /                 \
   record_count  AGGREGATE
   of all        COUNT(*)
   datafiles         |
   without       ANTI JOIN
   deletes      /         \
               /           \
               SCAN        SCAN
               datafiles   deletes

This optimization consists of two parts:
 1 Rewriting count(*) expression to count(*) + "record_count" (of data
   files without deletes)
 2 In IcebergScanPlanner we only need to consruct the right side of
   the original UNION ALL operator, i.e.:

            ANTI JOIN
           /         \
          /           \
         SCAN        SCAN
         datafiles   deletes

SelectStmt decides whether we can do the count(*) optimization, and if
so, does the following:

 1: SelectStmt sets 'TotalRecordsNumV2' in the analyzer, then during the
    expression rewrite phase the CountStarToConstRule rewrites the
    count(*) to count(*) + record_count
 2: SelectStmt sets "OptimizeCountStarForIcebergV2" in the query context
    then IcebergScanPlanner creates plan accordingly.

This mechanism works for simple queries, but can turn on count(*)
optimization in IcebergScanPlanner for all Iceberg V2 tables in complex
queries. Even if only one subquery enables count(*) optimization during
analysis.

With this patch the followings change:
 1: We introduce IcebergV2CountStarAdjuster which we use instead of the
    ArithmethicExpr. So after rewrite we still know if count(*)
    optimization should be enabled for the planner.
 2: Instead of using the query context, we pass the information to the
    IcebergScanPlanner via the TableRef object.

Testing
 * e2e tests

Change-Id: I1940031298eb634aa82c3d32bbbf16bce8eaf874
---
M common/thrift/Query.thrift
A fe/src/main/java/org/apache/impala/analysis/IcebergV2CountStarAdjuster.java
M fe/src/main/java/org/apache/impala/analysis/SelectStmt.java
M fe/src/main/java/org/apache/impala/analysis/TableRef.java
M fe/src/main/java/org/apache/impala/planner/IcebergScanPlanner.java
M fe/src/main/java/org/apache/impala/rewrite/CountStarToConstRule.java
A testdata/workloads/functional-query/queries/QueryTest/iceberg-v2-count-star-optimization-in-complex-query.test
M tests/query_test/test_iceberg.py
8 files changed, 193 insertions(+), 11 deletions(-)


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

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I1940031298eb634aa82c3d32bbbf16bce8eaf874
Gerrit-Change-Number: 23705
Gerrit-PatchSet: 2
Gerrit-Owner: Zoltan Borok-Nagy <bo...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>

[Impala-ASF-CR] IMPALA-13756: Fix Iceberg V2 count(*) optimization for complex queries

Posted by "Zoltan Borok-Nagy (Code Review)" <ge...@cloudera.org>.
Hello Riza Suminto, Impala Public Jenkins, 

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

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

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

Change subject: IMPALA-13756: Fix Iceberg V2 count(*) optimization for complex queries
......................................................................

IMPALA-13756: Fix Iceberg V2 count(*) optimization for complex queries

We optimize plain count(*) queries on Iceberg tables the following way:

       AGGREGATE
       COUNT(*)
           |
       UNION ALL
      /        \
     /          \
    /            \
   SCAN all  ANTI JOIN
   datafiles  /      \
   without   /        \
   deletes  SCAN      SCAN
            datafiles deletes

            ||
          rewrite
            ||
            \/

  ArithmethicExpr: LHS + RHS
      /             \
     /               \
    /                 \
   record_count  AGGREGATE
   of all        COUNT(*)
   datafiles         |
   without       ANTI JOIN
   deletes      /         \
               /           \
               SCAN        SCAN
               datafiles   deletes

This optimization consists of two parts:
 1 Rewriting count(*) expression to count(*) + "record_count" (of data
   files without deletes)
 2 In IcebergScanPlanner we only need to consruct the right side of
   the original UNION ALL operator, i.e.:

            ANTI JOIN
           /         \
          /           \
         SCAN        SCAN
         datafiles   deletes

SelectStmt decides whether we can do the count(*) optimization, and if
so, does the following:

 1: SelectStmt sets 'TotalRecordsNumV2' in the analyzer, then during the
    expression rewrite phase the CountStarToConstRule rewrites the
    count(*) to count(*) + record_count
 2: SelectStmt sets "OptimizeCountStarForIcebergV2" in the query context
    then IcebergScanPlanner creates plan accordingly.

This mechanism works for simple queries, but can turn on count(*)
optimization in IcebergScanPlanner for all Iceberg V2 tables in complex
queries. Even if only one subquery enables count(*) optimization during
analysis.

With this patch the followings change:
 1: We introduce IcebergV2CountStarAdjuster which we use instead of the
    ArithmethicExpr. So after rewrite we still know if count(*)
    optimization should be enabled for the planner.
 2: Instead of using the query context, we pass the information to the
    IcebergScanPlanner via the TableRef object.

Testing
 * e2e tests

Change-Id: I1940031298eb634aa82c3d32bbbf16bce8eaf874
---
M common/thrift/Query.thrift
A fe/src/main/java/org/apache/impala/analysis/IcebergV2CountStarAccumulator.java
M fe/src/main/java/org/apache/impala/analysis/SelectStmt.java
M fe/src/main/java/org/apache/impala/analysis/TableRef.java
M fe/src/main/java/org/apache/impala/planner/IcebergScanPlanner.java
M fe/src/main/java/org/apache/impala/rewrite/CountStarToConstRule.java
A testdata/workloads/functional-query/queries/QueryTest/iceberg-v2-count-star-optimization-in-complex-query.test
M tests/query_test/test_iceberg.py
8 files changed, 196 insertions(+), 11 deletions(-)


  git pull ssh://gerrit.cloudera.org:29418/Impala-ASF refs/changes/05/23705/3
-- 
To view, visit http://gerrit.cloudera.org:8080/23705
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I1940031298eb634aa82c3d32bbbf16bce8eaf874
Gerrit-Change-Number: 23705
Gerrit-PatchSet: 3
Gerrit-Owner: Zoltan Borok-Nagy <bo...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Riza Suminto <ri...@cloudera.com>

[Impala-ASF-CR] IMPALA-13756: Fix Iceberg V2 count(*) optimization for complex queries

Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/23705 )

Change subject: IMPALA-13756: Fix Iceberg V2 count(*) optimization for complex queries
......................................................................


Patch Set 6:

Build Successful 

https://jenkins.impala.io/job/gerrit-code-review-checks/21215/ : Initial code review checks passed. Use gerrit-verify-dryrun-external or gerrit-verify-dryrun to run full precommit tests.


-- 
To view, visit http://gerrit.cloudera.org:8080/23705
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I1940031298eb634aa82c3d32bbbf16bce8eaf874
Gerrit-Change-Number: 23705
Gerrit-PatchSet: 6
Gerrit-Owner: Zoltan Borok-Nagy <bo...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Peter Rozsa <pr...@cloudera.com>
Gerrit-Reviewer: Riza Suminto <ri...@cloudera.com>
Gerrit-Reviewer: Zoltan Borok-Nagy <bo...@cloudera.com>
Gerrit-Comment-Date: Fri, 19 Dec 2025 13:10:14 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-13756: Fix Iceberg V2 count(*) optimization for complex queries

Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/23705 )

Change subject: IMPALA-13756: Fix Iceberg V2 count(*) optimization for complex queries
......................................................................


Patch Set 7:

Build started: https://jenkins.impala.io/job/gerrit-verify-dryrun/12817/ DRY_RUN=false


-- 
To view, visit http://gerrit.cloudera.org:8080/23705
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I1940031298eb634aa82c3d32bbbf16bce8eaf874
Gerrit-Change-Number: 23705
Gerrit-PatchSet: 7
Gerrit-Owner: Zoltan Borok-Nagy <bo...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Peter Rozsa <pr...@cloudera.com>
Gerrit-Reviewer: Riza Suminto <ri...@cloudera.com>
Gerrit-Reviewer: Zoltan Borok-Nagy <bo...@cloudera.com>
Gerrit-Comment-Date: Fri, 19 Dec 2025 12:44:40 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-13756: Fix Iceberg V2 count(*) optimization for complex queries

Posted by "Zoltan Borok-Nagy (Code Review)" <ge...@cloudera.org>.
Hello Riza Suminto, Peter Rozsa, Impala Public Jenkins, 

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

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

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

Change subject: IMPALA-13756: Fix Iceberg V2 count(*) optimization for complex queries
......................................................................

IMPALA-13756: Fix Iceberg V2 count(*) optimization for complex queries

We optimize plain count(*) queries on Iceberg tables the following way:

       AGGREGATE
       COUNT(*)
           |
       UNION ALL
      /        \
     /          \
    /            \
   SCAN all  ANTI JOIN
   datafiles  /      \
   without   /        \
   deletes  SCAN      SCAN
            datafiles deletes

            ||
          rewrite
            ||
            \/

  ArithmethicExpr: LHS + RHS
      /             \
     /               \
    /                 \
   record_count  AGGREGATE
   of all        COUNT(*)
   datafiles         |
   without       ANTI JOIN
   deletes      /         \
               /           \
               SCAN        SCAN
               datafiles   deletes

This optimization consists of two parts:
 1 Rewriting count(*) expression to count(*) + "record_count" (of data
   files without deletes)
 2 In IcebergScanPlanner we only need to consruct the right side of
   the original UNION ALL operator, i.e.:

            ANTI JOIN
           /         \
          /           \
         SCAN        SCAN
         datafiles   deletes

SelectStmt decides whether we can do the count(*) optimization, and if
so, does the following:

 1: SelectStmt sets 'TotalRecordsNumV2' in the analyzer, then during the
    expression rewrite phase the CountStarToConstRule rewrites the
    count(*) to count(*) + record_count
 2: SelectStmt sets "OptimizeCountStarForIcebergV2" in the query context
    then IcebergScanPlanner creates plan accordingly.

This mechanism works for simple queries, but can turn on count(*)
optimization in IcebergScanPlanner for all Iceberg V2 tables in complex
queries. Even if only one subquery enables count(*) optimization during
analysis.

With this patch the followings change:
 1: We introduce IcebergV2CountStarAccumulator which we use instead of
    the ArithmethicExpr. So after rewrite we still know if count(*)
    optimization should be enabled for the planner.
 2: Instead of using the query context, we pass the information to the
    IcebergScanPlanner via the TableRef object.

Testing
 * e2e tests

Change-Id: I1940031298eb634aa82c3d32bbbf16bce8eaf874
---
M common/thrift/Query.thrift
A fe/src/main/java/org/apache/impala/analysis/IcebergV2CountStarAccumulator.java
M fe/src/main/java/org/apache/impala/analysis/SelectStmt.java
M fe/src/main/java/org/apache/impala/analysis/TableRef.java
M fe/src/main/java/org/apache/impala/planner/IcebergScanPlanner.java
M fe/src/main/java/org/apache/impala/rewrite/CountStarToConstRule.java
A testdata/workloads/functional-query/queries/QueryTest/iceberg-v2-count-star-optimization-in-complex-query.test
M tests/query_test/test_iceberg.py
8 files changed, 196 insertions(+), 11 deletions(-)


  git pull ssh://gerrit.cloudera.org:29418/Impala-ASF refs/changes/05/23705/4
-- 
To view, visit http://gerrit.cloudera.org:8080/23705
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I1940031298eb634aa82c3d32bbbf16bce8eaf874
Gerrit-Change-Number: 23705
Gerrit-PatchSet: 4
Gerrit-Owner: Zoltan Borok-Nagy <bo...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Peter Rozsa <pr...@cloudera.com>
Gerrit-Reviewer: Riza Suminto <ri...@cloudera.com>
Gerrit-Reviewer: Zoltan Borok-Nagy <bo...@cloudera.com>

[Impala-ASF-CR] IMPALA-13756: Fix Iceberg V2 count(*) optimization for complex queries

Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/23705 )

Change subject: IMPALA-13756: Fix Iceberg V2 count(*) optimization for complex queries
......................................................................


Patch Set 5: Code-Review+2


-- 
To view, visit http://gerrit.cloudera.org:8080/23705
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I1940031298eb634aa82c3d32bbbf16bce8eaf874
Gerrit-Change-Number: 23705
Gerrit-PatchSet: 5
Gerrit-Owner: Zoltan Borok-Nagy <bo...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Peter Rozsa <pr...@cloudera.com>
Gerrit-Reviewer: Riza Suminto <ri...@cloudera.com>
Gerrit-Reviewer: Zoltan Borok-Nagy <bo...@cloudera.com>
Gerrit-Comment-Date: Thu, 18 Dec 2025 10:48:14 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-13756: Fix Iceberg V2 count(*) optimization for complex queries

Posted by "Riza Suminto (Code Review)" <ge...@cloudera.org>.
Riza Suminto has posted comments on this change. ( http://gerrit.cloudera.org:8080/23705 )

Change subject: IMPALA-13756: Fix Iceberg V2 count(*) optimization for complex queries
......................................................................


Patch Set 3: Code-Review+1

(3 comments)

http://gerrit.cloudera.org:8080/#/c/23705/2/testdata/workloads/functional-query/queries/QueryTest/iceberg-v2-count-star-optimization-in-complex-query.test
File testdata/workloads/functional-query/queries/QueryTest/iceberg-v2-count-star-optimization-in-complex-query.test:

http://gerrit.cloudera.org:8080/#/c/23705/2/testdata/workloads/functional-query/queries/QueryTest/iceberg-v2-count-star-optimization-in-complex-query.test@65
PS2, Line 65: ), table_b as (
            :     SELECT CO
> Done
Done


http://gerrit.cloudera.org:8080/#/c/23705/2/testdata/workloads/functional-query/queries/QueryTest/iceberg-v2-count-star-optimization-in-complex-query.test@101
PS2, Line 101: --                                      this table has 3 rows in a data file without deletes, it
             : -- 
> Contents of the tables should be the same, so diff counts should still be 0
Ack


http://gerrit.cloudera.org:8080/#/c/23705/2/testdata/workloads/functional-query/queries/QueryTest/iceberg-v2-count-star-optimization-in-complex-query.test@103
PS2, Line 103: --    "count(*)": count(*) in view 'diff_count'.
             : with diff_cou
> Done
Done



-- 
To view, visit http://gerrit.cloudera.org:8080/23705
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I1940031298eb634aa82c3d32bbbf16bce8eaf874
Gerrit-Change-Number: 23705
Gerrit-PatchSet: 3
Gerrit-Owner: Zoltan Borok-Nagy <bo...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Riza Suminto <ri...@cloudera.com>
Gerrit-Reviewer: Zoltan Borok-Nagy <bo...@cloudera.com>
Gerrit-Comment-Date: Mon, 15 Dec 2025 15:35:31 +0000
Gerrit-HasComments: Yes

[Impala-ASF-CR] IMPALA-13756: Fix Iceberg V2 count(*) optimization for complex queries

Posted by "Zoltan Borok-Nagy (Code Review)" <ge...@cloudera.org>.
Zoltan Borok-Nagy has submitted this change and it was merged. ( http://gerrit.cloudera.org:8080/23705 )

Change subject: IMPALA-13756: Fix Iceberg V2 count(*) optimization for complex queries
......................................................................

IMPALA-13756: Fix Iceberg V2 count(*) optimization for complex queries

We optimize plain count(*) queries on Iceberg tables the following way:

       AGGREGATE
       COUNT(*)
           |
       UNION ALL
      /        \
     /          \
    /            \
   SCAN all  ANTI JOIN
   datafiles  /      \
   without   /        \
   deletes  SCAN      SCAN
            datafiles deletes

            ||
          rewrite
            ||
            \/

  ArithmethicExpr: LHS + RHS
      /             \
     /               \
    /                 \
   record_count  AGGREGATE
   of all        COUNT(*)
   datafiles         |
   without       ANTI JOIN
   deletes      /         \
               /           \
               SCAN        SCAN
               datafiles   deletes

This optimization consists of two parts:
 1 Rewriting count(*) expression to count(*) + "record_count" (of data
   files without deletes)
 2 In IcebergScanPlanner we only need to consruct the right side of
   the original UNION ALL operator, i.e.:

            ANTI JOIN
           /         \
          /           \
         SCAN        SCAN
         datafiles   deletes

SelectStmt decides whether we can do the count(*) optimization, and if
so, does the following:

 1: SelectStmt sets 'TotalRecordsNumV2' in the analyzer, then during the
    expression rewrite phase the CountStarToConstRule rewrites the
    count(*) to count(*) + record_count
 2: SelectStmt sets "OptimizeCountStarForIcebergV2" in the query context
    then IcebergScanPlanner creates plan accordingly.

This mechanism works for simple queries, but can turn on count(*)
optimization in IcebergScanPlanner for all Iceberg V2 tables in complex
queries. Even if only one subquery enables count(*) optimization during
analysis.

With this patch the followings change:
 1: We introduce IcebergV2CountStarAccumulator which we use instead of
    the ArithmethicExpr. So after rewrite we still know if count(*)
    optimization should be enabled for the planner.
 2: Instead of using the query context, we pass the information to the
    IcebergScanPlanner via the TableRef object.

Testing
 * e2e tests

Change-Id: I1940031298eb634aa82c3d32bbbf16bce8eaf874
Reviewed-on: http://gerrit.cloudera.org:8080/23705
Tested-by: Impala Public Jenkins <im...@cloudera.com>
Reviewed-by: Zoltan Borok-Nagy <bo...@cloudera.com>
---
M common/thrift/Query.thrift
A fe/src/main/java/org/apache/impala/analysis/IcebergV2CountStarAccumulator.java
M fe/src/main/java/org/apache/impala/analysis/SelectStmt.java
M fe/src/main/java/org/apache/impala/analysis/TableRef.java
M fe/src/main/java/org/apache/impala/planner/IcebergScanPlanner.java
M fe/src/main/java/org/apache/impala/rewrite/CountStarToConstRule.java
M fe/src/test/java/org/apache/impala/analysis/AnalyzeStmtsTest.java
A testdata/workloads/functional-query/queries/QueryTest/iceberg-v2-count-star-optimization-in-complex-query.test
M tests/query_test/test_iceberg.py
9 files changed, 197 insertions(+), 12 deletions(-)

Approvals:
  Impala Public Jenkins: Verified
  Zoltan Borok-Nagy: Looks good to me, approved

-- 
To view, visit http://gerrit.cloudera.org:8080/23705
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I1940031298eb634aa82c3d32bbbf16bce8eaf874
Gerrit-Change-Number: 23705
Gerrit-PatchSet: 8
Gerrit-Owner: Zoltan Borok-Nagy <bo...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Peter Rozsa <pr...@cloudera.com>
Gerrit-Reviewer: Riza Suminto <ri...@cloudera.com>
Gerrit-Reviewer: Zoltan Borok-Nagy <bo...@cloudera.com>

[Impala-ASF-CR] IMPALA-13756: Fix Iceberg V2 count(*) optimization for complex queries

Posted by "Riza Suminto (Code Review)" <ge...@cloudera.org>.
Riza Suminto has posted comments on this change. ( http://gerrit.cloudera.org:8080/23705 )

Change subject: IMPALA-13756: Fix Iceberg V2 count(*) optimization for complex queries
......................................................................


Patch Set 2:

(3 comments)

http://gerrit.cloudera.org:8080/#/c/23705/2/testdata/workloads/functional-query/queries/QueryTest/iceberg-v2-count-star-optimization-in-complex-query.test
File testdata/workloads/functional-query/queries/QueryTest/iceberg-v2-count-star-optimization-in-complex-query.test:

http://gerrit.cloudera.org:8080/#/c/23705/2/testdata/workloads/functional-query/queries/QueryTest/iceberg-v2-count-star-optimization-in-complex-query.test@65
PS2, Line 65: ---- TYPES
            : BIGINT,BIGINT
Add RUNTIME_PROFILE validation?

---- RUNTIME_PROFILE:
  |  output exprs: count(*) - count(*) + CAST(3 AS BIGINT), count(*)


http://gerrit.cloudera.org:8080/#/c/23705/2/testdata/workloads/functional-query/queries/QueryTest/iceberg-v2-count-star-optimization-in-complex-query.test@101
PS2, Line 101: ---- RESULTS
             : 0,0
nit: This result is a bit confusing to me if I compare it against the output exprs.

  output exprs: count(*) + CAST(1 AS BIGINT) - count(*) + CAST(3 AS BIGINT), count(*)

I thought it should result in 4,0. Can you explain what each 'count(*)' values are?


http://gerrit.cloudera.org:8080/#/c/23705/2/testdata/workloads/functional-query/queries/QueryTest/iceberg-v2-count-star-optimization-in-complex-query.test@103
PS2, Line 103: ---- TYPES
             : BIGINT,BIGINT
Can validate RUNTIME_PROFILE here, so test case below is not needed.

---- RUNTIME_PROFILE:
  |  output exprs: count(*) + CAST(1 AS BIGINT) - count(*) + CAST(3 AS BIGINT), count(*)



-- 
To view, visit http://gerrit.cloudera.org:8080/23705
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I1940031298eb634aa82c3d32bbbf16bce8eaf874
Gerrit-Change-Number: 23705
Gerrit-PatchSet: 2
Gerrit-Owner: Zoltan Borok-Nagy <bo...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Riza Suminto <ri...@cloudera.com>
Gerrit-Comment-Date: Wed, 03 Dec 2025 00:13:12 +0000
Gerrit-HasComments: Yes

[Impala-ASF-CR] IMPALA-13756: Fix Iceberg V2 count(*) optimization for complex queries

Posted by "Zoltan Borok-Nagy (Code Review)" <ge...@cloudera.org>.
Zoltan Borok-Nagy has posted comments on this change. ( http://gerrit.cloudera.org:8080/23705 )

Change subject: IMPALA-13756: Fix Iceberg V2 count(*) optimization for complex queries
......................................................................


Patch Set 3:

(5 comments)

Thanks for the comments!

http://gerrit.cloudera.org:8080/#/c/23705/2/common/thrift/Query.thrift
File common/thrift/Query.thrift:

http://gerrit.cloudera.org:8080/#/c/23705/2/common/thrift/Query.thrift@a991
PS2, Line 991: 
             : 
             : 
> Can this be marked as deprecated instead?
I guess it can cause issues when coordinator and executor have different versions. Added a comment about the deprecation.


http://gerrit.cloudera.org:8080/#/c/23705/2/fe/src/main/java/org/apache/impala/analysis/IcebergV2CountStarAdjuster.java
File fe/src/main/java/org/apache/impala/analysis/IcebergV2CountStarAdjuster.java:

http://gerrit.cloudera.org:8080/#/c/23705/2/fe/src/main/java/org/apache/impala/analysis/IcebergV2CountStarAdjuster.java@20
PS2, Line 20: 
> Add documentation about what this expression is about.
Done


http://gerrit.cloudera.org:8080/#/c/23705/2/testdata/workloads/functional-query/queries/QueryTest/iceberg-v2-count-star-optimization-in-complex-query.test
File testdata/workloads/functional-query/queries/QueryTest/iceberg-v2-count-star-optimization-in-complex-query.test:

http://gerrit.cloudera.org:8080/#/c/23705/2/testdata/workloads/functional-query/queries/QueryTest/iceberg-v2-count-star-optimization-in-complex-query.test@65
PS2, Line 65: ), table_b as (
            :     SELECT CO
> Add RUNTIME_PROFILE validation?
Done


http://gerrit.cloudera.org:8080/#/c/23705/2/testdata/workloads/functional-query/queries/QueryTest/iceberg-v2-count-star-optimization-in-complex-query.test@101
PS2, Line 101: --                                      this table has 3 rows in a data file without deletes, it
             : -- 
> nit: This result is a bit confusing to me if I compare it against the outpu
Contents of the tables should be the same, so diff counts should still be 0s. Added explanation to the output exprs.


http://gerrit.cloudera.org:8080/#/c/23705/2/testdata/workloads/functional-query/queries/QueryTest/iceberg-v2-count-star-optimization-in-complex-query.test@103
PS2, Line 103: --    "count(*)": count(*) in view 'diff_count'.
             : with diff_cou
> Can validate RUNTIME_PROFILE here, so test case below is not needed.
Done



-- 
To view, visit http://gerrit.cloudera.org:8080/23705
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I1940031298eb634aa82c3d32bbbf16bce8eaf874
Gerrit-Change-Number: 23705
Gerrit-PatchSet: 3
Gerrit-Owner: Zoltan Borok-Nagy <bo...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Riza Suminto <ri...@cloudera.com>
Gerrit-Reviewer: Zoltan Borok-Nagy <bo...@cloudera.com>
Gerrit-Comment-Date: Wed, 10 Dec 2025 11:49:18 +0000
Gerrit-HasComments: Yes

[Impala-ASF-CR] IMPALA-13756: Fix Iceberg V2 count(*) optimization for complex queries

Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/23705 )

Change subject: IMPALA-13756: Fix Iceberg V2 count(*) optimization for complex queries
......................................................................


Patch Set 5: Verified-1

Build failed: https://jenkins.impala.io/job/gerrit-verify-dryrun/12811/


-- 
To view, visit http://gerrit.cloudera.org:8080/23705
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I1940031298eb634aa82c3d32bbbf16bce8eaf874
Gerrit-Change-Number: 23705
Gerrit-PatchSet: 5
Gerrit-Owner: Zoltan Borok-Nagy <bo...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Peter Rozsa <pr...@cloudera.com>
Gerrit-Reviewer: Riza Suminto <ri...@cloudera.com>
Gerrit-Reviewer: Zoltan Borok-Nagy <bo...@cloudera.com>
Gerrit-Comment-Date: Thu, 18 Dec 2025 15:41:14 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-13756: Fix Iceberg V2 count(*) optimization for complex queries

Posted by "Riza Suminto (Code Review)" <ge...@cloudera.org>.
Riza Suminto has posted comments on this change. ( http://gerrit.cloudera.org:8080/23705 )

Change subject: IMPALA-13756: Fix Iceberg V2 count(*) optimization for complex queries
......................................................................


Patch Set 2:

(2 comments)

http://gerrit.cloudera.org:8080/#/c/23705/2/common/thrift/Query.thrift
File common/thrift/Query.thrift:

http://gerrit.cloudera.org:8080/#/c/23705/2/common/thrift/Query.thrift@a991
PS2, Line 991: 
             : 
             : 
Can this be marked as deprecated instead?
Downstream code might relies on this in some way.


http://gerrit.cloudera.org:8080/#/c/23705/2/fe/src/main/java/org/apache/impala/analysis/IcebergV2CountStarAdjuster.java
File fe/src/main/java/org/apache/impala/analysis/IcebergV2CountStarAdjuster.java:

http://gerrit.cloudera.org:8080/#/c/23705/2/fe/src/main/java/org/apache/impala/analysis/IcebergV2CountStarAdjuster.java@20
PS2, Line 20: public class IcebergV2CountStarAdjuster extends ArithmeticExpr {
Add documentation about what this expression is about.

nit: IcebergV2CountStarAdder or IcebergV2CountStarAccumulator sounds better.



-- 
To view, visit http://gerrit.cloudera.org:8080/23705
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I1940031298eb634aa82c3d32bbbf16bce8eaf874
Gerrit-Change-Number: 23705
Gerrit-PatchSet: 2
Gerrit-Owner: Zoltan Borok-Nagy <bo...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Riza Suminto <ri...@cloudera.com>
Gerrit-Comment-Date: Tue, 02 Dec 2025 22:25:42 +0000
Gerrit-HasComments: Yes

[Impala-ASF-CR] IMPALA-13756: Fix Iceberg V2 count(*) optimization for complex queries

Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/23705 )

Change subject: IMPALA-13756: Fix Iceberg V2 count(*) optimization for complex queries
......................................................................


Patch Set 1:

(1 comment)

gerrit-auto-critic failed. You can reproduce it locally using command:

  python3 bin/jenkins/critique-gerrit-review.py --dryrun

To run it, you might need a virtual env with Python3's venv installed.

http://gerrit.cloudera.org:8080/#/c/23705/1/common/thrift/Query.thrift
File common/thrift/Query.thrift:

http://gerrit.cloudera.org:8080/#/c/23705/1/common/thrift/Query.thrift@a993
PS1, Line 993: 
Deleting required field 'optimize_count_star_for_iceberg_v2' of TQueryCtx might break the compatibility between impalad and catalogd/statestore during upgrade



-- 
To view, visit http://gerrit.cloudera.org:8080/23705
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I1940031298eb634aa82c3d32bbbf16bce8eaf874
Gerrit-Change-Number: 23705
Gerrit-PatchSet: 1
Gerrit-Owner: Zoltan Borok-Nagy <bo...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Comment-Date: Fri, 21 Nov 2025 12:46:59 +0000
Gerrit-HasComments: Yes

[Impala-ASF-CR] IMPALA-13756: Fix Iceberg V2 count(*) optimization for complex queries

Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/23705 )

Change subject: IMPALA-13756: Fix Iceberg V2 count(*) optimization for complex queries
......................................................................


Patch Set 1:

Build Successful 

https://jenkins.impala.io/job/gerrit-code-review-checks/21011/ : Initial code review checks passed. Use gerrit-verify-dryrun-external or gerrit-verify-dryrun to run full precommit tests.


-- 
To view, visit http://gerrit.cloudera.org:8080/23705
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I1940031298eb634aa82c3d32bbbf16bce8eaf874
Gerrit-Change-Number: 23705
Gerrit-PatchSet: 1
Gerrit-Owner: Zoltan Borok-Nagy <bo...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Comment-Date: Fri, 21 Nov 2025 13:12:17 +0000
Gerrit-HasComments: No