Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions .github/workflows/cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,7 @@ jobs:
ARROW_DATASET: ON
ARROW_FLIGHT: ON
ARROW_FLIGHT_SQL: ON
ARROW_FLIGHT_SQL_ODBC: ON
ARROW_GANDIVA: ON
ARROW_GCS: ON
ARROW_HDFS: OFF
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[submodule "cpp/submodules/parquet-testing"]
path = cpp/submodules/parquet-testing
url = https://github.com/apache/parquet-testing.git
[submodule "testing"]
path = testing
url = https://github.com/apache/arrow-testing
8 changes: 8 additions & 0 deletions cpp/CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,14 @@
"ARROW_FLIGHT_SQL": "ON"
}
},
{
"name": "features-flight-sql-odbc",
"inherits": "features-flight-sql",
"hidden": true,
"cacheVariables": {
"ARROW_FLIGHT_SQL_ODBC": "ON"
}
},
{
"name": "features-gandiva",
"inherits": "features-basic",
Expand Down
3 changes: 3 additions & 0 deletions cpp/build-support/lint_cpp_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ def lint_file(path):

EXCLUSIONS = _paths('''\
arrow/arrow-config.cmake
arrow/flight/sql/odbc/flight_sql/get_info_cache.h
arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/blocking_queue.h
arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/odbc_handle.h
arrow/python/iterators.h
arrow/util/hashing.h
arrow/util/macros.h
Expand Down
7 changes: 7 additions & 0 deletions cpp/cmake_modules/DefineOptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,13 @@ takes precedence over ccache if a storage backend is configured" ON)
DEPENDS
ARROW_FLIGHT)

define_option(ARROW_FLIGHT_SQL_ODBC
"Build the Arrow Flight SQL ODBC extension"
OFF
DEPENDS
ARROW_FLIGHT_SQL
ARROW_COMPUTE)

define_option(ARROW_GANDIVA
"Build the Gandiva libraries"
OFF
Expand Down
4 changes: 4 additions & 0 deletions cpp/src/arrow/flight/sql/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -168,3 +168,7 @@ if(ARROW_BUILD_TESTS OR ARROW_BUILD_EXAMPLES)
endforeach()
endif()
endif()

if(ARROW_FLIGHT_SQL_ODBC)
add_subdirectory(odbc)
endif()
13 changes: 1 addition & 12 deletions cpp/src/arrow/flight/sql/odbc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
cmake_minimum_required(VERSION 3.16)
set(CMAKE_CXX_STANDARD 17)

project(flightsql_odbc)
add_custom_target(arrow_flight_sql_odbc)

if(CMAKE_BUILD_TYPE STREQUAL "Release")
add_compile_definitions(NDEBUG)
Expand All @@ -28,16 +28,5 @@ endif()
find_package(Boost REQUIRED)
find_package(ODBC REQUIRED)

# Fetch and include GTest
# Adapted from Google's documentation: https://google.github.io/googletest/quickstart-cmake.html#set-up-a-project
include(FetchContent)
fetchcontent_declare(googletest
URL https://github.com/google/googletest/archive/v1.14.0.zip)
# For Windows: Prevent overriding the parent project's compiler/linker settings
set(gtest_force_shared_crt
ON
CACHE BOOL "" FORCE)
fetchcontent_makeavailable(googletest)

add_subdirectory(flight_sql)
add_subdirectory(odbcabstraction)
51 changes: 20 additions & 31 deletions cpp/src/arrow/flight/sql/odbc/flight_sql/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -100,27 +100,27 @@ add_library(arrow_odbc_spi_impl
system_trust_store.h
utils.cc)
target_include_directories(arrow_odbc_spi_impl PUBLIC ${CMAKE_CURRENT_LIST_DIR})

if(WIN32)
target_sources(arrow_odbc_spi_impl
include/flight_sql/config/configuration.h
include/flight_sql/config/connection_string_parser.h
include/flight_sql/ui/add_property_window.h
include/flight_sql/ui/custom_window.h
include/flight_sql/ui/dsn_configuration_window.h
include/flight_sql/ui/window.h
config/configuration.cc
config/connection_string_parser.cc
ui/custom_window.cc
ui/window.cc
ui/dsn_configuration_window.cc
ui/add_property_window.cc
system_dsn.cc)
PRIVATE include/flight_sql/config/configuration.h
include/flight_sql/config/connection_string_parser.h
include/flight_sql/ui/add_property_window.h
include/flight_sql/ui/custom_window.h
include/flight_sql/ui/dsn_configuration_window.h
include/flight_sql/ui/window.h
config/configuration.cc
config/connection_string_parser.cc
ui/custom_window.cc
ui/window.cc
ui/dsn_configuration_window.cc
ui/add_property_window.cc
system_dsn.cc)
endif()

find_package(ArrowFlightSql)

target_link_libraries(arrow_odbc_spi_impl PUBLIC odbcabstraction
ArrowFlightSql::arrow_flight_sql_static)
target_link_libraries(arrow_odbc_spi_impl PUBLIC odbcabstraction arrow_flight_sql_shared)

if(MSVC)
set(CMAKE_CXX_FLAGS_RELEASE "/MD")
Expand Down Expand Up @@ -157,7 +157,8 @@ set_target_properties(arrow_odbc_spi_impl_cli
target_link_libraries(arrow_odbc_spi_impl_cli arrow_odbc_spi_impl)

# Unit tests
add_executable(arrow_odbc_spi_impl_test
add_arrow_test(arrow_odbc_spi_impl_test
SOURCES
accessors/boolean_array_accessor_test.cc
accessors/binary_array_accessor_test.cc
accessors/date_array_accessor_test.cc
Expand All @@ -170,18 +171,6 @@ add_executable(arrow_odbc_spi_impl_test
parse_table_types_test.cc
json_converter_test.cc
record_batch_transformer_test.cc
utils_test.cc)

set_target_properties(arrow_odbc_spi_impl_test
PROPERTIES RUNTIME_OUTPUT_DIRECTORY
${CMAKE_BINARY_DIR}/test/$<CONFIG>/bin)
target_link_libraries(arrow_odbc_spi_impl_test arrow_odbc_spi_impl gtest gtest_main)

add_test(connection_test arrow_odbc_spi_impl_test)
add_test(transformer_test arrow_odbc_spi_impl_test)

add_custom_command(TARGET arrow_odbc_spi_impl_test
COMMENT "Run tests"
POST_BUILD
COMMAND ${CMAKE_BINARY_DIR}/test/$<CONFIG>/bin/arrow_odbc_spi_impl_test
)
utils_test.cc
EXTRA_LINK_LIBS
arrow_odbc_spi_impl)
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
namespace driver {
namespace flight_sql {

namespace arrow {
namespace odbcabstraction {
using arrow::BinaryArray;
using odbcabstraction::RowStatus;

namespace {

Expand Down Expand Up @@ -71,7 +71,8 @@ BinaryArrayFlightSqlAccessor<TARGET_TYPE>::BinaryArrayFlightSqlAccessor(Array* a
BinaryArrayFlightSqlAccessor<TARGET_TYPE>>(array) {}

template <>
RowStatus BinaryArrayFlightSqlAccessor<CDataType_BINARY>::MoveSingleCell_impl(
RowStatus
BinaryArrayFlightSqlAccessor<odbcabstraction::CDataType_BINARY>::MoveSingleCell_impl(
ColumnBinding* binding, int64_t arrow_row, int64_t i, int64_t& value_offset,
bool update_value_offset, odbcabstraction::Diagnostics& diagnostics) {
return MoveSingleCellToBinaryBuffer(binding, this->GetArray(), arrow_row, i,
Expand All @@ -86,7 +87,5 @@ size_t BinaryArrayFlightSqlAccessor<TARGET_TYPE>::GetCellLength_impl(

template class BinaryArrayFlightSqlAccessor<odbcabstraction::CDataType_BINARY>;

} // namespace odbcabstraction
} // namespace arrow
} // namespace flight_sql
} // namespace driver
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
namespace driver {
namespace flight_sql {

namespace arrow {
namespace odbcabstraction {
using arrow::BinaryArray;
using odbcabstraction::RowStatus;

template <CDataType TARGET_TYPE>
class BinaryArrayFlightSqlAccessor
Expand All @@ -41,7 +41,5 @@ class BinaryArrayFlightSqlAccessor
size_t GetCellLength_impl(ColumnBinding* binding) const;
};

} // namespace odbcabstraction
} // namespace arrow
} // namespace flight_sql
} // namespace driver
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,24 @@
namespace driver {
namespace flight_sql {

namespace arrow {
namespace odbcabstraction {
using arrow::BinaryType;
using odbcabstraction::OdbcVersion;

using arrow::ArrayFromVector;

TEST(BinaryArrayAccessor, Test_CDataType_BINARY_Basic) {
std::vector<std::string> values = {"foo", "barx", "baz123"};
std::shared_ptr<Array> array;
ArrayFromVector<BinaryType, std::string>(values, &array);

BinaryArrayFlightSqlAccessor<CDataType_BINARY> accessor(array.get());
BinaryArrayFlightSqlAccessor<odbcabstraction::CDataType_BINARY> accessor(array.get());

size_t max_strlen = 64;
std::vector<char> buffer(values.size() * max_strlen);
std::vector<ssize_t> strlen_buffer(values.size());

ColumnBinding binding(CDataType_BINARY, 0, 0, buffer.data(), max_strlen,
strlen_buffer.data());
ColumnBinding binding(odbcabstraction::CDataType_BINARY, 0, 0, buffer.data(),
max_strlen, strlen_buffer.data());

int64_t value_offset = 0;
odbcabstraction::Diagnostics diagnostics("Foo", "Foo", OdbcVersion::V_3);
Expand All @@ -61,14 +63,14 @@ TEST(BinaryArrayAccessor, Test_CDataType_BINARY_Truncation) {
std::shared_ptr<Array> array;
ArrayFromVector<BinaryType, std::string>(values, &array);

BinaryArrayFlightSqlAccessor<CDataType_BINARY> accessor(array.get());
BinaryArrayFlightSqlAccessor<odbcabstraction::CDataType_BINARY> accessor(array.get());

size_t max_strlen = 8;
std::vector<char> buffer(values.size() * max_strlen);
std::vector<ssize_t> strlen_buffer(values.size());

ColumnBinding binding(CDataType_BINARY, 0, 0, buffer.data(), max_strlen,
strlen_buffer.data());
ColumnBinding binding(odbcabstraction::CDataType_BINARY, 0, 0, buffer.data(),
max_strlen, strlen_buffer.data());

std::stringstream ss;
int64_t value_offset = 0;
Expand Down Expand Up @@ -99,7 +101,5 @@ TEST(BinaryArrayAccessor, Test_CDataType_BINARY_Truncation) {
ASSERT_EQ(values[0], ss.str());
}

} // namespace odbcabstraction
} // namespace arrow
} // namespace flight_sql
} // namespace driver
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
namespace driver {
namespace flight_sql {

namespace arrow {
namespace odbcabstraction {
using arrow::BooleanArray;
using odbcabstraction::RowStatus;

template <CDataType TARGET_TYPE>
BooleanArrayFlightSqlAccessor<TARGET_TYPE>::BooleanArrayFlightSqlAccessor(Array* array)
Expand Down Expand Up @@ -53,7 +53,5 @@ size_t BooleanArrayFlightSqlAccessor<TARGET_TYPE>::GetCellLength_impl(

template class BooleanArrayFlightSqlAccessor<odbcabstraction::CDataType_BIT>;

} // namespace odbcabstraction
} // namespace arrow
} // namespace flight_sql
} // namespace driver
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@

#pragma once

#include "arrow/flight/sql/odbc/flight_sql/types.h"
#include "arrow/flight/sql/odbc/odbcabstraction/diagnostics.h"
#include "arrow/flight/sql/odbc/odbcabstraction/types.h"
#include "arrow/flight/sql/odbc/flight_sql/accessors/types.h"
#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/diagnostics.h"
#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/types.h"
#include "arrow/type_fwd.h"

namespace driver {
namespace flight_sql {

namespace arrow {
namespace odbcabstraction {
using arrow::BooleanArray;
using odbcabstraction::RowStatus;

template <CDataType TARGET_TYPE>
class BooleanArrayFlightSqlAccessor
Expand All @@ -42,7 +42,5 @@ class BooleanArrayFlightSqlAccessor
size_t GetCellLength_impl(ColumnBinding* binding) const;
};

} // namespace odbcabstraction
} // namespace arrow
} // namespace flight_sql
} // namespace driver
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,23 @@
namespace driver {
namespace flight_sql {

namespace arrow {
namespace odbcabstraction {
using arrow::BooleanType;
using odbcabstraction::OdbcVersion;

using arrow::ArrayFromVector;

TEST(BooleanArrayFlightSqlAccessor, Test_BooleanArray_CDataType_BIT) {
const std::vector<bool> values = {true, false, true};
std::shared_ptr<Array> array;
ArrayFromVector<BooleanType>(values, &array);

BooleanArrayFlightSqlAccessor<CDataType_BIT> accessor(array.get());
BooleanArrayFlightSqlAccessor<odbcabstraction::CDataType_BIT> accessor(array.get());

std::vector<char> buffer(values.size());
std::vector<ssize_t> strlen_buffer(values.size());

ColumnBinding binding(CDataType_BIT, 0, 0, buffer.data(), 0, strlen_buffer.data());
ColumnBinding binding(odbcabstraction::CDataType_BIT, 0, 0, buffer.data(), 0,
strlen_buffer.data());

int64_t value_offset = 0;
odbcabstraction::Diagnostics diagnostics("Foo", "Foo", OdbcVersion::V_3);
Expand All @@ -49,7 +52,5 @@ TEST(BooleanArrayFlightSqlAccessor, Test_BooleanArray_CDataType_BIT) {
}
}

} // namespace odbcabstraction
} // namespace arrow
} // namespace flight_sql
} // namespace driver
7 changes: 1 addition & 6 deletions cpp/src/arrow/flight/sql/odbc/flight_sql/accessors/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@
namespace driver {
namespace flight_sql {

namespace arrow {
namespace odbcabstraction {

template <typename ARRAY_TYPE>
inline size_t CopyFromArrayValuesToBinding(ARRAY_TYPE* array, ColumnBinding* binding,
int64_t starting_row, int64_t cells) {
Expand All @@ -40,7 +37,7 @@ inline size_t CopyFromArrayValuesToBinding(ARRAY_TYPE* array, ColumnBinding* bin
for (int64_t i = 0; i < cells; ++i) {
int64_t current_row = starting_row + i;
if (array->IsNull(current_row)) {
binding->strlen_buffer[i] = NULL_DATA;
binding->strlen_buffer[i] = odbcabstraction::NULL_DATA;
} else {
binding->strlen_buffer[i] = element_size;
}
Expand All @@ -63,7 +60,5 @@ inline size_t CopyFromArrayValuesToBinding(ARRAY_TYPE* array, ColumnBinding* bin
return cells;
}

} // namespace odbcabstraction
} // namespace arrow
} // namespace flight_sql
} // namespace driver
Loading
Loading