andygrove commented on code in PR #3536:
URL: https://github.com/apache/datafusion-comet/pull/3536#discussion_r2819302829
##########
native/spark-expr/src/utils.rs:
##########
@@ -71,6 +72,49 @@ pub fn array_with_timezone(
to_type: Option<&DataType>,
) -> Result<ArrayRef, ArrowError> {
match array.data_type() {
+ DataType::Timestamp(TimeUnit::Millisecond, None) => {
+ assert!(!timezone.is_empty());
+ match to_type {
+ Some(DataType::Utf8) | Some(DataType::Date32) => Ok(array),
+ Some(DataType::Timestamp(_, Some(_))) => {
+ timestamp_ntz_to_timestamp(array, timezone.as_str(),
Some(timezone.as_str()))
+ }
+ Some(DataType::Timestamp(TimeUnit::Microsecond, None)) => {
+ // Convert from Timestamp(Millisecond, None) to
Timestamp(Microsecond, None)
+ let millis_array =
as_primitive_array::<TimestampMillisecondType>(&array);
+ let micros_array: TimestampMicrosecondArray = millis_array
+ .iter()
+ .map(|opt| opt.map(|v| v * 1000))
+ .collect();
+ Ok(Arc::new(micros_array))
+ }
+ _ => {
+ // Not supported
+ panic!(
Review Comment:
We should return an Err here
##########
native/spark-expr/src/utils.rs:
##########
@@ -71,6 +72,49 @@ pub fn array_with_timezone(
to_type: Option<&DataType>,
) -> Result<ArrayRef, ArrowError> {
match array.data_type() {
+ DataType::Timestamp(TimeUnit::Millisecond, None) => {
+ assert!(!timezone.is_empty());
+ match to_type {
+ Some(DataType::Utf8) | Some(DataType::Date32) => Ok(array),
+ Some(DataType::Timestamp(_, Some(_))) => {
+ timestamp_ntz_to_timestamp(array, timezone.as_str(),
Some(timezone.as_str()))
+ }
+ Some(DataType::Timestamp(TimeUnit::Microsecond, None)) => {
+ // Convert from Timestamp(Millisecond, None) to
Timestamp(Microsecond, None)
+ let millis_array =
as_primitive_array::<TimestampMillisecondType>(&array);
+ let micros_array: TimestampMicrosecondArray = millis_array
+ .iter()
+ .map(|opt| opt.map(|v| v * 1000))
+ .collect();
+ Ok(Arc::new(micros_array))
+ }
+ _ => {
+ // Not supported
+ panic!(
+ "Cannot convert from {:?} to {:?}",
+ array.data_type(),
+ to_type.unwrap()
+ )
+ }
+ }
+ }
+ DataType::Timestamp(TimeUnit::Microsecond, None) => {
+ assert!(!timezone.is_empty());
+ match to_type {
+ Some(DataType::Utf8) | Some(DataType::Date32) => Ok(array),
+ Some(DataType::Timestamp(_, Some(_))) => {
+ timestamp_ntz_to_timestamp(array, timezone.as_str(),
Some(timezone.as_str()))
+ }
+ _ => {
+ // Not supported
+ panic!(
Review Comment:
We should return an Err here
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]