[ 
https://issues.apache.org/jira/browse/CALCITE-6195?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17805342#comment-17805342
 ] 

David Dali Susanibar Arce commented on CALCITE-6195:
----------------------------------------------------

Thank you Alessandro for your comments.

We are able to resolve qualified names in SQL Query, main problem appear when 
we are trying to also apply qualified names into SQL Expressions.

For that reason when we create MapString, RelDataType> nameToTypeMap` or 
`Map<String, RexNode> nameToNodeMap` we could map qualified names but Calcite 
core internally are not implemented properly logic to consider qualified names 
for SQL Expressions.

> SqlValidator validateParameterizedExpression is not supporting qualified paths
> ------------------------------------------------------------------------------
>
>                 Key: CALCITE-6195
>                 URL: https://issues.apache.org/jira/browse/CALCITE-6195
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.36.0
>            Reporter: David Dali Susanibar Arce
>            Priority: Major
>              Labels: pull-request-available
>
> The SQLValidator.validateParameterizedExpression method can be used to 
> validate parameterized expressions.
> It is possible to register 
> [validateParameterizedExpression|https://github.com/apache/calcite/blob/1b11d99e65d03a15ae4b25c47250b6918ce9aa10/core/src/test/java/org/apache/calcite/test/SqlValidatorTest.java#L11421:L11435]:
> {code:java}
> final Map<String, RelDataType> nameToTypeMap = new HashMap<>();
> nameToTypeMap.put("A", intType);
> nameToTypeMap.put("B", intTypeNull); 
> final String expr = "a + b";
> final SqlNode validated = validator.validateParameterizedExpression(sqlNode, 
> nameToTypeMap);{code}
>  
> Problems appear if we are trying to register qualified paths:
> {code:java}
> final Map<String, RelDataType> nameToTypeMap = new HashMap<>(); 
> nameToTypeMap.put("EMP.A", intType);
> nameToTypeMap.put("EMP.B", intTypeNull); 
> final String expr = "EMP.a + EMP.b";
> final SqlNode validated = validator.validateParameterizedExpression(sqlNode, 
> nameToTypeMap); 
> Error:
> org.apache.calcite.runtime.CalciteContextException: From line 1, column 1 to 
> line 1, column 3: Unknown identifier 'EMP'
> {code}
> I would appreciate if you could provide me with some advice regarding how to 
> resolve this error.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to