miomiocat commented on code in PR #1514:
URL: https://github.com/apache/paimon-rust/pull/1514#discussion_r4679308901


##########
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:
   Fixed in 2a42ad44. The legacy ORC reader now strips Java’s `GMT` prefix from 
signed offsets before asking Arrow to parse them. The ORC read regression 
writes a UTC timestamp and a null, then reads the same file with `GMT+05:30`, 
`GMT-03:30`, and `+05:30` and checks the timestamp in each case. `cargo check 
--locked -p paimon --tests` passed. Thank you for the reproducer.



-- 
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]

Reply via email to