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

Change subject: IMPALA-14910: Calcite planner: support expressions in limit 
clause
......................................................................


Patch Set 3:

(1 comment)

http://gerrit.cloudera.org:8080/#/c/24268/3/testdata/workloads/functional-query/queries/QueryTest/calcite.test
File testdata/workloads/functional-query/queries/QueryTest/calcite.test:

http://gerrit.cloudera.org:8080/#/c/24268/3/testdata/workloads/functional-query/queries/QueryTest/calcite.test@1380
PS3, Line 1380: select id from functional.alltypes order by id limit 1 + 1
> Fixed OFFSET and added a test
OFFSET works now, thanks - "offset 2 + 3" and "limit 1 + 1" both plan and run. 
A few more shapes on PS5 (planner=calcite, fallback_planner=none), in the order 
I would weigh them.

A value that arrives as a literal never reaches verifyValue - onMatch returns 
early for it - and surfaces further down instead:

    limit cast(null as int)    NPE: Cannot invoke 
"java.math.BigDecimal.longValue()"
                                    because RexLiteral.value(...) is null
    offset cast(null as int)   same
    limit -1                   IllegalArgumentException: null
    offset -1                  IllegalStateException: null

For the NULL ones the stack points at ImpalaSortRel.<init>, where 
RexLiteral.value(fetch) comes back null; for the negative ones I did not chase 
where the exception is raised.

The original planner has words for all four: "LIMIT expression evaluates to 
NULL: CAST(NULL AS INT)" and "LIMIT/OFFSET must be a non-negative integer: -1 = 
-1". The non-negative check is already in this patch - "limit 2 - 3" goes 
through the rule and reports it properly - it just is not reached when the 
value arrives as a literal. And unlike "limit id", "limit -1" is well inside 
what people write; it used to be a parse error before the parser change, so 
this is new ground rather than a regression.

The bare NPE is the part I would care about most: it is the same shape 24260 is 
taking out of trunc.

And a small one: verifyValue's messages always say LIMIT, so "offset 2 - 3" 
comes back as "LIMIT must be a non-negative integer."

Would running verifyValue on literals as well, with the clause name passed in, 
cover all of these?



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

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ic01a0144671485156654e7685d0d5816fa743f9d
Gerrit-Change-Number: 24268
Gerrit-PatchSet: 3
Gerrit-Owner: Steve Carlin <[email protected]>
Gerrit-Reviewer: Aleksandr Efimov <[email protected]>
Gerrit-Reviewer: Impala Public Jenkins <[email protected]>
Gerrit-Reviewer: Steve Carlin <[email protected]>
Gerrit-Comment-Date: Tue, 25 Aug 2026 16:13:35 +0000
Gerrit-HasComments: Yes

Reply via email to