Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Treat legacy TIMSETAMP_X converted types as UTC #4309

Merged
Merged
Show file tree
Hide file tree
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
24 changes: 19 additions & 5 deletions parquet/src/arrow/array_reader/primitive_array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,15 @@ mod tests {
}

macro_rules! test_primitive_array_reader_one_type {
($arrow_parquet_type:ty, $physical_type:expr, $converted_type_str:expr, $result_arrow_type:ty, $result_arrow_cast_type:ty, $result_primitive_type:ty) => {{
(
$arrow_parquet_type:ty,
$physical_type:expr,
$converted_type_str:expr,
$result_arrow_type:ty,
$result_arrow_cast_type:ty,
$result_primitive_type:ty
$(, $timezone:expr)?
) => {{
let message_type = format!(
"
message test_schema {{
Expand Down Expand Up @@ -493,7 +501,9 @@ mod tests {
result_data_type
)
.as_str(),
);
)
$(.with_timezone($timezone))?
;

// create expected array as primitive, and cast to result type
let expected = PrimitiveArray::<$result_arrow_cast_type>::from(
Expand All @@ -516,7 +526,9 @@ mod tests {
result_data_type
)
.as_str(),
);
)
$(.with_timezone($timezone))?
;
assert_eq!(expected, array);
}
}};
Expand Down Expand Up @@ -554,15 +566,17 @@ mod tests {
"TIMESTAMP_MILLIS",
arrow::datatypes::TimestampMillisecondType,
arrow::datatypes::Int64Type,
i64
i64,
"UTC"
);
test_primitive_array_reader_one_type!(
crate::data_type::Int64Type,
PhysicalType::INT64,
"TIMESTAMP_MICROS",
arrow::datatypes::TimestampMicrosecondType,
arrow::datatypes::Int64Type,
i64
i64,
"UTC"
);
}

Expand Down
4 changes: 2 additions & 2 deletions parquet/src/arrow/schema/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1278,12 +1278,12 @@ mod tests {
Field::new("time_nano", DataType::Time64(TimeUnit::Nanosecond), true),
Field::new(
"ts_milli",
DataType::Timestamp(TimeUnit::Millisecond, None),
DataType::Timestamp(TimeUnit::Millisecond, Some("UTC".into())),
true,
),
Field::new(
"ts_micro",
DataType::Timestamp(TimeUnit::Microsecond, None),
DataType::Timestamp(TimeUnit::Microsecond, Some("UTC".into())),
false,
),
Field::new(
Expand Down
14 changes: 8 additions & 6 deletions parquet/src/arrow/schema/primitive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,12 +218,14 @@ fn from_int64(info: &BasicTypeInfo, scale: i32, precision: i32) -> Result<DataTy
(None, ConvertedType::INT_64) => Ok(DataType::Int64),
(None, ConvertedType::UINT_64) => Ok(DataType::UInt64),
(None, ConvertedType::TIME_MICROS) => Ok(DataType::Time64(TimeUnit::Microsecond)),
(None, ConvertedType::TIMESTAMP_MILLIS) => {
Ok(DataType::Timestamp(TimeUnit::Millisecond, None))
}
(None, ConvertedType::TIMESTAMP_MICROS) => {
Ok(DataType::Timestamp(TimeUnit::Microsecond, None))
}
(None, ConvertedType::TIMESTAMP_MILLIS) => Ok(DataType::Timestamp(
TimeUnit::Millisecond,
Some("UTC".into()),
)),
(None, ConvertedType::TIMESTAMP_MICROS) => Ok(DataType::Timestamp(
TimeUnit::Microsecond,
Some("UTC".into()),
)),
(Some(LogicalType::Decimal { scale, precision }), _) => {
decimal_128_type(scale, precision)
}
Expand Down