pitrou commented on code in PR #14266:
URL: https://github.com/apache/arrow/pull/14266#discussion_r1005878920
##########
cpp/src/arrow/flight/sql/server_test.cc:
##########
@@ -502,51 +489,53 @@ TEST_F(TestFlightSqlServer,
TestCommandPreparedStatementQueryWithParameterBindin
auto prepared_statement,
sql_client->Prepare({}, "SELECT * FROM intTable WHERE keyName LIKE ?"));
- auto parameter_schema = prepared_statement->parameter_schema();
-
+ const std::shared_ptr<Schema>& parameter_schema =
+ prepared_statement->parameter_schema();
const std::shared_ptr<Schema>& expected_parameter_schema =
arrow::schema({arrow::field("parameter_1",
example::GetUnknownColumnDataType())});
+ ASSERT_NO_FATAL_FAILURE(AssertSchemaEqual(expected_parameter_schema,
parameter_schema));
- AssertSchemaEqual(expected_parameter_schema, parameter_schema);
-
- std::shared_ptr<Array> type_ids = ArrayFromJSON(int8(), R"([0])");
- std::shared_ptr<Array> offsets = ArrayFromJSON(int32(), R"([0])");
- std::shared_ptr<Array> string_array = ArrayFromJSON(utf8(), R"(["%one"])");
- std::shared_ptr<Array> bytes_array = ArrayFromJSON(binary(), R"([])");
- std::shared_ptr<Array> bigint_array = ArrayFromJSON(int64(), R"([])");
- std::shared_ptr<Array> double_array = ArrayFromJSON(float64(), R"([])");
-
- ASSERT_OK_AND_ASSIGN(
- auto parameter_1_array,
- DenseUnionArray::Make(*type_ids, *offsets,
- {string_array, bytes_array, bigint_array,
double_array},
- {"string", "bytes", "bigint", "double"}, {0, 1, 2,
3}));
-
- const std::shared_ptr<RecordBatch>& record_batch =
- RecordBatch::Make(parameter_schema, 1, {parameter_1_array});
-
- ASSERT_OK(prepared_statement->SetParameters(record_batch));
+ auto record_batch = RecordBatchFromJSON(parameter_schema, R"([ [[0, "%one"]]
])");
+ ASSERT_OK(prepared_statement->SetParameters(std::move(record_batch)));
ASSERT_OK_AND_ASSIGN(auto flight_info, prepared_statement->Execute());
-
ASSERT_OK_AND_ASSIGN(auto stream,
sql_client->DoGet({},
flight_info->endpoints()[0].ticket));
-
ASSERT_OK_AND_ASSIGN(auto table, stream->ToTable());
const std::shared_ptr<Schema>& expected_schema =
arrow::schema({arrow::field("id", int64()), arrow::field("keyName",
utf8()),
arrow::field("value", int64()), arrow::field("foreignId",
int64())});
- const auto id_array = ArrayFromJSON(int64(), R"([1, 3])");
- const auto keyname_array = ArrayFromJSON(utf8(), R"(["one", "negative
one"])");
- const auto value_array = ArrayFromJSON(int64(), R"([1, -1])");
- const auto foreignId_array = ArrayFromJSON(int64(), R"([1, 1])");
-
- const std::shared_ptr<Table>& expected_table = Table::Make(
- expected_schema, {id_array, keyname_array, value_array,
foreignId_array});
-
- AssertTablesEqual(*expected_table, *table);
+ auto expected_table = TableFromJSON(expected_schema, {R"([
+ [1, "one", 1, 1],
+ [3, "negative one", -1, 1]
+ ])"});
+ ASSERT_NO_FATAL_FAILURE(AssertTablesEqual(*expected_table, *table,
/*verbose=*/true));
+
+ // Set multiple parameters at once
+ record_batch =
+ RecordBatchFromJSON(parameter_schema, R"([ [[0, "%one"]], [[0, "%zero"]]
])");
+ ASSERT_OK(prepared_statement->SetParameters(std::move(record_batch)));
+ ASSERT_OK_AND_ASSIGN(flight_info, prepared_statement->Execute());
+ ASSERT_OK_AND_ASSIGN(stream, sql_client->DoGet({},
flight_info->endpoints()[0].ticket));
+ ASSERT_OK_AND_ASSIGN(table, stream->ToTable());
+ expected_table = TableFromJSON(expected_schema, {R"([
+ [1, "one", 1, 1],
+ [3, "negative one", -1, 1],
+ [2, "zero", 0, 1]
Review Comment:
Not really, since it would switch to an actual resolved builder at the first
non-null value encountered.
--
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]