[ https://issues.apache.org/jira/browse/FLINK-11935?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16816445#comment-16816445 ]
Rong Rong commented on FLINK-11935: ----------------------------------- I think [~julianhyde] is correct. actually I ran the test again and seems like the ymdToJulian returns the correct epoch: {{-30044998861002L}} which converts to {{Saturday, November 29, 1017 10:58:58.998 PM}} according to https://www.epochconverter.com/. However, the current {{DateTimeUtils}} in flink-table-planner codebase returns a wrong epoch: {{-30044480461002}}. Thus I think something is not right when converting the epoch back to string representation. Please see my test code in this commit: https://github.com/walterddr/flink/commit/61bc3d96f4f7fbfe70cef637bdc261f0855c2011 It need not be the tests problem, might've been part of the settings in Flink's datetime where it is suppose to use Julian but somehow mixed with Gregorian. I am pretty blank in terms of this knowledge domain, so some of the observation might've been off, any additional thoughts or comments [~julianhyde]? > Remove DateTimeUtils pull-in and fix datetime casting problem > ------------------------------------------------------------- > > Key: FLINK-11935 > URL: https://issues.apache.org/jira/browse/FLINK-11935 > Project: Flink > Issue Type: Sub-task > Components: Table SQL / API > Reporter: Rong Rong > Assignee: vinoyang > Priority: Major > > This {{DateTimeUtils}} was pulled in in FLINK-7235. > Originally the time operation was not correctly done via the {{ymdToJulian}} > function before the date {{1970-01-01}} thus we need the fix. similar to > addressing this problem: > {code:java} > Optimized :1017-12-05 22:58:58.998 > Expected :1017-11-29 22:58:58.998 > Actual :1017-12-05 22:58:58.998 > {code} > > However, after pulling in avatica 1.13, I found out that the optimized plans > of the time operations are actually correct. it is in fact the casting part > that creates problem: > For example, the following: > *{{(plus(-12000.months, cast('2017-11-29 22:58:58.998', TIMESTAMP))}}* > result in a StringTestExpression of: > *{{CAST(1017-11-29 22:58:58.998):VARCHAR(65536) CHARACTER SET "UTF-16LE" > COLLATE "ISO-8859-1$en_US$primary" NOT NULL}}* > but the testing results are: > {code:java} > Optimized :1017-11-29 22:58:58.998 > Expected :1017-11-29 22:58:58.998 > Actual :1017-11-23 22:58:58.998 > {code} > -- This message was sent by Atlassian JIRA (v7.6.3#76005)