Uploaded image for project: 'Flink'
  1. Flink
  2. FLINK-17683

Pojo with no-args constructor will be treated as ROW when returned by ScalarFunction, but not when it is a field of case class.

    XMLWordPrintableJSON

Details

    Description

      Pojo.java

      @Data
      @NoArgsConstructor
      public class Pojo  {
          private String foo;
      }
      
      object Fun extends ScalarFunction { 
         def eval(): Pojo = { new Pojo() } 
      }
      case class CaseClass(pojo:Pojo)
      

       

       

      tableEnv.registerFunction("fun", Fun)
      val table = tableEnv.sqlQuery("select fun() as pojo")
      table.toRetractStream[CaseClass].print()
      

       

      exception:

       

      Exception in thread "main" org.apache.flink.table.api.ValidationException: Field types of query result and registered TableSink  do not match.
      Query schema: [pojo: ROW<`foo` STRING>]
      Sink schema: [pojo: LEGACY('STRUCTURED_TYPE', 'POJO<com.yunmo.iot.Pojo>')]
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            xiemeilong xiemeilong
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated: