[
https://issues.apache.org/jira/browse/CALCITE-7268?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Mihai Budiu resolved CALCITE-7268.
----------------------------------
Fix Version/s: 1.42.0
Resolution: Fixed
Fixed in
[https://github.com/apache/calcite/commit/82cdcc78dbcb8df44827c1a9fe1126ccfffc21ac]
Thank you for your review [~caicancai]
> SqlToRelConverter throws exception if lambda contains IN
> --------------------------------------------------------
>
> Key: CALCITE-7268
> URL: https://issues.apache.org/jira/browse/CALCITE-7268
> Project: Calcite
> Issue Type: Bug
> Components: core
> Affects Versions: 1.41.0
> Reporter: Dmitry Sysolyatin
> Assignee: Dmitry Sysolyatin
> Priority: Major
> Labels: pull-request-available
> Fix For: 1.42.0
>
>
> Test case [1]
> {code}
> @Test void testLambdaExpressionWithIn() {
> final String sql = "select filter_function(ARRAY[1,2,3,4], (n) -> n IN
> (1,3))";
> fixture()
> .withFactory(c ->
> c.withOperatorTable(t ->
> MockSqlOperatorTable.standard().extend()))
> .withSql(sql)
> .ok();
> }
> {code}
> Exception:
> {code}
> while converting `N` = CAST(1 AS BIGINT)
> java.lang.RuntimeException: while converting `N` = CAST(1 AS BIGINT)
> at
> org.apache.calcite.sql2rel.ReflectiveConvertletTable.lambda$registerNodeTypeMethod$1(ReflectiveConvertletTable.java:99)
> at
> org.apache.calcite.sql2rel.SqlNodeToRexConverterImpl.convertCall(SqlNodeToRexConverterImpl.java:62)
> at
> org.apache.calcite.sql2rel.SqlToRelConverter$Blackboard.visit(SqlToRelConverter.java:5985)
> at
> org.apache.calcite.sql2rel.SqlToRelConverter$Blackboard.visit(SqlToRelConverter.java:5148)
> at org.apache.calcite.sql.SqlCall.accept(SqlCall.java:175)
> at
> org.apache.calcite.sql2rel.SqlToRelConverter$Blackboard.convertExpression(SqlToRelConverter.java:5799)
> at
> org.apache.calcite.sql2rel.SqlToRelConverter.convertInToOr(SqlToRelConverter.java:1781)
> at
> org.apache.calcite.sql2rel.SqlToRelConverter.substituteSubQuery(SqlToRelConverter.java:1231)
> {code}
> The reason is that SqlToRelConverter tries to call substituteSubQuery on a
> Blackboard that doesn’t have the lambda parameters in scope. Instead,
> substituteSubQuery should be called on the lambda’s Blackboard [2]
> [1]
> https://github.com/apache/calcite/commit/7d78da6a465d05a1e147291af20ee074bf814e88
> [2]
> https://github.com/apache/calcite/blob/95350ed1a449bbb2f008fcf2b704544e7d95c410/core/src/main/java/org/apache/calcite/sql2rel/SqlToRelConverter.java#L2283
--
This message was sent by Atlassian Jira
(v8.20.10#820010)