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
37 changes: 37 additions & 0 deletions .github/workflows/cpp_extra.yml
Original file line number Diff line number Diff line change
Expand Up @@ -355,8 +355,11 @@ jobs:
macos-version: "14"
env:
ARROW_BUILD_TESTS: ON
ARROW_DEPENDENCY_SOURCE: BUNDLED
ARROW_DEPENDENCY_USE_SHARED: OFF
ARROW_FLIGHT_SQL_ODBC: ON
ARROW_HOME: /tmp/local
ARROW_MIMALLOC: OFF
steps:
- name: Checkout Arrow
uses: actions/checkout@v6.0.1
Expand All @@ -366,6 +369,22 @@ jobs:
- name: Install Dependencies
run: |
brew bundle --file=cpp/Brewfile

# We want to use bundled RE2 for static linking. If
# Homebrew's RE2 is installed, its header file may be used.
# We uninstall Homebrew's RE2 to ensure using bundled RE2.
brew uninstall grpc || : # gRPC depends on RE2
brew uninstall grpc@1.54 || : # gRPC 1.54 may be installed too
brew uninstall re2

# We want to use bundled Protobuf for static linking. If
# Homebrew's Protobuf is installed, its library file may be
# used on test We uninstall Homebrew's Protobuf to ensure using
# bundled Protobuf.
brew uninstall protobuf

# We want to use bundled Boost for static linking.
brew uninstall boost
- name: Setup ccache
run: |
ci/scripts/ccache_setup.sh
Expand Down Expand Up @@ -395,6 +414,24 @@ jobs:
export ARROW_CMAKE_ARGS="-DODBC_INCLUDE_DIR=$ODBC_INCLUDE_DIR"
export CXXFLAGS="$CXXFLAGS -I$ODBC_INCLUDE_DIR"
ci/scripts/cpp_build.sh $(pwd) $(pwd)/build
- name: Setup Python
uses: actions/setup-python@v6
with:
python-version: 3
- name: Setup Archery
run: python3 -m pip install -e dev/archery
- name: Check ODBC Dependency
run: |
# ODBC dependency should not include other Arrow or third party libraries
archery linking check-dependencies \
--allow CoreFoundation \
--allow libSystem \
--allow libarrow_flight_sql_odbc \
--allow libc++ \
--allow libiconv \
--allow libresolv \
--allow libz \
"$(pwd)/build/cpp/debug/libarrow_flight_sql_odbc.dylib"
- name: Register Flight SQL ODBC Driver
run: |
sudo cpp/src/arrow/flight/sql/odbc/install/mac/install_odbc.sh $(pwd)/build/cpp/debug/libarrow_flight_sql_odbc.dylib
Expand Down
19 changes: 17 additions & 2 deletions cpp/cmake_modules/ThirdpartyToolchain.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -1114,6 +1114,22 @@ function(build_boost)
else()
list(APPEND BOOST_EXCLUDE_LIBRARIES uuid)
endif()
if(ARROW_FLIGHT_SQL_ODBC)
# GH-49244: Replace boost beast with alternatives in ODBC
# GH-49243: Replace boost variant with std::variant in ODBC
# GH-49245: Replace boost xpressive with alternatives in ODBC
list(APPEND
BOOST_INCLUDE_LIBRARIES
beast
variant
xpressive)
else()
list(APPEND
BOOST_EXCLUDE_LIBRARIES
beast
variant
xpressive)
endif()
set(BOOST_SKIP_INSTALL_RULES ON)
if(NOT ARROW_ENABLE_THREADING)
set(BOOST_UUID_LINK_LIBATOMIC OFF)
Expand Down Expand Up @@ -3025,8 +3041,7 @@ function(build_cares)
if(APPLE)
# libresolv must be linked from c-ares version 1.16.1
find_library(LIBRESOLV_LIBRARY NAMES resolv libresolv REQUIRED)
set_target_properties(c-ares::cares PROPERTIES INTERFACE_LINK_LIBRARIES
"${LIBRESOLV_LIBRARY}")
target_link_libraries(c-ares INTERFACE ${LIBRESOLV_LIBRARY})
endif()
Comment on lines 3043 to 3045
Copy link
Collaborator Author

@alinaliBQ alinaliBQ Feb 11, 2026

Choose a reason for hiding this comment

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

This change fixes error:

CMake Error at cmake_modules/ThirdpartyToolchain.cmake:3032 (set_target_properties):
  set_target_properties can not be used on an ALIAS target.

Without this change, we have failed run with c-ares::cares being used. Log: https://github.com/Bit-Quill/arrow/actions/runs/21459770235/job/61809740997?pr=153#step:7:540


set(ARROW_BUNDLED_STATIC_LIBS
Expand Down
43 changes: 29 additions & 14 deletions cpp/src/arrow/flight/sql/odbc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,14 @@
# specific language governing permissions and limitations
# under the License.

# Use C++ 20 for ODBC and its subdirectory
# GH-44792: Arrow will switch to C++ 20
set(CMAKE_CXX_STANDARD 20)

if(WIN32)
if(MSVC_VERSION GREATER_EQUAL 1900)
set(ODBCINST legacy_stdio_definitions odbccp32 shlwapi)
elseif(MINGW)
set(ODBCINST odbccp32 shlwapi)
endif()
elseif(APPLE)
set(ODBCINST iodbcinst)
set(ODBCINST iodbc iodbcinst)
else()
set(ODBCINST odbcinst)
endif()
Expand Down Expand Up @@ -61,6 +57,27 @@ if(WIN32)
list(APPEND ARROW_FLIGHT_SQL_ODBC_SRCS odbc.def install/versioninfo.rc)
endif()

# On Windows, dynmaic build for ODBC is supported.
# On unix systems, static build for ODBC is supported, all libraries are linked statically on unix.
set(ARROW_FLIGHT_SQL_ODBC_DEPENDENCIES "")
set(ARROW_FLIGHT_SQL_ODBC_SHARED_INSTALL_INTERFACE_LIBS "")
set(ARROW_FLIGHT_SQL_ODBC_STATIC_INSTALL_INTERFACE_LIBS "")
set(ARROW_FLIGHT_SQL_ODBC_SHARED_PRIVATE_LINK_LIBS "")
if(WIN32)
set(ARROW_FLIGHT_SQL_ODBC_DEPENDENCIES arrow_flight_sql)
set(ARROW_FLIGHT_SQL_ODBC_SHARED_LINK_LIBS arrow_flight_sql_shared arrow_odbc_spi_impl)
set(ARROW_FLIGHT_SQL_ODBC_STATIC_LINK_LIBS arrow_flight_sql_static)
list(APPEND ARROW_FLIGHT_SQL_ODBC_SHARED_INSTALL_INTERFACE_LIBS
ArrowFlight::arrow_flight_sql_shared)
list(APPEND ARROW_FLIGHT_SQL_ODBC_STATIC_INSTALL_INTERFACE_LIBS
ArrowFlight::arrow_flight_sql_static)
list(APPEND ARROW_FLIGHT_SQL_ODBC_SHARED_PRIVATE_LINK_LIBS ODBC::ODBC ${ODBCINST})
else()
# Unix
set(ARROW_FLIGHT_SQL_ODBC_SHARED_LINK_LIBS arrow_odbc_spi_impl)
set(ARROW_FLIGHT_SQL_ODBC_STATIC_LINK_LIBS ODBC::ODBC ${ODBCINST})
endif()
Comment on lines +66 to +79
Copy link
Member

Choose a reason for hiding this comment

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

Why do we need this if()/else()? Can we use only one add_arrow_lib()?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sure, I have changed to use one add_arrow_lib() for easier maintenance


add_arrow_lib(arrow_flight_sql_odbc
CMAKE_PACKAGE_NAME
ArrowFlightSqlOdbc
Expand All @@ -70,24 +87,22 @@ add_arrow_lib(arrow_flight_sql_odbc
ARROW_FLIGHT_SQL_ODBC_LIBRARIES
SOURCES
${ARROW_FLIGHT_SQL_ODBC_SRCS}
DEPENDENCIES
arrow_flight_sql
DEFINITIONS
UNICODE
DEPENDENCIES
${ARROW_FLIGHT_SQL_ODBC_DEPENDENCIES}
SHARED_LINK_FLAGS
${ARROW_VERSION_SCRIPT_FLAGS} # Defined in cpp/arrow/CMakeLists.txt
SHARED_LINK_LIBS
arrow_flight_sql_shared
${ARROW_FLIGHT_SQL_ODBC_SHARED_LINK_LIBS}
SHARED_INSTALL_INTERFACE_LIBS
ArrowFlight::arrow_flight_sql_shared
${ARROW_FLIGHT_SQL_ODBC_SHARED_INSTALL_INTERFACE_LIBS}
STATIC_LINK_LIBS
arrow_flight_sql_static
${ARROW_FLIGHT_SQL_ODBC_STATIC_LINK_LIBS}
STATIC_INSTALL_INTERFACE_LIBS
ArrowFlight::arrow_flight_sql_static
${ARROW_FLIGHT_SQL_ODBC_STATIC_INSTALL_INTERFACE_LIBS}
SHARED_PRIVATE_LINK_LIBS
ODBC::ODBC
${ODBCINST}
arrow_odbc_spi_impl)
${ARROW_FLIGHT_SQL_ODBC_SHARED_PRIVATE_LINK_LIBS})

foreach(LIB_TARGET ${ARROW_FLIGHT_SQL_ODBC_LIBRARIES})
target_compile_definitions(${LIB_TARGET} PRIVATE ARROW_FLIGHT_SQL_ODBC_EXPORTING)
Expand Down
29 changes: 17 additions & 12 deletions cpp/src/arrow/flight/sql/odbc/odbc_impl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# specific language governing permissions and limitations
# under the License.

add_library(arrow_odbc_spi_impl
add_library(arrow_odbc_spi_impl STATIC
accessors/binary_array_accessor.cc
accessors/binary_array_accessor.h
accessors/boolean_array_accessor.cc
Expand Down Expand Up @@ -133,8 +133,11 @@ endif()
if(APPLE)
target_include_directories(arrow_odbc_spi_impl SYSTEM BEFORE PUBLIC ${ODBC_INCLUDE_DIR})
target_link_libraries(arrow_odbc_spi_impl
PUBLIC arrow_flight_sql_shared arrow_compute_shared Boost::locale
iodbc)
PUBLIC arrow_flight_sql_static
arrow_compute_static
Boost::locale
Boost::headers
RapidJSON)
else()
find_package(ODBC REQUIRED)
target_include_directories(arrow_odbc_spi_impl PUBLIC ${ODBC_INCLUDE_DIR})
Expand All @@ -143,14 +146,6 @@ else()
${ODBCINST})
endif()

set_target_properties(arrow_odbc_spi_impl
PROPERTIES ARCHIVE_OUTPUT_DIRECTORY
${CMAKE_BINARY_DIR}/$<CONFIG>/lib
LIBRARY_OUTPUT_DIRECTORY
${CMAKE_BINARY_DIR}/$<CONFIG>/lib
RUNTIME_OUTPUT_DIRECTORY
${CMAKE_BINARY_DIR}/$<CONFIG>/lib)

# CLI
add_executable(arrow_odbc_spi_impl_cli main.cc)
set_target_properties(arrow_odbc_spi_impl_cli
Expand All @@ -159,6 +154,16 @@ set_target_properties(arrow_odbc_spi_impl_cli
target_link_libraries(arrow_odbc_spi_impl_cli arrow_odbc_spi_impl)

# Unit tests

# On Windows, dynamic linking ODBC is supported.
# On unix systems, static linking ODBC is supported, thus the library linking is static.
if(WIN32)
set(ODBC_SPI_IMPL_TEST_LINK_LIBS arrow_flight_testing_shared)
else()
# unix
set(ODBC_SPI_IMPL_TEST_LINK_LIBS arrow_flight_testing_static)
endif()

add_arrow_test(odbc_spi_impl_test
SOURCES
accessors/boolean_array_accessor_test.cc
Expand All @@ -177,4 +182,4 @@ add_arrow_test(odbc_spi_impl_test
util_test.cc
EXTRA_LINK_LIBS
arrow_odbc_spi_impl
arrow_flight_testing_shared)
${ODBC_SPI_IMPL_TEST_LINK_LIBS})
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

#include <string>

#include "config/configuration.h"
#include "arrow/flight/sql/odbc/odbc_impl/config/configuration.h"

namespace arrow::flight::sql::odbc {
namespace config {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// specific language governing permissions and limitations
// under the License.

#include "ui/add_property_window.h"
#include "arrow/flight/sql/odbc/odbc_impl/ui/add_property_window.h"

#include <Windowsx.h>

Expand All @@ -25,8 +25,8 @@
#include <commctrl.h>

#include "arrow/flight/sql/odbc/odbc_impl/exceptions.h"
#include "ui/custom_window.h"
#include "ui/window.h"
#include "arrow/flight/sql/odbc/odbc_impl/ui/custom_window.h"
#include "arrow/flight/sql/odbc/odbc_impl/ui/window.h"

namespace arrow::flight::sql::odbc {
namespace config {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#include <sstream>

#include "arrow/flight/sql/odbc/odbc_impl/exceptions.h"
#include "ui/custom_window.h"
#include "arrow/flight/sql/odbc/odbc_impl/ui/custom_window.h"

namespace arrow::flight::sql::odbc {
namespace config {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

#pragma once

#include "ui/window.h"
#include "arrow/flight/sql/odbc/odbc_impl/ui/window.h"

namespace arrow::flight::sql::odbc {
namespace config {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

#pragma once

#include "config/configuration.h"
#include "ui/custom_window.h"
#include "arrow/flight/sql/odbc/odbc_impl/config/configuration.h"
#include "arrow/flight/sql/odbc/odbc_impl/ui/custom_window.h"

namespace arrow::flight::sql::odbc {
namespace config {
Expand Down
66 changes: 47 additions & 19 deletions cpp/src/arrow/flight/sql/odbc/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,29 +25,57 @@ set(ARROW_FLIGHT_SQL_MOCK_SERVER_SRCS
../../example/sqlite_server.cc
../../example/sqlite_tables_schema_batch_reader.cc)

set(ARROW_FLIGHT_SQL_ODBC_TEST_SRCS
odbc_test_suite.cc
odbc_test_suite.h
columns_test.cc
connection_attr_test.cc
connection_info_test.cc
connection_test.cc
errors_test.cc
get_functions_test.cc
statement_attr_test.cc
statement_test.cc
tables_test.cc
type_info_test.cc
# Enable Protobuf cleanup after test execution
# GH-46889: move protobuf_test_util to a more common location
../../../../engine/substrait/protobuf_test_util.cc)

if(ARROW_TEST_LINKAGE STREQUAL "static")
set(ARROW_FLIGHT_SQL_ODBC_TEST_LINK_LIBS arrow_flight_sql_odbc_static
${ARROW_TEST_STATIC_LINK_LIBS})
else()
set(ARROW_FLIGHT_SQL_ODBC_TEST_LINK_LIBS arrow_flight_sql_odbc_shared
${ARROW_TEST_SHARED_LINK_LIBS})
Comment on lines +45 to +50
Copy link
Collaborator Author

@alinaliBQ alinaliBQ Mar 4, 2026

Choose a reason for hiding this comment

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

I needed to replace ARROW_TEST_LINK_LIBS with  ARROW_TEST_< STATIC  | SHARED >_LINK_LIBS here, because ARROW_TEST_LINK_LIBS  contains unneeded variables. I based my code change on here:

if(ARROW_TEST_LINKAGE STREQUAL "static")
set(ARROW_ACERO_TEST_LINK_LIBS arrow_acero_static ${ARROW_TEST_STATIC_LINK_LIBS})
else()
set(ARROW_ACERO_TEST_LINK_LIBS arrow_acero_shared ${ARROW_TEST_SHARED_LINK_LIBS})
endif()

endif()

set(ARROW_FLIGHT_SQL_ODBC_TEST_LIBS ${ODBC_LIBRARIES} ${ODBCINST} ${SQLite3_LIBRARIES})

# On Windows, dynamic linking ODBC is supported, tests link libraries dynamically.
# On unix systems, static linking ODBC is supported, thus tests link libraries statically.
set(ARROW_FLIGHT_SQL_ODBC_TEST_EXTRA_LINK_LIBS "")
set(ARROW_FLIGHT_SQL_ODBC_TEST_STATIC_LINK_LIBS "")
if(WIN32)
# arrow_odbc_spi_impl is required on Windows due to dynamic linking
list(APPEND ARROW_FLIGHT_SQL_ODBC_TEST_EXTRA_LINK_LIBS arrow_odbc_spi_impl
${ARROW_FLIGHT_SQL_ODBC_TEST_LIBS})
else()
# Unix
list(APPEND ARROW_FLIGHT_SQL_ODBC_TEST_STATIC_LINK_LIBS
${ARROW_FLIGHT_SQL_ODBC_TEST_LIBS} ${ARROW_FLIGHT_SQL_ODBC_TEST_LINK_LIBS})
endif()

add_arrow_test(flight_sql_odbc_test
SOURCES
odbc_test_suite.cc
odbc_test_suite.h
columns_test.cc
connection_attr_test.cc
connection_info_test.cc
connection_test.cc
errors_test.cc
get_functions_test.cc
statement_attr_test.cc
statement_test.cc
tables_test.cc
type_info_test.cc
# Enable Protobuf cleanup after test execution
# GH-46889: move protobuf_test_util to a more common location
../../../../engine/substrait/protobuf_test_util.cc
${ARROW_FLIGHT_SQL_ODBC_TEST_SRCS}
${ARROW_FLIGHT_SQL_MOCK_SERVER_SRCS}
DEFINITIONS
UNICODE
EXTRA_LINK_LIBS
${ODBC_LIBRARIES}
${ODBCINST}
${SQLite3_LIBRARIES}
arrow_odbc_spi_impl)
${ARROW_FLIGHT_SQL_ODBC_TEST_EXTRA_LINK_LIBS}
STATIC_LINK_LIBS
${ARROW_FLIGHT_SQL_ODBC_TEST_STATIC_LINK_LIBS})

find_package(ODBC REQUIRED)
target_link_libraries(arrow-flight-sql-odbc-test PRIVATE ODBC::ODBC)
Expand Down
10 changes: 5 additions & 5 deletions cpp/src/arrow/flight/sql/odbc/tests/errors_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -507,19 +507,19 @@ TYPED_TEST(ErrorsOdbcV2Test, TestSQLErrorStmtErrorODBCVer2) {
// When application passes buffer length greater than SQL_MAX_MESSAGE_LENGTH (512),
// DM passes 512 as buffer length to SQLError.

std::wstring wsql = L"1";
std::wstring wsql = L"SELECT * from non_existent_table;";
std::vector<SQLWCHAR> sql0(wsql.begin(), wsql.end());

ASSERT_EQ(SQL_ERROR,
SQLExecDirect(this->stmt, &sql0[0], static_cast<SQLINTEGER>(sql0.size())));

SQLWCHAR sql_state[6] = {0};
SQLINTEGER native_error = 0;
SQLWCHAR message[SQL_MAX_MESSAGE_LENGTH] = {0};
SQLSMALLINT message_length = 0;
ASSERT_EQ(SQL_SUCCESS, SQLError(nullptr, nullptr, this->stmt, sql_state, &native_error,
message, SQL_MAX_MESSAGE_LENGTH, &message_length));

SQLWCHAR message[SQL_MAX_MESSAGE_LENGTH] = {0};
ASSERT_EQ(SQL_SUCCESS,
SQLError(SQL_NULL_HENV, this->conn, this->stmt, sql_state, &native_error,
message, SQL_MAX_MESSAGE_LENGTH, &message_length));
EXPECT_GT(message_length, 70);

EXPECT_EQ(100, native_error);
Expand Down
Loading
Loading