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

Fix cast exception when having time point literal as parameters

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    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

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            jark Jark Wu
            Matrix42 Matrix42
            Votes:
            0 Vote for this issue
            Watchers:
            4 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

                Slack

                  Issue deployment