-
Notifications
You must be signed in to change notification settings - Fork 2.5k
[CALCITE-6242] Enhance lambda closure parsing #4926
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8115,7 +8115,10 @@ void testGroupExpressionEquivalenceParams() { | |
|
|
||
| /** Test case for | ||
| * <a href="https://issues.apache.org/jira/browse/CALCITE-3679">[CALCITE-3679] | ||
| * Allow lambda expressions in SQL queries</a>. */ | ||
| * Allow lambda expressions in SQL queries</a>. | ||
| * <a href="https://issues.apache.org/jira/browse/CALCITE-6242">[CALCITE-6242] | ||
| * Enhance lambda closure parsing</a>. | ||
| * */ | ||
| @Test void testHigherOrderFunction() { | ||
| final SqlValidatorFixture s = fixture() | ||
| .withOperatorTable(MockSqlOperatorTable.standard().extend()); | ||
|
|
@@ -8129,6 +8132,10 @@ void testGroupExpressionEquivalenceParams() { | |
| .type("RecordType(INTEGER NOT NULL EXPR$0) NOT NULL"); | ||
| s.withSql("select HIGHER_ORDER_FUNCTION2(1, () -> 0.1)") | ||
| .type("RecordType(INTEGER NOT NULL EXPR$0) NOT NULL"); | ||
| s.withSql("select HIGHER_ORDER_FUNCTION(1, (x, y) -> x + 1 + ^emp.deptno^) from emp") | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add jira message in test.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
| .ok(); | ||
| s.withSql("select HIGHER_ORDER_FUNCTION(1, (x, y) -> x + 1 + ^deptno^) from emp") | ||
| .ok(); | ||
|
|
||
| // test for type check | ||
| s.withSql("select HIGHER_ORDER_FUNCTION(1, (x, y) -> ^x + 1^)") | ||
|
|
@@ -8146,13 +8153,6 @@ void testGroupExpressionEquivalenceParams() { | |
| .fails("Cannot apply '(?s).*HIGHER_ORDER_FUNCTION' to arguments of type " | ||
| + "'HIGHER_ORDER_FUNCTION\\(<INTEGER>, <FUNCTION\\(ANY, ANY, ANY\\) -> ANY>\\)'.*"); | ||
|
|
||
| // test for illegal parameters | ||
| s.withSql("select HIGHER_ORDER_FUNCTION(1, (x, y) -> x + 1 + ^emp.deptno^) from emp") | ||
| .fails("Param 'EMP\\.DEPTNO' not found in lambda expression " | ||
| + "'\\(`X`, `Y`\\) -> `X` \\+ 1 \\+ `EMP`\\.`DEPTNO`'"); | ||
| s.withSql("select HIGHER_ORDER_FUNCTION(1, (x, y) -> x + 1 + ^deptno^) from emp") | ||
| .fails("Param 'DEPTNO' not found in lambda expression " | ||
| + "'\\(`X`, `Y`\\) -> `X` \\+ 1 \\+ `DEPTNO`'"); | ||
| } | ||
|
|
||
| /** Test case for <a href="https://issues.apache.org/jira/browse/CALCITE-7193">[CALCITE-7193] | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -102,3 +102,16 @@ select "EXISTS"(array[array[1, 2], array[3, 4]], x -> x[1] = 1); | |
| (1 row) | ||
|
|
||
| !ok | ||
|
|
||
| # [CALCITE-6242] Enhance lambda closure parsing | ||
| select * | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. also here. |
||
| from (select array(1, 2, 3) as arr) as t1 inner join | ||
| (select 1 as v) as t2 on "EXISTS"(arr, x -> x = t2.v); | ||
| +-----------+---+ | ||
| | ARR | V | | ||
| +-----------+---+ | ||
| | [1, 2, 3] | 1 | | ||
| +-----------+---+ | ||
| (1 row) | ||
|
|
||
| !ok | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you could add some comments here to explain the reason.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done, thanks