[
https://issues.apache.org/jira/browse/CALCITE-7269?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Mihai Budiu reassigned CALCITE-7269:
------------------------------------
Assignee: Mihai Budiu
> SqlValidator throws exception if lambda parameter is struct
> -----------------------------------------------------------
>
> Key: CALCITE-7269
> URL: https://issues.apache.org/jira/browse/CALCITE-7269
> Project: Calcite
> Issue Type: Bug
> Components: core
> Affects Versions: 1.41.0
> Reporter: Dmitry Sysolyatin
> Assignee: Mihai Budiu
> Priority: Major
>
> Test case [1]
> {code:java}
> @Test void testLambdaExpressionWithRowParameter() {
> final String sql = "select \"EXISTS\"(array(ROW(true, false)), x ->
> x.\"EXPR$1\")";
> fixture()
> .withFactory(c ->
> c.withOperatorTable(t ->
> SqlValidatorTest.operatorTableFor(SqlLibrary.SPARK)))
> .withSql(sql)
> .ok();
> }
> {code}
> Exception:
> {code:java}
> From line 1, column 47 to line 1, column 56: Param 'X.EXPR$1' not found in
> lambda expression '`X` -> `X`.`EXPR$1`'
> org.apache.calcite.runtime.CalciteContextException: From line 1, column 47 to
> line 1, column 56: Param 'X.EXPR$1' not found in lambda expression '`X` ->
> `X`.`EXPR$1`'
> at
> java.base/jdk.internal.reflect.DirectConstructorHandleAccessor.newInstance(DirectConstructorHandleAccessor.java:62)
> at
> java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:502)
> at
> java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:486)
> at
> org.apache.calcite.runtime.Resources$ExInstWithCause.ex(Resources.java:511)
> at org.apache.calcite.sql.SqlUtil.newContextException(SqlUtil.java:960)
> at org.apache.calcite.sql.SqlUtil.newContextException(SqlUtil.java:945)
> {code}
> There are three things about lambda implementation:
> 1. SqlLambdaScope.fullyQualified returns the parameter only if the
> SqlIdentifier matches exactly. If we change it to just use getComponent(0),
> then…
> 2. SqlLambdaScope sets lambda parameters to ANY. But ANY does not have fields.
> 3. LambdaOperandTypeChecker sets the actual types. I think this is not the
> right place to set actual types [2]. (or it is ?)
> [1]
> [https://github.com/apache/calcite/commit/44bf468d867a6623e905c98ec8e3c64daa2711b7]
> [2]
> [https://github.com/apache/calcite/blob/7ecd358b2e4678e8c74e6689a235912361aa6a8a/core/src/main/java/org/apache/calcite/sql/type/OperandTypes.java#L1815-L1817]
--
This message was sent by Atlassian Jira
(v8.20.10#820010)