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

Constant expression with nested casts causes a compiler crash

VotersWatch issueWatchersLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    Description

      This program fails at compilation time:

      SELECT CAST(CAST('32767.4' AS FLOAT) AS SMALLINT)
      

      This happens in linq4j in Expressions.constant:

      if ((clazz != Float.class && clazz != Double.class || !(value instanceof BigDecimal)) && !clazz.isInstance(value)) {
                      String stringValue = String.valueOf(value);
                      if (type == BigDecimal.class) {
                          value = new BigDecimal(stringValue);
                      }
      
                      if (type == BigInteger.class) {
                          value = new BigInteger(stringValue);
                      }
      
                      if (primitive != null) {
                          value = primitive.parse(stringValue);  // << error happens here
                      }
                  }
      

      Attachments

        Issue Links

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            Unassigned Unassigned
            mbudiu Mihai Budiu
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment