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

[NSE-576] Support from_unixtime expression in the case that 'yyyyMMdd' format is required #614

Merged
merged 3 commits into from
Dec 13, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ object ColumnarDateTimeExpressions {
right match {
case literal: ColumnarLiteral =>
val format = literal.value.toString
if (format.length != 10) {
if (!format.equals("yyyy-MM-dd") && !format.equals("yyyyMMdd")) {
throw new UnsupportedOperationException(
s"$format is not supported in ColumnarFromUnixTime.")
}
Expand All @@ -534,9 +534,19 @@ object ColumnarDateTimeExpressions {
throw new UnsupportedOperationException(
s"${left.dataType} is not supported in ColumnarFromUnixTime.")
}
var formatLength = 0L
right match {
case literal: ColumnarLiteral =>
val format = literal.value.toString
if (format.equals("yyyy-MM-dd")) {
formatLength = 10L
} else if (format.equals("yyyyMMdd")) {
formatLength = 8L
}
}
val dateNode = TreeBuilder.makeFunction(
"castVARCHAR", Lists.newArrayList(date32LeftNode, TreeBuilder.makeLiteral(java.lang.Long.valueOf(10L))), outType)

"castVARCHAR", Lists.newArrayList(date32LeftNode,
TreeBuilder.makeLiteral(java.lang.Long.valueOf(formatLength))), outType)
(dateNode, outType)
}
}
Expand Down