lidavidm commented on code in PR #870:
URL: https://github.com/apache/arrow-adbc/pull/870#discussion_r1254803029
##########
c/driver/postgresql/statement.h:
##########
@@ -30,6 +30,9 @@
#include "postgres_copy_reader.h"
#include "postgres_type.h"
+#define ADBC_POSTGRESQL_OPTION_BATCH_SIZE_HINT_BYTES \
+ "adbc.postgresql.batch_size_hint_bytes"
Review Comment:
We should add this to the constants in the Python bindings (though we can
split out a task for that)
##########
c/driver/postgresql/statement.cc:
##########
@@ -937,6 +1003,14 @@ AdbcStatusCode PostgresStatement::SetOption(const char*
key, const char* value,
SetError(error, "%s%s%s%s", "[libpq] Invalid value ", value, " for
option ", key);
return ADBC_STATUS_INVALID_ARGUMENT;
}
+ } else if (std::strcmp(value, ADBC_POSTGRESQL_OPTION_BATCH_SIZE_HINT_BYTES))
{
+ int64_t int_value = std::atol(value);
+ if (int_value <= 0) {
+ SetError(error, "%s%s%s%s", "[libpq] Invalid value ", value, " for
option ", key);
Review Comment:
just a nit, but shouldn't this be more like
```cpp
SetError(error, "[libpq] Invalid value '%s' for option '%s'", value, key);
```
?
##########
c/driver/postgresql/postgresql_test.cc:
##########
@@ -638,6 +638,48 @@ TEST_F(PostgresStatementTest, UpdateInExecuteQuery) {
}
}
+TEST_F(PostgresStatementTest, BatchSizeHint) {
+ ASSERT_THAT(quirks()->EnsureSampleTable(&connection, "batch_size_hint_test",
&error),
+ IsOkStatus(&error));
+ ASSERT_THAT(AdbcStatementNew(&connection, &statement, &error),
IsOkStatus(&error));
+
+ ASSERT_EQ(AdbcStatementSetOption(&statement,
"adbc.postgresql.batch_size_hint_bytes",
+ "-1", nullptr),
+ ADBC_STATUS_INVALID_ARGUMENT);
+ ASSERT_EQ(AdbcStatementSetOption(&statement,
"adbc.postgresql.batch_size_hint_bytes",
+ "not a valid number", nullptr),
+ ADBC_STATUS_INVALID_ARGUMENT);
+
+ ASSERT_THAT(AdbcStatementSetOption(&statement,
"adbc.postgresql.batch_size_hint_bytes",
+ "1", &error),
Review Comment:
so because 1 byte < sizeof(int64), this also tests the case where the limit
is less than the size of a single row?
--
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]