Uploaded image for project: 'Beam'
  1. Beam
  2. BEAM-12473

ClassCastException when using registerUdaf in Calcite SQL

Details

    • Bug
    • Status: Resolved
    • P2
    • Resolution: Fixed
    • 2.31.0
    • 2.32.0
    • dsl-sql
    • None

    Description

      When using registerUdaf as follows:

                      .registerUdaf(
                          "LONGEST_WORD",
                          Max.of(
                              (Comparator<String> & Serializable)
                                  (String a, String b) -> Integer.compare(a.length(), b.length()))))
      

      results in following exception:

      Caused by: java.lang.ClassCastException: class sun.reflect.generics.reflectiveObjects.TypeVariableImpl cannot be cast to class java.lang.Class (sun.reflect.generics.reflectiveObjects.TypeVariableImpl and java.lang.Class are in module java.base of loader 'bootstrap')
      	at org.apache.beam.sdk.extensions.sql.impl.utils.CalciteUtils.sqlTypeWithAutoCast(CalciteUtils.java:327)
      	at org.apache.beam.sdk.extensions.sql.impl.UdafImpl$1.getType(UdafImpl.java:73)
      	at org.apache.beam.vendor.calcite.v1_20_0.org.apache.calcite.prepare.CalciteCatalogReader.toOp(CalciteCatalogReader.java:315)
      	at org.apache.beam.vendor.calcite.v1_20_0.org.apache.calcite.prepare.CalciteCatalogReader.toOp(CalciteCatalogReader.java:302)
      	at org.apache.beam.vendor.calcite.v1_20_0.org.apache.calcite.prepare.CalciteCatalogReader.lambda$lookupOperatorOverloads$3(CalciteCatalogReader.java:271)
      	at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
      	at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:177)
      
      

      If this way of registering UDAF is not supported, it should throw a more user-friendly exception.

      Attachments

        Issue Links

          Activity

            People

              janl Jan Lukavský
              janl Jan Lukavský
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 1h 40m
                  1h 40m