|
17 | 17 |
|
18 | 18 | use crate::logical_plan::producer::to_substrait_precision; |
19 | 19 | use crate::logical_plan::producer::utils::flatten_names; |
| 20 | +#[allow(deprecated)] |
| 21 | +use crate::variation_const::TIMESTAMP_NANO_TYPE_VARIATION_REF; |
20 | 22 | use crate::variation_const::{ |
21 | 23 | DATE_32_TYPE_VARIATION_REF, DATE_64_TYPE_VARIATION_REF, |
22 | 24 | DECIMAL_128_TYPE_VARIATION_REF, DECIMAL_256_TYPE_VARIATION_REF, |
@@ -109,26 +111,16 @@ pub(crate) fn to_substrait_type( |
109 | 111 | nullability, |
110 | 112 | })), |
111 | 113 | }), |
112 | | - DataType::Timestamp(unit, tz) => { |
113 | | - let precision = to_substrait_precision(unit); |
114 | | - let kind = match tz { |
115 | | - None => r#type::Kind::PrecisionTimestamp(r#type::PrecisionTimestamp { |
116 | | - type_variation_reference: DEFAULT_TYPE_VARIATION_REF, |
| 114 | + DataType::Timestamp(_unit, _) => { |
| 115 | + // TODO: DataDog-specific workaround, don't commit upstream |
| 116 | + #[allow(deprecated)] |
| 117 | + let type_variation_reference = TIMESTAMP_NANO_TYPE_VARIATION_REF; |
| 118 | + Ok(substrait::proto::Type { |
| 119 | + kind: Some(r#type::Kind::Timestamp(r#type::Timestamp { |
| 120 | + type_variation_reference, |
117 | 121 | nullability, |
118 | | - precision, |
119 | | - }), |
120 | | - Some(_) => { |
121 | | - // If timezone is present, no matter what the actual tz value is, it indicates the |
122 | | - // value of the timestamp is tied to UTC epoch. That's all that Substrait cares about. |
123 | | - // As the timezone is lost, this conversion may be lossy for downstream use of the value. |
124 | | - r#type::Kind::PrecisionTimestampTz(r#type::PrecisionTimestampTz { |
125 | | - type_variation_reference: DEFAULT_TYPE_VARIATION_REF, |
126 | | - nullability, |
127 | | - precision, |
128 | | - }) |
129 | | - } |
130 | | - }; |
131 | | - Ok(substrait::proto::Type { kind: Some(kind) }) |
| 122 | + })), |
| 123 | + }) |
132 | 124 | } |
133 | 125 | DataType::Time32(unit) => { |
134 | 126 | let precision = to_substrait_precision(unit); |
@@ -325,6 +317,8 @@ pub(crate) fn to_substrait_type( |
325 | 317 | precision: *p as i32, |
326 | 318 | })), |
327 | 319 | }), |
| 320 | + // TODO: DataDog-specific workaround, don't commit upstream |
| 321 | + DataType::Dictionary(_, dt) => to_substrait_type(dt, nullable), |
328 | 322 | _ => not_impl_err!("Unsupported cast type: {dt:?}"), |
329 | 323 | } |
330 | 324 | } |
@@ -378,12 +372,13 @@ mod tests { |
378 | 372 | round_trip_type(DataType::Float32)?; |
379 | 373 | round_trip_type(DataType::Float64)?; |
380 | 374 |
|
381 | | - for tz in [None, Some("UTC".into())] { |
382 | | - round_trip_type(DataType::Timestamp(TimeUnit::Second, tz.clone()))?; |
383 | | - round_trip_type(DataType::Timestamp(TimeUnit::Millisecond, tz.clone()))?; |
384 | | - round_trip_type(DataType::Timestamp(TimeUnit::Microsecond, tz.clone()))?; |
385 | | - round_trip_type(DataType::Timestamp(TimeUnit::Nanosecond, tz))?; |
386 | | - } |
| 375 | + // TODO: DataDog-specific workaround, don't commit upstream |
| 376 | + // for tz in [None, Some("UTC".into())] { |
| 377 | + // round_trip_type(DataType::Timestamp(TimeUnit::Second, tz.clone()))?; |
| 378 | + // round_trip_type(DataType::Timestamp(TimeUnit::Millisecond, tz.clone()))?; |
| 379 | + // round_trip_type(DataType::Timestamp(TimeUnit::Microsecond, tz.clone()))?; |
| 380 | + // round_trip_type(DataType::Timestamp(TimeUnit::Nanosecond, tz))?; |
| 381 | + // } |
387 | 382 |
|
388 | 383 | round_trip_type(DataType::Time32(TimeUnit::Second))?; |
389 | 384 | round_trip_type(DataType::Time32(TimeUnit::Millisecond))?; |
|
0 commit comments