IGNITE-28739 SQL Calcite: Add expression support for FETCH - #13464
IGNITE-28739 SQL Calcite: Add expression support for FETCH#13464tkalkirill wants to merge 13 commits into
Conversation
| long fetch = validateAndGetFetch(rel.fetch, SortNode.FETCH_DEFAULT); | ||
|
|
||
| // Zero FETCH is enforced by the outer IgniteLimit, while SortNode accepts only positive FETCH values. | ||
| if (fetch == 0) |
There was a problem hiding this comment.
why do we need this change ? I run limited set of tests and it`s all ok, plz clarify ?
Also if this fix is helpful for smth. it looks hacky
- run validateAndGetFetch with SortNode.FETCH_DEFAULT
- additional check and additional set : fetch = SortNode.FETCH_DEFAULT;
There was a problem hiding this comment.
You're right, I overdid it a bit, I got rid of it.
| super.validateSelect(select, targetRowType); | ||
|
|
||
| validateFetchOffset(select.getFetch(), "fetch / limit"); | ||
| validateFetch(select, "fetch / limit"); |
There was a problem hiding this comment.
now we have 2 functions: one - for 'validateFetch' and other for 'validateFetchOffset' ? looks weird
There was a problem hiding this comment.
Agree, it looks weird. This is temporary because the current ticket adds expression support only for FETCH/LIMIT, while OFFSET still uses the existing validation path. We will align OFFSET behavior and consolidate these methods in the follow-up ticket.
| if (call.isA(SqlKind.QUERY)) | ||
| throw newValidationError(call, IgniteResource.INSTANCE.illegalFetchLimit(clauseName)); | ||
|
|
||
| if (call.getKind() == SqlKind.OVER) |
There was a problem hiding this comment.
I don`t think that this is a good approach:
- comment this line : if (call.getKind() == SqlKind.OVER)
and run 'testInvalidFetchExpression' - you obtain aggregate related error, i mean - if you miss some operands comparison here - you will obtain confusing exception. - I don`t like an idea to handle each stupid oparation here, you will always miss smth, check :
'SELECT * FROM TEST_REPL FETCH FIRST (1=1) ROWS ONLY' but if you want - you can do it with extended tests for all such a cases
There was a problem hiding this comment.
I partially agree that covering every possible invalid expression and keeping all related errors consistent may be quite cumbersome. For now, I’ll remove these specific checks and rely on the general validation. If a concrete need arises, we can restore them together with focused tests.
zstan
left a comment
There was a problem hiding this comment.
one minor, plz append this check - help TC with time economy plz )
|
|
||
| /** */ | ||
| @Test | ||
| public void testFetchExpression() throws Exception { |
There was a problem hiding this comment.
let simplify these tests a bit, plz append "assumeNoTransactions();"
/** */
private void assumeNoTransactions() {
assumeTrue("Test use queries that doesn't touch any data. Skip for tx modes", sqlTxMode == SqlTransactionMode.NONE);
}
https://issues.apache.org/jira/browse/IGNITE-28739