WillAyd commented on code in PR #908:
URL: https://github.com/apache/arrow-adbc/pull/908#discussion_r1265606547
##########
c/driver/postgresql/postgres_copy_reader.h:
##########
@@ -212,7 +212,35 @@ class PostgresCopyNetworkEndianFieldReader : public
PostgresCopyFieldReader {
}
};
-// Converts COPY resulting from the Postgres NUMERIC type into a string.
+// Reader for Intervals
+class PostgresCopyIntervalFieldReader : public PostgresCopyFieldReader {
+ public:
+ ArrowErrorCode Read(ArrowBufferView* data, int32_t field_size_bytes,
ArrowArray* array,
+ ArrowError* error) override {
+ if (field_size_bytes <= 0) {
+ return ArrowArrayAppendNull(array, 1);
+ }
+
+ if (field_size_bytes != 128) {
+ ArrowErrorSet(error, "Expected field with %d bytes but found field with
%d bytes",
+ 128,
+ static_cast<int>(field_size_bytes)); //
NOLINT(runtime/int)
+ return EINVAL;
+ }
+
+ // postgres stores time as usec, arrow stores as ns
+ const int64_t time = ReadUnsafe<int64_t>(data) * 1000;
+ const int32_t days = ReadUnsafe<int32_t>(data);
+ const int32_t months = ReadUnsafe<int32_t>(data);
+
+ NANOARROW_RETURN_NOT_OK(ArrowBufferAppend(data_, &days, sizeof(int32_t)));
+ NANOARROW_RETURN_NOT_OK(ArrowBufferAppend(data_, &months,
sizeof(int32_t)));
Review Comment:
Cool thanks for the reference. Is what I linked a bug in arrow?
--
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]