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

Julian Hyde edited comment on CALCITE-4548 at 3/25/21, 7:33 PM:
----------------------------------------------------------------

You are correct that {{SqlToRelConverter.convertExpression()}} is a public API. 
I had forgotten that fact, and I apologize.

The method is only used in two places in Calcite code, and is not used in any 
tests. So, clearly, it is no surprise that there are bugs.

Fixing this will entail writing some tests, and probably doing the same kind of 
expansions that {{SqlToRelConverter.convertQuery()}} does. Contributions 
welcome.


was (Author: julianhyde):
You are correct that {{SqlToRelConverter.convertExpression()}} is a public API. 
I had forgotten that fact. It only used in two places in Calcite code, and is 
not used in any tests. So, clearly, it may be buggy.

Fixing this will entail writing some tests, and probably doing the same kind of 
expansions that {{SqlToRelConverter.convertQuery()}} does. Contributions 
welcome.

> SqlToRelConverter#convertExpression can not convert SqlNode which has subQuery
> ------------------------------------------------------------------------------
>
>                 Key: CALCITE-4548
>                 URL: https://issues.apache.org/jira/browse/CALCITE-4548
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.26.0
>            Reporter: jibiyr
>            Priority: Major
>
> hi community, when I use  *SqlToRelConverter* to convertExpression,I found it 
> does  not registery subQuery before convertExpression, so the 
> convertExpression throw npe.
> here is the executable example
>  
> {code:java}
> // code placeholder
> CalciterHelper calciterHelper = new CalciterHelper(config);
> SqlNode parse = calciterHelper.parseExpression("ID IN (1, 2, 3)");
> HashMap<String, RexNode> nameToNodeMap = new HashMap<>();
> nameToNodeMap.put("ID",new RexInputRef(0, 
> calciterHelper.getTypeFactory().createSqlType(SqlTypeName.INTEGER)));
> final Map<String, RelDataType> nameToTypeMap = new HashMap<>();
> for (Map.Entry<String, RexNode> entry : nameToNodeMap.entrySet()) {
>   nameToTypeMap.put(entry.getKey(), entry.getValue().getType());
> }
> SqlValidatorImpl orCreateValidator = calciterHelper.getOrCreateValidator();
> orCreateValidator.validateCall((SqlCall) parse,new 
> ParameterScope(orCreateValidator,nameToTypeMap));
> SqlToRelConverter orCreateSqlToRelConverter = 
> calciterHelper.getOrCreateSqlToRelConverter();
> orCreateSqlToRelConverter.convertExpression(parse,nameToNodeMap);
> {code}
>  
>  
> and the npe,
>  
> {code:java}
> // code placeholder
> Exception in thread "main" java.lang.NullPointerExceptionException in thread 
> "main" java.lang.NullPointerException 
> at java.util.Objects.requireNonNull(Objects.java:203) 
> at 
> org.apache.calcite.sql2rel.SqlToRelConverter$Blackboard.convertExpression(SqlToRelConverter.java:4914)
> {code}
>  
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to