-
Notifications
You must be signed in to change notification settings - Fork 75
[NSE-1019] [NSE-1020] Support more date formats and be aware of local time zone in handling unix timestamp #1021
Conversation
This patch depends on oap-project/arrow#124. We need to revert the change for arrow branch at last. |
Row(java.lang.Long.valueOf(1249084800L)))) | ||
Seq(Row(java.lang.Long.valueOf(1248940800L)), | ||
Row(java.lang.Long.valueOf(1249027200L)), | ||
Row(java.lang.Long.valueOf(1249113600L)))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The expected result has been corrected, which is verified by checking spark's result.
class ColumnarUnixTimestamp(left: Expression, right: Expression) | ||
extends UnixTimestamp(left, right) with | ||
ColumnarExpression { | ||
|
||
val yearMonthDayFormat = "yyyy-MM-dd" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After double check, castDATE_nullsafe
currently still cannot handle no separator date format, i.e., yyyyMMdd, as before. Let's enable it if there is a requirement from users.
val timestampNode = TreeBuilder.makeFunction("castTIMESTAMP", | ||
Lists.newArrayList(ConverterUtils.addTimestampOffset(tsInMilliSecNode)), timestampType) | ||
// The largest length for yyyy-MM-dd HH:mm:ss. | ||
val lenNode = TreeBuilder.makeLiteral(java.lang.Long.valueOf(19L)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The length (19) is set for the output string length. It's a fixed value for 'yyyy-MM-dd HH:mm:ss' format.
This reverts commit 11f0977.
What changes were proposed in this pull request?
Enhancement and fixing bugs.
How was this patch tested?
Query test with designed case. Some spark UTs also covers.