Uploaded image for project: 'Calcite'
  1. Calcite
  2. CALCITE-4548

SqlToRelConverter#convertExpression can not convert SqlNode which has subQuery

    XMLWordPrintableJSON

    Details

      Description

      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 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);
      

       

       

      and the npe,

       

      // 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)
      

       

       

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                yr jibiyr
                Reporter:
                yr jibiyr
              • Votes:
                0 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 3.5h
                  3.5h