From c61d81bf7e1488bfef2155b820762ff82e748ba2 Mon Sep 17 00:00:00 2001 From: "Alina (Xi) Li" Date: Mon, 26 May 2025 16:20:18 -0700 Subject: [PATCH] Build ODBC in Windows Workflow Tests are skipped for now. --- .github/workflows/cpp.yml | 2 +- ci/scripts/cpp_build.sh | 2 ++ ci/scripts/cpp_test.sh | 2 ++ cpp/cmake_modules/ThirdpartyToolchain.cmake | 2 +- cpp/src/arrow/flight/sql/odbc/CMakeLists.txt | 5 +++++ cpp/src/arrow/flight/sql/odbc/flight_sql/CMakeLists.txt | 8 +++++--- .../flight_sql/accessors/string_array_accessor_test.cc | 1 - cpp/src/arrow/flight/sql/odbc/flight_sql/address_info.h | 1 + .../arrow/flight/sql/odbc/flight_sql/system_trust_store.h | 3 +++ .../arrow/flight/sql/odbc/flight_sql/ui/custom_window.cc | 5 +++-- .../arrow/flight/sql/odbc/odbcabstraction/CMakeLists.txt | 3 --- 11 files changed, 23 insertions(+), 11 deletions(-) diff --git a/.github/workflows/cpp.yml b/.github/workflows/cpp.yml index 4bf162d7b1a..8c4388fc0f9 100644 --- a/.github/workflows/cpp.yml +++ b/.github/workflows/cpp.yml @@ -375,7 +375,7 @@ jobs: windows-mingw: name: AMD64 Windows MinGW ${{ matrix.msystem_upper }} C++ - runs-on: windows-2019 + runs-on: windows-2022 if: ${{ !contains(github.event.pull_request.title, 'WIP') }} # Build may take 1h+ without cache. timeout-minutes: 120 diff --git a/ci/scripts/cpp_build.sh b/ci/scripts/cpp_build.sh index 8b0d6deaaf1..cdf53c413df 100755 --- a/ci/scripts/cpp_build.sh +++ b/ci/scripts/cpp_build.sh @@ -64,6 +64,7 @@ if [ "${ARROW_ENABLE_THREADING:-ON}" = "OFF" ]; then ARROW_AZURE=OFF ARROW_FLIGHT=OFF ARROW_FLIGHT_SQL=OFF + ARROW_FLIGHT_SQL_ODBC=OFF ARROW_GCS=OFF ARROW_JEMALLOC=OFF ARROW_MIMALLOC=OFF @@ -206,6 +207,7 @@ else -DARROW_FILESYSTEM=${ARROW_FILESYSTEM:-ON} \ -DARROW_FLIGHT=${ARROW_FLIGHT:-OFF} \ -DARROW_FLIGHT_SQL=${ARROW_FLIGHT_SQL:-OFF} \ + -DARROW_FLIGHT_SQL_ODBC=${ARROW_FLIGHT_SQL_ODBC:-OFF} \ -DARROW_FUZZING=${ARROW_FUZZING:-OFF} \ -DARROW_GANDIVA_PC_CXX_FLAGS=${ARROW_GANDIVA_PC_CXX_FLAGS:-} \ -DARROW_GANDIVA=${ARROW_GANDIVA:-OFF} \ diff --git a/ci/scripts/cpp_test.sh b/ci/scripts/cpp_test.sh index 36e09e8936f..fd81cefe48d 100755 --- a/ci/scripts/cpp_test.sh +++ b/ci/scripts/cpp_test.sh @@ -73,6 +73,8 @@ case "$(uname)" in exclude_tests="${exclude_tests}|gandiva-precompiled-test" exclude_tests="${exclude_tests}|gandiva-projector-test" exclude_tests="${exclude_tests}|gandiva-utf8-test" + # TODO: Enable ODBC tests + exclude_tests="${exclude_tests}|arrow-connection-test" ctest_options+=(--exclude-regex "${exclude_tests}") ;; *) diff --git a/cpp/cmake_modules/ThirdpartyToolchain.cmake b/cpp/cmake_modules/ThirdpartyToolchain.cmake index e2180223701..8b88d21786e 100644 --- a/cpp/cmake_modules/ThirdpartyToolchain.cmake +++ b/cpp/cmake_modules/ThirdpartyToolchain.cmake @@ -1283,7 +1283,7 @@ if(ARROW_USE_BOOST) endif() if(ARROW_BOOST_REQUIRE_LIBRARY) set(ARROW_BOOST_COMPONENTS filesystem system) - if(ARROW_FLIGHT_SQL_ODBC AND MSVC) + if(ARROW_FLIGHT_SQL_ODBC) list(APPEND ARROW_BOOST_COMPONENTS locale) endif() set(ARROW_BOOST_OPTIONAL_COMPONENTS process) diff --git a/cpp/src/arrow/flight/sql/odbc/CMakeLists.txt b/cpp/src/arrow/flight/sql/odbc/CMakeLists.txt index 1f7c5d1f61f..449db0fedf4 100644 --- a/cpp/src/arrow/flight/sql/odbc/CMakeLists.txt +++ b/cpp/src/arrow/flight/sql/odbc/CMakeLists.txt @@ -17,9 +17,14 @@ add_custom_target(arrow_flight_sql_odbc) +# Ensure fmt is loaded as header only +add_compile_definitions(FMT_HEADER_ONLY) + 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) diff --git a/cpp/src/arrow/flight/sql/odbc/flight_sql/CMakeLists.txt b/cpp/src/arrow/flight/sql/odbc/flight_sql/CMakeLists.txt index 6985f781b9a..e9f282e91f9 100644 --- a/cpp/src/arrow/flight/sql/odbc/flight_sql/CMakeLists.txt +++ b/cpp/src/arrow/flight/sql/odbc/flight_sql/CMakeLists.txt @@ -101,10 +101,12 @@ if(WIN32) win_system_dsn.cc) endif() -target_link_libraries(arrow_odbc_spi_impl PUBLIC odbcabstraction arrow_flight_sql_shared) +target_link_libraries(arrow_odbc_spi_impl PUBLIC odbcabstraction arrow_flight_sql_shared + Boost::locale) -if(MSVC) - target_link_libraries(arrow_odbc_spi_impl PUBLIC Boost::locale) +# Link libraries on MINGW64 only +if(MINGW AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + target_link_libraries(arrow_odbc_spi_impl PUBLIC ${ODBCINST}) endif() set_target_properties(arrow_odbc_spi_impl diff --git a/cpp/src/arrow/flight/sql/odbc/flight_sql/accessors/string_array_accessor_test.cc b/cpp/src/arrow/flight/sql/odbc/flight_sql/accessors/string_array_accessor_test.cc index 8b568bbffcf..587e7d5eb1c 100644 --- a/cpp/src/arrow/flight/sql/odbc/flight_sql/accessors/string_array_accessor_test.cc +++ b/cpp/src/arrow/flight/sql/odbc/flight_sql/accessors/string_array_accessor_test.cc @@ -134,7 +134,6 @@ TEST(StringArrayAccessor, Test_CDataType_WCHAR_Truncation) { ColumnBinding binding(odbcabstraction::CDataType_WCHAR, 0, 0, buffer.data(), max_strlen, strlen_buffer.data()); - std::basic_stringstream ss; int64_t value_offset = 0; // Construct the whole string by concatenating smaller chunks from diff --git a/cpp/src/arrow/flight/sql/odbc/flight_sql/address_info.h b/cpp/src/arrow/flight/sql/odbc/flight_sql/address_info.h index 312d5689a98..2609abd6af7 100644 --- a/cpp/src/arrow/flight/sql/odbc/flight_sql/address_info.h +++ b/cpp/src/arrow/flight/sql/odbc/flight_sql/address_info.h @@ -21,6 +21,7 @@ #include #include +#include #if !_WIN32 # include #endif diff --git a/cpp/src/arrow/flight/sql/odbc/flight_sql/system_trust_store.h b/cpp/src/arrow/flight/sql/odbc/flight_sql/system_trust_store.h index 71175b09709..f8e02fea526 100644 --- a/cpp/src/arrow/flight/sql/odbc/flight_sql/system_trust_store.h +++ b/cpp/src/arrow/flight/sql/odbc/flight_sql/system_trust_store.h @@ -24,6 +24,9 @@ # include # include + +# include + # include # include diff --git a/cpp/src/arrow/flight/sql/odbc/flight_sql/ui/custom_window.cc b/cpp/src/arrow/flight/sql/odbc/flight_sql/ui/custom_window.cc index e79e1221e78..8f660a21329 100644 --- a/cpp/src/arrow/flight/sql/odbc/flight_sql/ui/custom_window.cc +++ b/cpp/src/arrow/flight/sql/odbc/flight_sql/ui/custom_window.cc @@ -23,6 +23,7 @@ #include #include +#include #include #include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/exceptions.h" @@ -53,7 +54,7 @@ LRESULT CALLBACK CustomWindow::WndProc(HWND hwnd, UINT msg, WPARAM wParam, switch (msg) { case WM_NCCREATE: { - _ASSERT(lParam != NULL); + assert(lParam != NULL); CREATESTRUCT* createStruct = reinterpret_cast(lParam); @@ -65,7 +66,7 @@ LRESULT CALLBACK CustomWindow::WndProc(HWND hwnd, UINT msg, WPARAM wParam, } case WM_CREATE: { - _ASSERT(window != NULL); + assert(window != NULL); window->SetHandle(hwnd); diff --git a/cpp/src/arrow/flight/sql/odbc/odbcabstraction/CMakeLists.txt b/cpp/src/arrow/flight/sql/odbc/odbcabstraction/CMakeLists.txt index c9614b88a5b..e1e52492648 100644 --- a/cpp/src/arrow/flight/sql/odbc/odbcabstraction/CMakeLists.txt +++ b/cpp/src/arrow/flight/sql/odbc/odbcabstraction/CMakeLists.txt @@ -17,9 +17,6 @@ include_directories(include) -# Ensure fmt is loaded as header only -add_compile_definitions(FMT_HEADER_ONLY) - add_library(odbcabstraction include/odbcabstraction/calendar_utils.h include/odbcabstraction/diagnostics.h