lidavidm commented on code in PR #861:
URL: https://github.com/apache/arrow-adbc/pull/861#discussion_r1246744462


##########
c/validation/adbc_validation.cc:
##########
@@ -1094,6 +1094,83 @@ void StatementTest::TestSqlIngestBinary() {
       NANOARROW_TYPE_BINARY, {std::nullopt, "", "\x00\x01\x02\x04", 
"\xFE\xFF"}));
 }
 
+template <enum ArrowTimeUnit TU>

Review Comment:
   I need to fix things here, but it should be quite straightforward to also 
write a matcher like `IsError(&error, ::testing::HasSubstr("..."))`



##########
c/driver/postgresql/statement.cc:
##########
@@ -337,6 +347,53 @@ struct BindStream {
               param_values[col] = const_cast<char*>(view.data.as_char);
               break;
             }
+            case ArrowType::NANOARROW_TYPE_TIMESTAMP: {
+              int64_t val = 
array_view->children[col]->buffer_views[1].data.as_int64[row];
+              if (strcmp("", bind_schema_fields[col].timezone)) {
+                SetError(error, "%s%" PRIi64 "%s%s%s", "[libpq] Column #", col 
+ 1,
+                         " (\"", PQfname(result, col),
+                         "\") has unsupported type code timestamp with 
timezone");
+                return ADBC_STATUS_NOT_IMPLEMENTED;
+              }
+
+              // 2000-01-01 00:00:00.000000 in microseconds
+              constexpr int64_t kPostgresTimestampEpoch = 946684800000000;
+              constexpr int64_t kSecOverflowLimit = 9223372036854;
+              constexpr int64_t kmSecOverflowLimit = 9223372036854775;
+
+              auto unit = bind_schema_fields[col].time_unit;
+              switch (unit) {
+                case NANOARROW_TIME_UNIT_SECOND:
+                  if (abs(val) > kSecOverflowLimit) {
+                    SetError(error, "%s%" PRId64 "%s%s%s%" PRId64 "%s", 
"[libpq] Field #",

Review Comment:
   FWIW, why not have the format string be `"[libpq] Field #" PRId64 ...`?



##########
c/validation/adbc_validation.cc:
##########
@@ -1094,6 +1094,83 @@ void StatementTest::TestSqlIngestBinary() {
       NANOARROW_TYPE_BINARY, {std::nullopt, "", "\x00\x01\x02\x04", 
"\xFE\xFF"}));
 }
 
+template <enum ArrowTimeUnit TU>

Review Comment:
   It might be easiest to have the signature be `AdbcStatusCode 
TestSqlIngestTemporalType(..., struct AdbcError* error)` and then you can use 
the usual `ASSERT_THAT(..., IsOkStatus(&error))` 



##########
c/validation/adbc_validation.cc:
##########
@@ -1094,6 +1094,83 @@ void StatementTest::TestSqlIngestBinary() {
       NANOARROW_TYPE_BINARY, {std::nullopt, "", "\x00\x01\x02\x04", 
"\xFE\xFF"}));
 }
 
+template <enum ArrowTimeUnit TU>

Review Comment:
   This seems reasonable as is though



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