Copilot commented on code in PR #48205:
URL: https://github.com/apache/arrow/pull/48205#discussion_r3352081846


##########
cpp/src/parquet/column_writer.h:
##########
@@ -267,9 +267,14 @@ inline void ArrowTimestampToImpalaTimestamp(const int64_t 
time, Int96* impala_ti
   }
   impala_timestamp->value[2] = static_cast<uint32_t>(julian_days);
   uint64_t last_day_nanos = static_cast<uint64_t>(last_day_units) * 
NanosecondsPerUnit;
+#if ARROW_LITTLE_ENDIAN
   // impala_timestamp will be unaligned every other entry so do memcpy instead
   // of assign and reinterpret cast to avoid undefined behavior.
-  std::memcpy(impala_timestamp, &last_day_nanos, sizeof(uint64_t));
+  std::memcpy(impala_timestamp, &last_day_nanos, sizeof(int64_t));
+#else
+  (*impala_timestamp).value[0] = static_cast<uint32_t>(last_day_nanos);
+  (*impala_timestamp).value[1] = static_cast<uint32_t>(last_day_nanos >> 32);

Review Comment:
   On big-endian platforms, storing `last_day_nanos` as `{low32, high32}` makes 
the in-memory `Int96` layout inconsistent with Parquet's existing decode 
helpers (e.g. `DecodeInt96Timestamp` / `Int96GetNanoSeconds` in 
`parquet/types.h` memcpy the first 8 bytes into a native-endian `uint64_t`). 
With the current ordering, `Int96GetNanoSeconds()` will reconstruct 
`(low<<32)|high` on big-endian and return the wrong timestamp. If the goal is 
to avoid unaligned 64-bit stores, you can still preserve the existing layout by 
writing the high word first on big-endian.



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