JingsongLi commented on code in PR #1514:
URL: https://github.com/apache/paimon-rust/pull/1514#discussion_r4679227343
##########
crates/paimon/src/arrow/format/orc.rs:
##########
@@ -42,7 +43,115 @@ use tokio::sync::{mpsc, oneshot};
const ORC_IN_PREDICATE_MAX_LITERALS: usize = 20;
-pub(crate) struct OrcFormatReader;
+pub(crate) struct OrcFormatReader {
+ legacy_time_zone: Option<String>,
+}
+
+impl OrcFormatReader {
+ pub(crate) fn with_options(options: &HashMap<String, String>) -> Self {
+ // Java Paimon defaults to its legacy LTZ representation. The embedding
+ // engine supplies the JVM's zone, not the SQL session's display zone.
+ let legacy = options
+ .get("orc.timestamp-ltz.legacy.type")
+ .is_none_or(|value| !value.eq_ignore_ascii_case("false"));
+ Self {
+ legacy_time_zone: legacy.then(|| {
+ options
+ .get("orc.timestamp-ltz.legacy.time-zone")
+ .cloned()
+ .unwrap_or_else(|| "UTC".to_string())
+ }),
+ }
+ }
+}
+
+fn normalize_legacy_ltz(array: &ArrayRef, zone: &str) ->
crate::Result<ArrayRef> {
+ if zone == "UTC" {
+ return Ok(Arc::clone(array));
+ }
+ // Arrow casts can merely relabel timezone metadata. Legacy Java Paimon
+ // instead adds the JVM offset to the stored UTC instant's numeric value.
+ if let ArrowDataType::Timestamp(unit, Some(_)) = array.data_type() {
+ let tz: arrow_array::timezone::Tz = zone.parse().map_err(|error|
Error::DataInvalid {
Review Comment:
**[P2] Accept Java's fixed-offset GMT timezone IDs**
The option asks readers to use the Java JVM timezone. Java 17 accepts
`GMT+05:30`, returns that exact ID, and gives an offset of 19,800,000 ms. With
the same physical ORC timestamp file, Rust read the correct value for `+05:30`
but returned `Invalid legacy ORC LTZ zone GMT+05:30` for the JVM ID. Normalize
`GMT+HH:mm` and `GMT-HH:mm` to Arrow's fixed-offset spelling before parsing,
and cover a non-whole-hour offset in the ORC read test.
--
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]