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

On using UDF, seeing java.lang.AssertionError: ANY

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 1.31.0
    • None
    • core, extensions
    • None

    Description

      I'm using Apache Beam and Calcite and have a UDF such as:

      public static String eval(@Parameter(name = "obj") Object obj,
                                @Parameter(name = "isSigned", optional = true) Boolean isSigned) {
        String hex = null;
        if (obj instanceof Float) {
          hex = Float.toHexString((Float) obj);
        } else if (obj instanceof Double) {
          hex = Double.toHexString((Double) obj);
        }
        
        return hex;
      } 

       

      In Calcite 1.20, the above code works totally fine.

      After the calcite upgrade to 1.31, we are coming across the error:

      java.lang.AssertionError: ANY        at org.apache.beam.vendor.calcite.v1_31_0.org.apache.calcite.sql.type.SqlTypeExplicitPrecedenceList.compareTypePrecedence(SqlTypeExplicitPrecedenceList.java:141) 

       

      Observation:

      It seems like "Object" is not being recognized as the new calcite version has strict type requirements.

      This change has been introduced as part of the https://issues.apache.org/jira/browse/CALCITE-2082

      cc: julianhyde 

       

      The main change impacting us is in SqlFunction.java:

      Calcite 1.20 code:

      SqlFunction function = (SqlFunction)SqlUtil.lookupRoutine(validator.getOperatorTable(), this.getNameAsId(), argTypes, argNames, this.getFunctionType(), SqlSyntax.FUNCTION, this.getKind(), validator.getCatalogReader().nameMatcher()); 

      Calcite 1.31 code:

      Object function = (SqlFunction)SqlUtil.lookupRoutine(validator.getOperatorTable(), validator.getTypeFactory(), this.getNameAsId(), argTypes, argNames, this.getFunctionType(), SqlSyntax.FUNCTION, this.getKind(), validator.getCatalogReader().nameMatcher(), false); 

       

      Any idea what can be done to fix this?

      Attachments

        Activity

          People

            Unassigned Unassigned
            rishk1111 Rish K
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated: