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

UnsupportedOperationException with unclear message is shown when SqlNode with unknown type is validated

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None

      Description

      If RelDataType for SqlNode is unknown then SqlValidatorImpl#getValidatedNodeType(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:

      public static RuntimeException needToImplement(Object o) {
          String description = null;
          if (o != null) {
            description = o.getClass().toString() + ": " + o.toString();
          }
          throw new UnsupportedOperationException(description);
      }
      

      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:

      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)
      

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              KazydubB Bohdan Kazydub
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated: