Skip to content

Commit

Permalink
Update arrow version from 9 to 14
Browse files Browse the repository at this point in the history
* Set C+ standard+ to 17 to accommodate arrow build. `flightsql-odbc` used C++ 11, but arrow 14.0.0 uses C++ 17, so C++ standard is set to 17 to support building of arrow.
* Error arrow/utils/optional.h no longer found is fixed.
* I found that [Arrow commit 5e49174](apache@5e49174)
removes arrow/utils/optional.h and replaces it with <optional> C++ 17 header.
So I updated flightsql-odbc code with when looking at this commit.
* Removed deprecated `std::binary_function`.
* There are build errors from `boost::variant`, so changed `boost::variant` to `std::variant` to align with rest of Arrow repository. Also replaced `boost::get` with `std::get` as a result.
* Fixed "error C2660: 'arrow::flight::FlightInfo::GetSchema': function does not take 2 arguments":
I checked [commit d214455](apache@d214455)
that changed GetSchema, and found that GetSchema(dictionary_memo, out) can be replaced with GetSchema(dictionary_memo).Value(out).
* Fixed error C2661: 'arrow::flight::FlightClient::Connect': no overloaded function takes 3 arguments:
I checked [commit 9e08c50](apache@9e08c50)
that changed Connect, and found that Connect(location, options, client) can be replaced with Connect(location, options).Value(client).
* Fixed error C2660: 'arrow::flight::Location::ForGrpcTls': function does not take 3 arguments:
I checked [commit d214455](apache@d214455)
that changed ForGrpcTls, and found that Connect(host, port, location) can be replaced with ForGrpcTls(host, port).Value(location). Same process to fix error with `Location::ForGrpcTcp`.
* Fixed error of scalar->value being deprecated. I see from [commit 6cc37cf](apache@6cc37cf)
that scalar::value is replaced with scalar::child_value(), so I went with this change.
* Fixed linking errors. `ARROW_FLIGHT_SQL_STATIC` was added in [commit 9c93f82](apache@9c93f82), so now we need to define `ARROW_FLIGHT_SQL_STATIC` in CMakeLists.txt also.
  • Loading branch information
alinaliBQ committed Dec 13, 2023
1 parent 91a6bee commit 5ce0e0a
Show file tree
Hide file tree
Showing 27 changed files with 114 additions and 114 deletions.
2 changes: 1 addition & 1 deletion cpp/src/flightsql_odbc/flightsql-odbc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#

cmake_minimum_required(VERSION 3.11)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD 17)

project(flightsql_odbc)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#

cmake_minimum_required(VERSION 3.11)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD 17)

set(CMAKE_POSITION_INDEPENDENT_CODE ON)

Expand Down Expand Up @@ -115,7 +115,7 @@ endif()

# If build fails, need to remove build folder to re-build.
set(ARROW_GIT_REPOSITORY "https://github.com/apache/arrow.git" CACHE STRING "Arrow repository path or URL")
set(ARROW_GIT_TAG "b050bd0d31db6412256cec3362c0d57c9732e1f2" CACHE STRING "Tag for the Arrow repository")
set(ARROW_GIT_TAG "apache-arrow-14.0.1" CACHE STRING "Tag for the Arrow repository")

message("Using Arrow from ${ARROW_GIT_REPOSITORY} on tag ${ARROW_GIT_TAG}")
ExternalProject_Add(
Expand All @@ -134,7 +134,7 @@ link_directories(${CMAKE_CURRENT_BINARY_DIR}/ApacheArrow-prefix/src/ApacheArrow-

if (MSVC)
# the following definitions stop arrow from using __declspec when staticly linking and will break on windows without them
add_compile_definitions(ARROW_STATIC ARROW_FLIGHT_STATIC)
add_compile_definitions(ARROW_STATIC ARROW_FLIGHT_STATIC ARROW_FLIGHT_SQL_STATIC)
endif()

enable_testing()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ class UserPasswordAuthMethod : public FlightSqlAuthMethod {
FlightCallOptions auth_call_options;
const boost::optional<Connection::Attribute> &login_timeout =
connection.GetAttribute(Connection::LOGIN_TIMEOUT);
if (login_timeout && boost::get<uint32_t>(*login_timeout) > 0) {
if (login_timeout && std::get<uint32_t>(*login_timeout) > 0) {
// ODBC's LOGIN_TIMEOUT attribute and FlightCallOptions.timeout use
// seconds as time unit.
double timeout_seconds = static_cast<double>(boost::get<uint32_t>(*login_timeout));
double timeout_seconds = static_cast<double>(std::get<uint32_t>(*login_timeout));
if (timeout_seconds > 0) {
auth_call_options.timeout = TimeoutDuration{timeout_seconds};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ void FlightSqlConnection::Connect(const ConnPropertyMap &properties,

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

std::unique_ptr<FlightSqlAuthMethod> auth_method =
FlightSqlAuthMethod::FromProperties(flight_client, properties);
Expand Down Expand Up @@ -251,9 +251,9 @@ FlightSqlConnection::PopulateCallOptions(const ConnPropertyMap &props) {
// is the first request.
const boost::optional<Connection::Attribute> &connection_timeout = closed_ ?
GetAttribute(LOGIN_TIMEOUT) : GetAttribute(CONNECTION_TIMEOUT);
if (connection_timeout && boost::get<uint32_t>(*connection_timeout) > 0) {
if (connection_timeout && std::get<uint32_t>(*connection_timeout) > 0) {
call_options_.timeout =
TimeoutDuration{static_cast<double>(boost::get<uint32_t>(*connection_timeout))};
TimeoutDuration{static_cast<double>(std::get<uint32_t>(*connection_timeout))};
}

for (auto prop : props) {
Expand Down Expand Up @@ -342,7 +342,7 @@ FlightSqlConnection::BuildLocation(const ConnPropertyMap &properties,
operation_result = address_info.GetAddressInfo(host, host_name_info,
NI_MAXHOST);
if (operation_result) {
ThrowIfNotOK(Location::ForGrpcTls(host_name_info, port, &location));
ThrowIfNotOK(Location::ForGrpcTls(host_name_info, port).Value(&location));
return location;
}
// TODO: We should log that we could not convert an IP to hostname here.
Expand All @@ -353,11 +353,11 @@ FlightSqlConnection::BuildLocation(const ConnPropertyMap &properties,
// if it is not an IP.
}

ThrowIfNotOK(Location::ForGrpcTls(host, port, &location));
ThrowIfNotOK(Location::ForGrpcTls(host, port).Value(&location));
return location;
}

ThrowIfNotOK(Location::ForGrpcTcp(host, port, &location));
ThrowIfNotOK(Location::ForGrpcTcp(host, port).Value(&location));
return location;
}

Expand Down Expand Up @@ -415,7 +415,7 @@ Connection::Info FlightSqlConnection::GetInfo(uint16_t info_type) {
if (info_type == SQL_DBMS_NAME || info_type == SQL_SERVER_NAME) {
// Update the database component reported in error messages.
// We do this lazily for performance reasons.
diagnostics_.SetDataSourceComponent(boost::get<std::string>(result));
diagnostics_.SetDataSourceComponent(std::get<std::string>(result));
}
return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ TEST(AttributeTests, SetAndGetAttribute) {

EXPECT_TRUE(firstValue);

EXPECT_EQ(boost::get<uint32_t>(*firstValue), static_cast<uint32_t>(200));
EXPECT_EQ(std::get<uint32_t>(*firstValue), static_cast<uint32_t>(200));

connection.SetAttribute(Connection::CONNECTION_TIMEOUT, static_cast<uint32_t>(300));

const boost::optional<Connection::Attribute> changeValue =
connection.GetAttribute(Connection::CONNECTION_TIMEOUT);

EXPECT_TRUE(changeValue);
EXPECT_EQ(boost::get<uint32_t>(*changeValue), static_cast<uint32_t>(300));
EXPECT_EQ(std::get<uint32_t>(*changeValue), static_cast<uint32_t>(300));

connection.Close();
}
Expand All @@ -48,7 +48,7 @@ TEST(AttributeTests, GetAttributeWithoutSetting) {
connection.GetAttribute(Connection::CONNECTION_TIMEOUT);
connection.SetClosed(false);

EXPECT_EQ(0, boost::get<uint32_t>(*optional));
EXPECT_EQ(0, std::get<uint32_t>(*optional));

connection.Close();
}
Expand Down Expand Up @@ -113,7 +113,7 @@ TEST(BuildLocationTests, ForTcp) {

Location expected_location;
ASSERT_TRUE(
Location::ForGrpcTcp("localhost", 32010, &expected_location).ok());
Location::ForGrpcTcp("localhost", 32010).Value(&expected_location).ok());
ASSERT_EQ(expected_location, actual_location1);
ASSERT_NE(expected_location, actual_location2);
}
Expand Down Expand Up @@ -146,7 +146,7 @@ TEST(BuildLocationTests, ForTls) {

Location expected_location;
ASSERT_TRUE(
Location::ForGrpcTls("localhost", 32010, &expected_location).ok());
Location::ForGrpcTls("localhost", 32010).Value(&expected_location).ok());
ASSERT_EQ(expected_location, actual_location1);
ASSERT_NE(expected_location, actual_location2);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace driver {
namespace flight_sql {

using arrow::internal::checked_pointer_cast;
using arrow::util::nullopt;
using std::nullopt;

GetTablesReader::GetTablesReader(std::shared_ptr<RecordBatch> record_batch)
: record_batch_(std::move(record_batch)), current_row_(-1) {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@
*/

#include "record_batch_transformer.h"
#include <arrow/util/optional.h>

namespace driver {
namespace flight_sql {

using namespace arrow;
using arrow::util::optional;
using std::optional;

class GetTablesReader {
private:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace driver {
namespace flight_sql {

using arrow::internal::checked_pointer_cast;
using arrow::util::nullopt;
using std::nullopt;

GetTypeInfoReader::GetTypeInfoReader(std::shared_ptr<RecordBatch> record_batch)
: record_batch_(std::move(record_batch)), current_row_(-1) {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@
* See "LICENSE" for license information.
*/

#include <optional>

#include "record_batch_transformer.h"
#include <arrow/util/optional.h>

namespace driver {
namespace flight_sql {

using namespace arrow;
using arrow::util::optional;
using std::optional;

class GetTypeInfoReader {
private:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ FlightSqlResultSet::FlightSqlResultSet(
if (transformer_) {
schema_ = transformer_->GetTransformedSchema();
} else {
ThrowIfNotOK(flight_info->GetSchema(nullptr, &schema_));
ThrowIfNotOK(flight_info->GetSchema(nullptr).Value(&schema_));
}

for (size_t i = 0; i < columns_.size(); ++i) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ namespace flight_sql {
using namespace odbcabstraction;
using arrow::DataType;
using arrow::Field;
using arrow::util::make_optional;
using arrow::util::nullopt;
using std::make_optional;
using std::nullopt;

constexpr int32_t DefaultDecimalPrecision = 38;

Expand Down Expand Up @@ -251,7 +251,7 @@ FlightSqlResultSetMetadata::FlightSqlResultSetMetadata(
metadata_settings_(metadata_settings){
arrow::ipc::DictionaryMemo dict_memo;

ThrowIfNotOK(flight_info->GetSchema(&dict_memo, &schema_));
ThrowIfNotOK(flight_info->GetSchema(&dict_memo).Value(&schema_));
}

} // namespace flight_sql
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ bool FlightSqlStatement::SetAttribute(StatementAttributeId attribute,
case MAX_LENGTH:
return CheckIfSetToOnlyValidValue(value, static_cast<size_t>(0));
case QUERY_TIMEOUT:
if (boost::get<size_t>(value) > 0) {
if (std::get<size_t>(value) > 0) {
call_options_.timeout =
TimeoutDuration{static_cast<double>(boost::get<size_t>(value))};
TimeoutDuration{static_cast<double>(std::get<size_t>(value))};
} else {
call_options_.timeout = TimeoutDuration{-1};
// Intentional fall-through.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ namespace driver {
namespace flight_sql {

using arrow::flight::sql::ColumnMetadata;
using arrow::util::make_optional;
using arrow::util::nullopt;
using arrow::util::optional;
using std::make_optional;
using std::nullopt;
using std::optional;

namespace {
std::shared_ptr<Schema> GetColumns_V3_Schema() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,19 @@
* See "LICENSE" for license information.
*/

#include <optional>

#include "record_batch_transformer.h"
#include <arrow/array/builder_binary.h>
#include <arrow/array/builder_primitive.h>
#include <arrow/status.h>
#include <arrow/util/optional.h>
#include <odbcabstraction/types.h>

namespace driver {
namespace flight_sql {

using odbcabstraction::MetadataSettings;
using arrow::util::optional;
using std::optional;

class GetColumns_RecordBatchBuilder {
private:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ GetTablesForSQLAllCatalogs(const ColumnNames &names,

ThrowIfNotOK(result.status());
flight_info = result.ValueOrDie();
ThrowIfNotOK(flight_info->GetSchema(nullptr, &schema));
ThrowIfNotOK(flight_info->GetSchema(nullptr).Value(&schema));

auto transformer = RecordBatchTransformerWithTasksBuilder(schema)
.RenameField("catalog_name", names.catalog_column)
Expand All @@ -102,7 +102,7 @@ std::shared_ptr<ResultSet> GetTablesForSQLAllDbSchemas(

ThrowIfNotOK(result.status());
flight_info = result.ValueOrDie();
ThrowIfNotOK(flight_info->GetSchema(nullptr, &schema));
ThrowIfNotOK(flight_info->GetSchema(nullptr).Value(&schema));

auto transformer = RecordBatchTransformerWithTasksBuilder(schema)
.AddFieldOfNulls(names.catalog_column, utf8())
Expand Down Expand Up @@ -130,7 +130,7 @@ GetTablesForSQLAllTableTypes(const ColumnNames &names,

ThrowIfNotOK(result.status());
flight_info = result.ValueOrDie();
ThrowIfNotOK(flight_info->GetSchema(nullptr, &schema));
ThrowIfNotOK(flight_info->GetSchema(nullptr).Value(&schema));

auto transformer = RecordBatchTransformerWithTasksBuilder(schema)
.AddFieldOfNulls(names.catalog_column, utf8())
Expand Down Expand Up @@ -158,7 +158,7 @@ std::shared_ptr<ResultSet> GetTablesForGenericUse(

ThrowIfNotOK(result.status());
flight_info = result.ValueOrDie();
ThrowIfNotOK(flight_info->GetSchema(nullptr, &schema));
ThrowIfNotOK(flight_info->GetSchema(nullptr).Value(&schema));

auto transformer = RecordBatchTransformerWithTasksBuilder(schema)
.RenameField("catalog_name", names.catalog_column)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
namespace driver {
namespace flight_sql {

using arrow::util::make_optional;
using arrow::util::nullopt;
using arrow::util::optional;
using std::make_optional;
using std::nullopt;
using std::optional;

namespace {
std::shared_ptr<Schema> GetTypeInfo_V3_Schema() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,19 @@
* See "LICENSE" for license information.
*/

#include <optional>

#include "record_batch_transformer.h"
#include <arrow/array/builder_binary.h>
#include <arrow/array/builder_primitive.h>
#include <arrow/status.h>
#include <arrow/util/optional.h>
#include <odbcabstraction/types.h>

namespace driver {
namespace flight_sql {

using odbcabstraction::MetadataSettings;
using arrow::util::optional;
using std::optional;

class GetTypeInfo_RecordBatchBuilder {
private:
Expand Down
Loading

0 comments on commit 5ce0e0a

Please sign in to comment.