You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Bohdan Kazydub (JIRA)" <ji...@apache.org> on 2018/10/16 12:26:00 UTC

[jira] [Updated] (CALCITE-2627) UnsupportedOperationException with unclear message is shown when SqlNode with unknown type is validated

     [ https://issues.apache.org/jira/browse/CALCITE-2627?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Bohdan Kazydub updated CALCITE-2627:
------------------------------------
    Description: 
If RelDataType for SqlNode is unknown then SqlValidatorImpl#{color:#ffc66d}getValidatedNodeType{color}(SqlNode node) (see https://github.com/apache/calcite/blob/59b76701d9c805f51b0929577ca604fdbfe00b0b/core/src/main/java/org/apache/calcite/sql/validate/SqlValidatorImpl.java#L1555) throws Util.needToImplement(node), which is the following:

{code:java}
public static RuntimeException needToImplement(Object o) {
    String description = null;
    if (o != null) {
      description = o.getClass().toString() + ": " + o.toString();
    }
    throw new UnsupportedOperationException(description);
}
{code}
Javadoc for the method dictates that the method 'Returns [in a sense of "throws"] a RuntimeException indicating that a particular feature has not been implemented, but should be.'. As not every unknown type should be implemented, call to this method should be replaced with throwing of an RuntimeException (UnsupportedOperationException, perhaps) containing a more helpful message, something like 'Unknown type: [node.toString()]'.

For example, currently there is following error:
{code}
0: jdbc:calcite:model=target/test-classes/mod> select cast('' as sometype) from (values(1));
Error: Error while executing SQL "select cast('' as sometype) from (values(1))": class org.apache.calcite.sql.SqlIdentifier: SOMETYPE (state=,code=0)
{code}

  was:
If RelDataType for SqlNode is unknown then SqlValidatorImpl#{color:#ffc66d}getValidatedNodeType{color}(SqlNode node) (see https://github.com/apache/calcite/blob/59b76701d9c805f51b0929577ca604fdbfe00b0b/core/src/main/java/org/apache/calcite/sql/validate/SqlValidatorImpl.java#L1555) throws Util.needToImplement(node), which is the following:

{code:java}
public static RuntimeException needToImplement(Object o) {
    String description = null;
    if (o != null) {
      description = o.getClass().toString() + ": " + o.toString();
    }
    throw new UnsupportedOperationException(description);
}
{code}
Javadoc for the method dictates that the method 'Returns [in a sense of "throws"] a RuntimeException indicating that a particular feature has not been implemented, but should be.'. As not every unknown type should be implemented, call to this method should be replaced with throwing of an RuntimeException (UnsupportedOperationException, perhaps) containing a more helpful message, something like 'Unknown type: [node.toString()]'.


> UnsupportedOperationException with unclear message is shown when SqlNode with unknown type is validated
> -------------------------------------------------------------------------------------------------------
>
>                 Key: CALCITE-2627
>                 URL: https://issues.apache.org/jira/browse/CALCITE-2627
>             Project: Calcite
>          Issue Type: Improvement
>            Reporter: Bohdan Kazydub
>            Assignee: Julian Hyde
>            Priority: Major
>
> If RelDataType for SqlNode is unknown then SqlValidatorImpl#{color:#ffc66d}getValidatedNodeType{color}(SqlNode node) (see https://github.com/apache/calcite/blob/59b76701d9c805f51b0929577ca604fdbfe00b0b/core/src/main/java/org/apache/calcite/sql/validate/SqlValidatorImpl.java#L1555) throws Util.needToImplement(node), which is the following:
> {code:java}
> public static RuntimeException needToImplement(Object o) {
>     String description = null;
>     if (o != null) {
>       description = o.getClass().toString() + ": " + o.toString();
>     }
>     throw new UnsupportedOperationException(description);
> }
> {code}
> Javadoc for the method dictates that the method 'Returns [in a sense of "throws"] a RuntimeException indicating that a particular feature has not been implemented, but should be.'. As not every unknown type should be implemented, call to this method should be replaced with throwing of an RuntimeException (UnsupportedOperationException, perhaps) containing a more helpful message, something like 'Unknown type: [node.toString()]'.
> For example, currently there is following error:
> {code}
> 0: jdbc:calcite:model=target/test-classes/mod> select cast('' as sometype) from (values(1));
> Error: Error while executing SQL "select cast('' as sometype) from (values(1))": class org.apache.calcite.sql.SqlIdentifier: SOMETYPE (state=,code=0)
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)