Skip to content
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion cpp/src/arrow/flight/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,9 @@ if(ARROW_TESTING)
STATIC_INSTALL_INTERFACE_LIBS
${ARROW_FLIGHT_TESTING_STATIC_INSTALL_INTERFACE_LIBS}
PRIVATE_INCLUDES
"${Protobuf_INCLUDE_DIRS}")
"${Protobuf_INCLUDE_DIRS}"
SHARED_PRIVATE_LINK_LIBS
GTest::gmock)

Comment on lines 293 to 297

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the fix for the 12 build errors on the local environment. Rob and I have both seen this issue before. I am not sure why it is only visible in our local environments and not seen in CI

foreach(LIB_TARGET ${ARROW_FLIGHT_TESTING_LIBRARIES})
target_compile_definitions(${LIB_TARGET} PRIVATE ARROW_FLIGHT_EXPORTING)
Expand Down
4 changes: 3 additions & 1 deletion cpp/src/arrow/flight/sql/odbc/flight_sql/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,11 @@ add_arrow_test(arrow_odbc_spi_impl_test
accessors/time_array_accessor_test.cc
accessors/timestamp_array_accessor_test.cc
flight_sql_connection_test.cc
flight_sql_stream_chunk_buffer_test.cc
parse_table_types_test.cc
json_converter_test.cc
record_batch_transformer_test.cc
utils_test.cc
EXTRA_LINK_LIBS
arrow_odbc_spi_impl)
arrow_odbc_spi_impl
arrow_flight_testing_shared)
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ class NoOpClientAuthHandler : public arrow::flight::ClientAuthHandler {

arrow::Status Authenticate(arrow::flight::ClientAuthSender* outgoing,
arrow::flight::ClientAuthReader* incoming) override {
// Write a blank string. The server should ignore this and just accept any Handshake
// Return OK Status. The server should ignore this and just accept any Handshake
// request.
return outgoing->Write(std::string());
return arrow::Status::OK();
Comment on lines +61 to +63

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After the original flightsql-odbc code has been written, Arrow API changed and now would need OK to be returned directly instead of writing strings

}

arrow::Status GetToken(std::string* token) override {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ inline std::string GetCerts() { return ""; }
#endif

const std::set<std::string_view, CaseInsensitiveComparatorStrView> BUILT_IN_PROPERTIES = {
FlightSqlConnection::DRIVER,
FlightSqlConnection::DSN,
FlightSqlConnection::HOST,
FlightSqlConnection::PORT,
FlightSqlConnection::USER,
Expand Down Expand Up @@ -165,15 +167,15 @@ void FlightSqlConnection::Connect(const ConnPropertyMap& properties,
auto flight_ssl_configs = LoadFlightSslConfigs(properties);

Location location = BuildLocation(properties, missing_attr, flight_ssl_configs);
FlightClientOptions client_options =
client_options_ =
BuildFlightClientOptions(properties, missing_attr, flight_ssl_configs);

const std::shared_ptr<arrow::flight::ClientMiddlewareFactory>& cookie_factory =
arrow::flight::GetCookieFactory();
client_options.middleware.push_back(cookie_factory);
client_options_.middleware.push_back(cookie_factory);

std::unique_ptr<FlightClient> flight_client;
ThrowIfNotOK(FlightClient::Connect(location, client_options).Value(&flight_client));
ThrowIfNotOK(FlightClient::Connect(location, client_options_).Value(&flight_client));

PopulateMetadataSettings(properties);
PopulateCallOptions(properties);
Expand Down Expand Up @@ -377,7 +379,7 @@ void FlightSqlConnection::Close() {

std::shared_ptr<Statement> FlightSqlConnection::CreateStatement() {
return std::shared_ptr<Statement>(new FlightSqlStatement(
diagnostics_, *sql_client_, call_options_, metadata_settings_));
diagnostics_, *sql_client_, client_options_, call_options_, metadata_settings_));
}

bool FlightSqlConnection::SetAttribute(Connection::AttributeId attribute,
Expand Down Expand Up @@ -423,7 +425,7 @@ FlightSqlConnection::FlightSqlConnection(OdbcVersion odbc_version,
const std::string& driver_version)
: diagnostics_("Apache Arrow", "Flight SQL", odbc_version),
odbc_version_(odbc_version),
info_(call_options_, sql_client_, driver_version),
info_(client_options_, call_options_, sql_client_, driver_version),
closed_(true) {
attribute_[CONNECTION_DEAD] = static_cast<uint32_t>(SQL_TRUE);
attribute_[LOGIN_TIMEOUT] = static_cast<uint32_t>(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,14 @@ using odbcabstraction::DriverException;

FlightSqlResultSet::FlightSqlResultSet(
FlightSqlClient& flight_sql_client,
const arrow::flight::FlightClientOptions& client_options,
const arrow::flight::FlightCallOptions& call_options,
const std::shared_ptr<FlightInfo>& flight_info,
const std::shared_ptr<RecordBatchTransformer>& transformer,
odbcabstraction::Diagnostics& diagnostics,
const odbcabstraction::MetadataSettings& metadata_settings)
: metadata_settings_(metadata_settings),
chunk_buffer_(flight_sql_client, call_options, flight_info,
chunk_buffer_(flight_sql_client, client_options, call_options, flight_info,
metadata_settings_.chunk_buffer_capacity_),
transformer_(transformer),
metadata_(transformer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ class FlightSqlResultSet : public ResultSet {
~FlightSqlResultSet() override;

FlightSqlResultSet(FlightSqlClient& flight_sql_client,
const arrow::flight::FlightClientOptions& client_options,
const arrow::flight::FlightCallOptions& call_options,
const std::shared_ptr<FlightInfo>& flight_info,
const std::shared_ptr<RecordBatchTransformer>& transformer,
Expand Down
55 changes: 29 additions & 26 deletions cpp/src/arrow/flight/sql/odbc/flight_sql/flight_sql_statement.cc
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,12 @@ void ClosePreparedStatementIfAny(

FlightSqlStatement::FlightSqlStatement(
const odbcabstraction::Diagnostics& diagnostics, FlightSqlClient& sql_client,
FlightCallOptions call_options,
arrow::flight::FlightClientOptions client_options, FlightCallOptions call_options,
const odbcabstraction::MetadataSettings& metadata_settings)
: diagnostics_("Apache Arrow", diagnostics.GetDataSourceComponent(),
diagnostics.GetOdbcVersion()),
sql_client_(sql_client),
client_options_(std::move(client_options)),
call_options_(std::move(call_options)),
metadata_settings_(metadata_settings) {
attribute_[METADATA_ID] = static_cast<size_t>(SQL_FALSE);
Expand Down Expand Up @@ -135,8 +136,8 @@ bool FlightSqlStatement::ExecutePrepared() {
ThrowIfNotOK(result.status());

current_result_set_ = std::make_shared<FlightSqlResultSet>(
sql_client_, call_options_, result.ValueOrDie(), nullptr, diagnostics_,
metadata_settings_);
sql_client_, client_options_, call_options_, result.ValueOrDie(), nullptr,
diagnostics_, metadata_settings_);

return true;
}
Expand All @@ -148,8 +149,8 @@ bool FlightSqlStatement::Execute(const std::string& query) {
ThrowIfNotOK(result.status());

current_result_set_ = std::make_shared<FlightSqlResultSet>(
sql_client_, call_options_, result.ValueOrDie(), nullptr, diagnostics_,
metadata_settings_);
sql_client_, client_options_, call_options_, result.ValueOrDie(), nullptr,
diagnostics_, metadata_settings_);

return true;
}
Expand All @@ -170,27 +171,29 @@ std::shared_ptr<odbcabstraction::ResultSet> FlightSqlStatement::GetTables(

if ((catalog_name && *catalog_name == "%") && (schema_name && schema_name->empty()) &&
(table_name && table_name->empty())) {
current_result_set_ = GetTablesForSQLAllCatalogs(
column_names, call_options_, sql_client_, diagnostics_, metadata_settings_);
current_result_set_ =
GetTablesForSQLAllCatalogs(column_names, client_options_, call_options_,
sql_client_, diagnostics_, metadata_settings_);
} else if ((catalog_name && catalog_name->empty()) &&
(schema_name && *schema_name == "%") &&
(table_name && table_name->empty())) {
current_result_set_ =
GetTablesForSQLAllDbSchemas(column_names, call_options_, sql_client_, schema_name,
diagnostics_, metadata_settings_);
current_result_set_ = GetTablesForSQLAllDbSchemas(
column_names, client_options_, call_options_, sql_client_, schema_name,
diagnostics_, metadata_settings_);
} else if ((catalog_name && catalog_name->empty()) &&
(schema_name && schema_name->empty()) &&
(table_name && table_name->empty()) && (table_type && *table_type == "%")) {
current_result_set_ = GetTablesForSQLAllTableTypes(
column_names, call_options_, sql_client_, diagnostics_, metadata_settings_);
current_result_set_ =
GetTablesForSQLAllTableTypes(column_names, client_options_, call_options_,
sql_client_, diagnostics_, metadata_settings_);
} else {
if (table_type) {
ParseTableTypes(*table_type, table_types);
}

current_result_set_ = GetTablesForGenericUse(
column_names, call_options_, sql_client_, catalog_name, schema_name, table_name,
table_types, diagnostics_, metadata_settings_);
column_names, client_options_, call_options_, sql_client_, catalog_name,
schema_name, table_name, table_types, diagnostics_, metadata_settings_);
}

return current_result_set_;
Expand Down Expand Up @@ -228,9 +231,9 @@ std::shared_ptr<ResultSet> FlightSqlStatement::GetColumns_V2(
auto transformer = std::make_shared<GetColumns_Transformer>(
metadata_settings_, odbcabstraction::V_2, column_name);

current_result_set_ =
std::make_shared<FlightSqlResultSet>(sql_client_, call_options_, flight_info,
transformer, diagnostics_, metadata_settings_);
current_result_set_ = std::make_shared<FlightSqlResultSet>(
sql_client_, client_options_, call_options_, flight_info, transformer, diagnostics_,
metadata_settings_);

return current_result_set_;
}
Expand All @@ -249,9 +252,9 @@ std::shared_ptr<ResultSet> FlightSqlStatement::GetColumns_V3(
auto transformer = std::make_shared<GetColumns_Transformer>(
metadata_settings_, odbcabstraction::V_3, column_name);

current_result_set_ =
std::make_shared<FlightSqlResultSet>(sql_client_, call_options_, flight_info,
transformer, diagnostics_, metadata_settings_);
current_result_set_ = std::make_shared<FlightSqlResultSet>(
sql_client_, client_options_, call_options_, flight_info, transformer, diagnostics_,
metadata_settings_);

return current_result_set_;
}
Expand All @@ -267,9 +270,9 @@ std::shared_ptr<ResultSet> FlightSqlStatement::GetTypeInfo_V2(int16_t data_type)
auto transformer = std::make_shared<GetTypeInfo_Transformer>(
metadata_settings_, odbcabstraction::V_2, data_type);

current_result_set_ =
std::make_shared<FlightSqlResultSet>(sql_client_, call_options_, flight_info,
transformer, diagnostics_, metadata_settings_);
current_result_set_ = std::make_shared<FlightSqlResultSet>(
sql_client_, client_options_, call_options_, flight_info, transformer, diagnostics_,
metadata_settings_);

return current_result_set_;
}
Expand All @@ -285,9 +288,9 @@ std::shared_ptr<ResultSet> FlightSqlStatement::GetTypeInfo_V3(int16_t data_type)
auto transformer = std::make_shared<GetTypeInfo_Transformer>(
metadata_settings_, odbcabstraction::V_3, data_type);

current_result_set_ =
std::make_shared<FlightSqlResultSet>(sql_client_, call_options_, flight_info,
transformer, diagnostics_, metadata_settings_);
current_result_set_ = std::make_shared<FlightSqlResultSet>(
sql_client_, client_options_, call_options_, flight_info, transformer, diagnostics_,
metadata_settings_);

return current_result_set_;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class FlightSqlStatement : public odbcabstraction::Statement {
private:
odbcabstraction::Diagnostics diagnostics_;
std::map<StatementAttributeId, Attribute> attribute_;
arrow::flight::FlightClientOptions client_options_;
arrow::flight::FlightCallOptions call_options_;
arrow::flight::sql::FlightSqlClient& sql_client_;
std::shared_ptr<odbcabstraction::ResultSet> current_result_set_;
Expand All @@ -48,6 +49,7 @@ class FlightSqlStatement : public odbcabstraction::Statement {
public:
FlightSqlStatement(const odbcabstraction::Diagnostics& diagnostics,
arrow::flight::sql::FlightSqlClient& sql_client,
arrow::flight::FlightClientOptions client_options,
arrow::flight::FlightCallOptions call_options,
const odbcabstraction::MetadataSettings& metadata_settings);
~FlightSqlStatement();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,9 @@ void ParseTableTypes(const std::string& table_type,
}

std::shared_ptr<ResultSet> GetTablesForSQLAllCatalogs(
const ColumnNames& names, FlightCallOptions& call_options,
FlightSqlClient& sql_client, odbcabstraction::Diagnostics& diagnostics,
const ColumnNames& names, FlightClientOptions& client_options,
FlightCallOptions& call_options, FlightSqlClient& sql_client,
odbcabstraction::Diagnostics& diagnostics,
const odbcabstraction::MetadataSettings& metadata_settings) {
Result<std::shared_ptr<FlightInfo>> result = sql_client.GetCatalogs(call_options);

Expand All @@ -92,14 +93,15 @@ std::shared_ptr<ResultSet> GetTablesForSQLAllCatalogs(
.AddFieldOfNulls(names.remarks_column, arrow::utf8())
.Build();

return std::make_shared<FlightSqlResultSet>(
sql_client, call_options, flight_info, transformer, diagnostics, metadata_settings);
return std::make_shared<FlightSqlResultSet>(sql_client, client_options, call_options,
flight_info, transformer, diagnostics,
metadata_settings);
}

std::shared_ptr<ResultSet> GetTablesForSQLAllDbSchemas(
const ColumnNames& names, FlightCallOptions& call_options,
FlightSqlClient& sql_client, const std::string* schema_name,
odbcabstraction::Diagnostics& diagnostics,
const ColumnNames& names, FlightClientOptions& client_options,
FlightCallOptions& call_options, FlightSqlClient& sql_client,
const std::string* schema_name, odbcabstraction::Diagnostics& diagnostics,
const odbcabstraction::MetadataSettings& metadata_settings) {
Result<std::shared_ptr<FlightInfo>> result =
sql_client.GetDbSchemas(call_options, nullptr, schema_name);
Expand All @@ -119,13 +121,15 @@ std::shared_ptr<ResultSet> GetTablesForSQLAllDbSchemas(
.AddFieldOfNulls(names.remarks_column, arrow::utf8())
.Build();

return std::make_shared<FlightSqlResultSet>(
sql_client, call_options, flight_info, transformer, diagnostics, metadata_settings);
return std::make_shared<FlightSqlResultSet>(sql_client, client_options, call_options,
flight_info, transformer, diagnostics,
metadata_settings);
}

std::shared_ptr<ResultSet> GetTablesForSQLAllTableTypes(
const ColumnNames& names, FlightCallOptions& call_options,
FlightSqlClient& sql_client, odbcabstraction::Diagnostics& diagnostics,
const ColumnNames& names, FlightClientOptions& client_options,
FlightCallOptions& call_options, FlightSqlClient& sql_client,
odbcabstraction::Diagnostics& diagnostics,
const odbcabstraction::MetadataSettings& metadata_settings) {
Result<std::shared_ptr<FlightInfo>> result = sql_client.GetTableTypes(call_options);

Expand All @@ -144,15 +148,16 @@ std::shared_ptr<ResultSet> GetTablesForSQLAllTableTypes(
.AddFieldOfNulls(names.remarks_column, arrow::utf8())
.Build();

return std::make_shared<FlightSqlResultSet>(
sql_client, call_options, flight_info, transformer, diagnostics, metadata_settings);
return std::make_shared<FlightSqlResultSet>(sql_client, client_options, call_options,
flight_info, transformer, diagnostics,
metadata_settings);
}

std::shared_ptr<ResultSet> GetTablesForGenericUse(
const ColumnNames& names, FlightCallOptions& call_options,
FlightSqlClient& sql_client, const std::string* catalog_name,
const std::string* schema_name, const std::string* table_name,
const std::vector<std::string>& table_types,
const ColumnNames& names, FlightClientOptions& client_options,
FlightCallOptions& call_options, FlightSqlClient& sql_client,
const std::string* catalog_name, const std::string* schema_name,
const std::string* table_name, const std::vector<std::string>& table_types,
odbcabstraction::Diagnostics& diagnostics,
const odbcabstraction::MetadataSettings& metadata_settings) {
Result<std::shared_ptr<FlightInfo>> result = sql_client.GetTables(
Expand All @@ -173,8 +178,9 @@ std::shared_ptr<ResultSet> GetTablesForGenericUse(
.AddFieldOfNulls(names.remarks_column, arrow::utf8())
.Build();

return std::make_shared<FlightSqlResultSet>(
sql_client, call_options, flight_info, transformer, diagnostics, metadata_settings);
return std::make_shared<FlightSqlResultSet>(sql_client, client_options, call_options,
flight_info, transformer, diagnostics,
metadata_settings);
}

} // namespace flight_sql
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ namespace driver {
namespace flight_sql {

using arrow::flight::FlightCallOptions;
using arrow::flight::FlightClientOptions;
using arrow::flight::sql::FlightSqlClient;
using odbcabstraction::MetadataSettings;
using odbcabstraction::ResultSet;
Expand All @@ -46,26 +47,28 @@ void ParseTableTypes(const std::string& table_type,
std::vector<std::string>& table_types);

std::shared_ptr<ResultSet> GetTablesForSQLAllCatalogs(
const ColumnNames& column_names, FlightCallOptions& call_options,
FlightSqlClient& sql_client, odbcabstraction::Diagnostics& diagnostics,
const ColumnNames& column_names, FlightClientOptions& client_options,
FlightCallOptions& call_options, FlightSqlClient& sql_client,
odbcabstraction::Diagnostics& diagnostics,
const odbcabstraction::MetadataSettings& metadata_settings);

std::shared_ptr<ResultSet> GetTablesForSQLAllDbSchemas(
const ColumnNames& column_names, FlightCallOptions& call_options,
FlightSqlClient& sql_client, const std::string* schema_name,
odbcabstraction::Diagnostics& diagnostics,
const ColumnNames& column_names, FlightClientOptions& client_options,
FlightCallOptions& call_options, FlightSqlClient& sql_client,
const std::string* schema_name, odbcabstraction::Diagnostics& diagnostics,
const odbcabstraction::MetadataSettings& metadata_settings);

std::shared_ptr<ResultSet> GetTablesForSQLAllTableTypes(
const ColumnNames& column_names, FlightCallOptions& call_options,
FlightSqlClient& sql_client, odbcabstraction::Diagnostics& diagnostics,
const ColumnNames& column_names, FlightClientOptions& client_options,
FlightCallOptions& call_options, FlightSqlClient& sql_client,
odbcabstraction::Diagnostics& diagnostics,
const odbcabstraction::MetadataSettings& metadata_settings);

std::shared_ptr<ResultSet> GetTablesForGenericUse(
const ColumnNames& column_names, FlightCallOptions& call_options,
FlightSqlClient& sql_client, const std::string* catalog_name,
const std::string* schema_name, const std::string* table_name,
const std::vector<std::string>& table_types,
const ColumnNames& column_names, FlightClientOptions& client_options,
FlightCallOptions& call_options, FlightSqlClient& sql_client,
const std::string* catalog_name, const std::string* schema_name,
const std::string* table_name, const std::vector<std::string>& table_types,
odbcabstraction::Diagnostics& diagnostics,
const odbcabstraction::MetadataSettings& metadata_settings);
} // namespace flight_sql
Expand Down
Loading
Loading