-
Notifications
You must be signed in to change notification settings - Fork 75
[NSE-234]Support the to_date() with format function in Date and String Type #235
Conversation
class ColumnarUnixTimestamp(timeExp: Expression, format: Expression, original: UnixTimestamp) | ||
extends UnixTimestamp(timeExp, format, original.timeZoneId) | ||
with ColumnarExpression | ||
with Logging { |
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.
What types does this operator support? Could you add a buildCheck for supported types?
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.
Gazell already has ColumnarUnixTimestamp (convert to unix timestamp in sec).
@@ -504,6 +504,7 @@ object ConverterUtils extends Logging { | |||
case d: StringType => | |||
case d: DateType => | |||
case d: DecimalType => | |||
case d: TimestampType => |
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.
Will this pr depends on the previous pr?
#209
depends on: oap-project/arrow#10 |
@@ -439,7 +436,7 @@ class ColumnarCast( | |||
s"${child.dataType} is not supported in castFLOAT8") | |||
} | |||
} else if (dataType == DateType) { | |||
val supported = List(IntegerType, LongType, DateType) | |||
val supported = List(IntegerType, LongType, DateType, TimestampType) |
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.
Current code already has this changes.
@@ -450,6 +447,11 @@ class ColumnarCast( | |||
throw new UnsupportedOperationException( | |||
s"${child.dataType} is not supported in castDECIMAL") | |||
} | |||
} else if (datatype == TimestampType) { | |||
val supported = List(LongType) |
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.
Current code already has this changes.
@@ -530,9 +532,21 @@ class ColumnarCast( | |||
TreeBuilder.makeFunction("castFLOAT8", Lists.newArrayList(child_node), resultType) | |||
(funcNode, resultType) | |||
} else if (dataType == DateType) { | |||
val funcNode = | |||
val castNode = if (childType.isInstanceOf[ArrowType.Timestamp]) { |
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.
Current code already has this support.
@@ -541,6 +555,15 @@ class ColumnarCast( | |||
TreeBuilder.makeFunction("castDECIMAL", Lists.newArrayList(child_node), dType) | |||
(funcNode, dType) | |||
} | |||
} else if (dataType == TimestampType) { |
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.
Current code already has the support to cast LongType, DateType, StringType to TimeStampType.
It looks the cast should be tackled according to child type in this piece of code.
It looks the proposed functionality in this PR has already implemented in current gazelle code. And I also proposed #622 to support to_date expression. Let's close this PR. Thanks for this work! |
What changes were proposed in this pull request?
Fix #234
How was this patch tested?
DateFunctionsSuite.scala # function_to_date method