Aleksandr Efimov has posted comments on this change. ( 
http://gerrit.cloudera.org:8080/24718 )

Change subject: IMPALA-15278: Fix incorrect cardinality with OFFSET
......................................................................


Patch Set 3:

(2 comments)

Read through PS3. Three notes; the cardinality=0 one is the only one I would 
call a question rather than a nit.

http://gerrit.cloudera.org:8080/#/c/24718/3/fe/src/main/java/org/apache/impala/planner/PlanNode.java
File fe/src/main/java/org/apache/impala/planner/PlanNode.java:

http://gerrit.cloudera.org:8080/#/c/24718/3/fe/src/main/java/org/apache/impala/planner/PlanNode.java@816
PS3, Line 816:   protected long capCardinalityAtLimit(long cardinality, long 
offset) {
Worth a second look at what a zero does downstream. subquery-rewrite.test in 
this patch changes more than a number: "03:NESTED LOOP JOIN [RIGHT SEMI JOIN]" 
becomes "LEFT SEMI JOIN" and the inputs swap, because the TOP-N under it now 
estimates cardinality=0 (the scan estimates 1 row after "id < 5", and offset 6 
takes it to 0). ExchangeNode already produced zeros this way, but SortNode did 
not, so this widens where a 0 can appear.

Since the input is an estimate, offset > estimate does not really mean "empty". 
IcebergDeleteJoinNode line 130 clamps at 1 after a similar subtraction - no 
reason stated there, but the shape is the same. Is the join flip intended here, 
or would clamping at 1 fit the rest of the planner better?


http://gerrit.cloudera.org:8080/#/c/24718/3/testdata/workloads/functional-planner/queries/PlannerTest/card-limit-offset.test
File 
testdata/workloads/functional-planner/queries/PlannerTest/card-limit-offset.test:

http://gerrit.cloudera.org:8080/#/c/24718/3/testdata/workloads/functional-planner/queries/PlannerTest/card-limit-offset.test@16
PS3, Line 16: # OFFSET in MERGING-EXCHANGE
The new file covers offset below the estimate (7.30K rows, offset 6200) in both 
shapes. The case that actually moved a plan elsewhere - offset above the 
estimate, where the cardinality drops to 0 - shows up only in the 
subquery-rewrite golden. Worth one query here too, so the 0 case lives in the 
file named after it.



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

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I3b628beabc5c7ec6c4fdda9dff6aaf7a4acae538
Gerrit-Change-Number: 24718
Gerrit-PatchSet: 3
Gerrit-Owner: Quanlong Huang <[email protected]>
Gerrit-Reviewer: Aleksandr Efimov <[email protected]>
Gerrit-Reviewer: Impala Public Jenkins <[email protected]>
Gerrit-Reviewer: Michael Smith <[email protected]>
Gerrit-Reviewer: Quanlong Huang <[email protected]>
Gerrit-Comment-Date: Tue, 25 Aug 2026 17:23:58 +0000
Gerrit-HasComments: Yes

Reply via email to