pengzhiwei created CALCITE-2982:
-----------------------------------
Summary: SqlItemOpeator should throw understandable exception
message for incorrect field type
Key: CALCITE-2982
URL: https://issues.apache.org/jira/browse/CALCITE-2982
Project: Calcite
Issue Type: Bug
Components: core
Reporter: pengzhiwei
Assignee: pengzhiwei
Fix For: 1.20.0
In the follow sql:
{code:java}
sql("select name[0] from dept").ok();
{code}
_name_ is a field of _VARCHAR_ type, the follow exception message is thrown out:
{code:java}
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)
{code}
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.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)