Skip to content
This repository has been archived by the owner on Sep 18, 2023. It is now read-only.

[NSE-1019] [NSE-1020] Support more date formats and be aware of local time zone in handling unix timestamp #1021

Merged
merged 11 commits into from
Jul 15, 2022

Conversation

PHILO-HE
Copy link
Collaborator

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.

@github-actions
Copy link

#1019

@PHILO-HE
Copy link
Collaborator Author

PHILO-HE commented Jul 13, 2022

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))))
Copy link
Collaborator Author

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"
Copy link
Collaborator Author

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))
Copy link
Collaborator Author

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants