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

Commit

Permalink
[NSE-576] Support from_unixtime expression in the case that 'yyyyMMdd…
Browse files Browse the repository at this point in the history
…' format is required (#614)

* Support date format with no hyphen

* Change arrow branch for test [revert this commit at last]

* Revert "Change arrow branch for test [revert this commit at last]"

This reverts commit f0486cb.
  • Loading branch information
PHILO-HE authored Dec 13, 2021
1 parent cc0035c commit 604d17b
Showing 1 changed file with 13 additions and 3 deletions.
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

0 comments on commit 604d17b

Please sign in to comment.