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

ClassCastException when using registerUdaf in Calcite SQL

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P2
    • Resolution: Fixed
    • Affects Version/s: 2.31.0
    • Fix Version/s: 2.32.0
    • Component/s: dsl-sql
    • Labels:
      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

            • Assignee:
              janl Jan Lukavsk√Ĺ
              Reporter:
              janl Jan Lukavsk√Ĺ

              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

                  Issue deployment