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

Fix cast exception when having time point literal as parameters

    XMLWordPrintableJSON

    Details

      Description

      I defined as ScalarFunction as follow:

       

      public class DateFunc extends ScalarFunction {
      
      
          public String eval(Date date) {
            return date.toString();
          }
      
          @Override
          public TypeInformation<?> getResultType(Class<?>[] signature) {
              return Types.STRING;
          }
      
         @Override
         public TypeInformation<?>[] getParameterTypes(Class<?>[] signature) {
            return new TypeInformation[]{Types.INT};
         }
      }
      

      I ues it in sql: `select func(DATE '2020-11-12') as a from source` , Flink throws 'cannot cast 2020-11-12 as class java.time.LocalDate '

       

      The full code is in the Flinktest.zip Main class is com.lorinda.template.TestDateFunction

        Attachments

        1. Flinktest.zip
          59 kB
          Matrix42

          Issue Links

            Activity

              People

              • Assignee:
                jark Jark Wu
                Reporter:
                Matrix42 Matrix42
              • Votes:
                0 Vote for this issue
                Watchers:
                6 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 - 20m
                  20m