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

SqlItemOperator should throw understandable exception message for incorrect operand type

    XMLWordPrintableJSON

    Details

      Description

      In the following sql:

      select name[0] from dept
      

      name is a field of VARCHAR type, the follow exception message is thrown out:

      java.lang.AssertionError: VARCHAR
      at org.apache.calcite.sql.fun.SqlItemOperator.getChecker(SqlItemOperator.java:109)
      at org.apache.calcite.sql.fun.SqlItemOperator.checkOperandTypes(SqlItemOperator.java:91)
      at org.apache.calcite.sql.SqlOperator.validateOperands(SqlOperator.java:432)
      at org.apache.calcite.sql.SqlOperator.deriveType(SqlOperator.java:516)
      at org.apache.calcite.sql.validate.SqlValidatorImpl$DeriveTypeVisitor.visit(SqlValidatorImpl.java:5607)
      at org.apache.calcite.sql.validate.SqlValidatorImpl$DeriveTypeVisitor.visit(SqlValidatorImpl.java:5594)
      at org.apache.calcite.sql.SqlCall.accept(SqlCall.java:139)
      

      The exception message is hard to understand  for user. I think a message like "Cannot apply item opeator to VARCHAR type for filed "name"  at line xx column xx " is more friendly to the user.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                pzw2018 pengzhiwei
                Reporter:
                pzw2018 pengzhiwei
              • Votes:
                0 Vote for this issue
                Watchers:
                3 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 - 2h
                  2h