Skip to content

Commit c58bfe5

Browse files
authored
GH-48312: [C++][FlightRPC] Standalone ODBC MSVC CI (#48313)
### Rationale for this change #48312 ### What changes are included in this PR? - Add new ODBC workflow for Windows MSVC - Added build fixes to enable build on MSVC CI ### Are these changes tested? Tested in CI ### Are there any user-facing changes? N/A * GitHub Issue: #48312 Authored-by: Alina (Xi) Li <[email protected]> Signed-off-by: Sutou Kouhei <[email protected]>
1 parent 97ea97c commit c58bfe5

File tree

8 files changed

+124
-12
lines changed

8 files changed

+124
-12
lines changed

.github/workflows/cpp_extra.yml

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,12 +330,119 @@ jobs:
330330
cd cpp/examples/minimal_build
331331
../minimal_build.build/arrow-example
332332
333+
odbc:
334+
needs: check-labels
335+
name: ODBC
336+
runs-on: windows-2022
337+
if: >-
338+
needs.check-labels.outputs.force == 'true' ||
339+
contains(fromJSON(needs.check-labels.outputs.ci-extra-labels || '[]'), 'CI: Extra') ||
340+
contains(fromJSON(needs.check-labels.outputs.ci-extra-labels || '[]'), 'CI: Extra: C++')
341+
timeout-minutes: 240
342+
env:
343+
ARROW_BUILD_SHARED: ON
344+
ARROW_BUILD_STATIC: OFF
345+
ARROW_BUILD_TESTS: ON
346+
ARROW_BUILD_TYPE: release
347+
ARROW_DEPENDENCY_SOURCE: VCPKG
348+
ARROW_FLIGHT_SQL_ODBC: ON
349+
ARROW_SIMD_LEVEL: AVX2
350+
CMAKE_CXX_STANDARD: "17"
351+
CMAKE_GENERATOR: Ninja
352+
CMAKE_INSTALL_PREFIX: /usr
353+
VCPKG_BINARY_SOURCES: 'clear;nuget,GitHub,readwrite'
354+
VCPKG_DEFAULT_TRIPLET: x64-windows
355+
steps:
356+
- name: Disable Crash Dialogs
357+
run: |
358+
reg add `
359+
"HKCU\SOFTWARE\Microsoft\Windows\Windows Error Reporting" `
360+
/v DontShowUI `
361+
/t REG_DWORD `
362+
/d 1 `
363+
/f
364+
- name: Checkout Arrow
365+
uses: actions/checkout@v6
366+
with:
367+
fetch-depth: 0
368+
submodules: recursive
369+
- name: Download Timezone Database
370+
shell: bash
371+
run: ci/scripts/download_tz_database.sh
372+
- name: Install cmake
373+
shell: bash
374+
run: |
375+
ci/scripts/install_cmake.sh 4.1.2 /usr
376+
- name: Install ccache
377+
shell: bash
378+
run: |
379+
ci/scripts/install_ccache.sh 4.12.1 /usr
380+
- name: Setup ccache
381+
shell: bash
382+
run: |
383+
ci/scripts/ccache_setup.sh
384+
- name: ccache info
385+
id: ccache-info
386+
shell: bash
387+
run: |
388+
echo "cache-dir=$(ccache --get-config cache_dir)" >> $GITHUB_OUTPUT
389+
- name: Cache ccache
390+
uses: actions/cache@v4
391+
with:
392+
path: ${{ steps.ccache-info.outputs.cache-dir }}
393+
key: cpp-odbc-ccache-windows-x64-${{ hashFiles('cpp/**') }}
394+
restore-keys: cpp-odbc-ccache-windows-x64-
395+
- name: Checkout vcpkg
396+
uses: actions/checkout@v6
397+
with:
398+
fetch-depth: 0
399+
path: vcpkg
400+
repository: microsoft/vcpkg
401+
- name: Bootstrap vcpkg
402+
run: |
403+
vcpkg\bootstrap-vcpkg.bat
404+
$VCPKG_ROOT = $(Resolve-Path -LiteralPath "vcpkg").ToString()
405+
Write-Output ${VCPKG_ROOT} | `
406+
Out-File -FilePath ${Env:GITHUB_PATH} -Encoding utf8 -Append
407+
Write-Output "VCPKG_ROOT=${VCPKG_ROOT}" | `
408+
Out-File -FilePath ${Env:GITHUB_ENV} -Encoding utf8 -Append
409+
- name: Setup NuGet credentials for vcpkg caching
410+
shell: bash
411+
run: |
412+
$(vcpkg fetch nuget | tail -n 1) \
413+
sources add \
414+
-source "https://nuget.pkg.github.com/$GITHUB_REPOSITORY_OWNER/index.json" \
415+
-storepasswordincleartext \
416+
-name "GitHub" \
417+
-username "$GITHUB_REPOSITORY_OWNER" \
418+
-password "${{ secrets.GITHUB_TOKEN }}"
419+
$(vcpkg fetch nuget | tail -n 1) \
420+
setapikey "${{ secrets.GITHUB_TOKEN }}" \
421+
-source "https://nuget.pkg.github.com/$GITHUB_REPOSITORY_OWNER/index.json"
422+
- name: Build
423+
shell: cmd
424+
run: |
425+
set VCPKG_ROOT_KEEP=%VCPKG_ROOT%
426+
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64
427+
set VCPKG_ROOT=%VCPKG_ROOT_KEEP%
428+
bash -c "ci/scripts/cpp_build.sh $(pwd) $(pwd)/build"
429+
- name: Register Flight SQL ODBC Driver
430+
shell: cmd
431+
run: |
432+
call "cpp\src\arrow\flight\sql\odbc\tests\install_odbc.cmd" ${{ github.workspace }}\build\cpp\%ARROW_BUILD_TYPE%\arrow_flight_sql_odbc.dll
433+
# GH-48270 TODO: Resolve segementation fault during Arrow library unload
434+
# GH-48269 TODO: Enable Flight & Flight SQL testing in MSVC CI
435+
# GH-48547 TODO: enable ODBC tests after GH-48270 and GH-48269 are resolved.
436+
437+
# GH-47787 TODO: Build ODBC installer
438+
333439
report-extra-cpp:
334440
if: github.event_name == 'schedule' && always()
335441
needs:
336442
- docker
337443
- jni-linux
338444
- jni-macos
339445
- msvc-arm64
446+
- odbc
340447
uses: ./.github/workflows/report_ci.yml
341448
secrets: inherit

ci/scripts/cpp_test.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,8 @@ if [ "${ARROW_USE_MESON:-OFF}" = "OFF" ] && \
145145
;;
146146
esac
147147
if [ -n "${VCPKG_ROOT}" ] && [ -n "${VCPKG_DEFAULT_TRIPLET}" ]; then
148-
CMAKE_PREFIX_PATH+=";${VCPKG_ROOT}/installed/${VCPKG_DEFAULT_TRIPLET}"
148+
# Search vcpkg before <prefix>/lib/cmake.
149+
CMAKE_PREFIX_PATH="${VCPKG_ROOT}/installed/${VCPKG_DEFAULT_TRIPLET};${CMAKE_PREFIX_PATH}"
149150
fi
150151
cmake \
151152
-S "${source_dir}/examples/minimal_build" \

cpp/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -520,8 +520,6 @@ endif()
520520
set(PARQUET_PC_REQUIRES "")
521521
set(PARQUET_PC_REQUIRES_PRIVATE "")
522522

523-
include(ThirdpartyToolchain)
524-
525523
# Add common flags
526524
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CXX_COMMON_FLAGS}")
527525
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ARROW_CXXFLAGS}")
@@ -536,6 +534,8 @@ string(REPLACE "-std=c++17" "" CMAKE_C_FLAGS ${CMAKE_C_FLAGS})
536534
# Add C++-only flags, like -std=c++17
537535
set(CMAKE_CXX_FLAGS "${CXX_ONLY_FLAGS} ${CMAKE_CXX_FLAGS}")
538536

537+
include(ThirdpartyToolchain)
538+
539539
# ASAN / TSAN / UBSAN
540540
if(ARROW_FUZZING)
541541
set(ARROW_USE_COVERAGE ON)

cpp/src/arrow/flight/sql/odbc/odbc_impl/CMakeLists.txt

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -129,13 +129,9 @@ if(WIN32)
129129
system_dsn.h)
130130
endif()
131131

132-
target_link_libraries(arrow_odbc_spi_impl PUBLIC arrow_flight_sql_shared
133-
arrow_compute_shared Boost::locale)
134-
135-
# Link libraries on MINGW64 and macOS
136-
if(MINGW OR APPLE)
137-
target_link_libraries(arrow_odbc_spi_impl PUBLIC ${ODBCINST})
138-
endif()
132+
target_link_libraries(arrow_odbc_spi_impl
133+
PUBLIC arrow_flight_sql_shared arrow_compute_shared Boost::locale
134+
${ODBCINST})
139135

140136
set_target_properties(arrow_odbc_spi_impl
141137
PROPERTIES ARCHIVE_OUTPUT_DIRECTORY

cpp/src/arrow/flight/sql/odbc/odbc_impl/get_info_cache.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919

2020
#include "arrow/flight/sql/odbc/odbc_impl/platform.h"
2121

22-
#include <sql.h>
23-
#include <sqlext.h>
2422
#include "arrow/array.h"
2523
#include "arrow/array/array_nested.h"
2624
#include "arrow/flight/sql/api.h"
@@ -32,6 +30,10 @@
3230
#include "arrow/flight/sql/odbc/odbc_impl/scalar_function_reporter.h"
3331
#include "arrow/flight/sql/odbc/odbc_impl/util.h"
3432

33+
// Include ODBC headers after arrow headers to avoid conflicts with sql_info_undef.h
34+
#include <sql.h>
35+
#include <sqlext.h>
36+
3537
// Aliases for entries in SqlInfoOptions::SqlInfo that are defined here
3638
// due to causing compilation errors conflicting with ODBC definitions.
3739
#define ARROW_SQL_IDENTIFIER_CASE 503

cpp/src/arrow/flight/sql/odbc/odbc_impl/odbc_connection.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include "arrow/flight/sql/odbc/odbc_impl/spi/statement.h"
3030
#include "arrow/flight/sql/odbc/odbc_impl/util.h"
3131

32+
// Include ODBC headers after arrow headers to avoid conflicts with sql_info_undef.h
3233
#include <odbcinst.h>
3334
#include <sql.h>
3435
#include <sqlext.h>

cpp/src/arrow/flight/sql/odbc/tests/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,6 @@ add_arrow_test(flight_sql_odbc_test
5151
${ODBCINST}
5252
${SQLite3_LIBRARIES}
5353
arrow_odbc_spi_impl)
54+
55+
# Disable unity build due to sqlite_sql_info.cc conflict with sql.h and sqlext.h headers.
56+
set_target_properties(arrow-flight-sql-odbc-test PROPERTIES UNITY_BUILD OFF)

cpp/src/arrow/flight/sql/odbc/tests/odbc_test_suite.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
// specific language governing permissions and limitations
1616
// under the License.
1717

18+
#pragma once
19+
1820
#include "arrow/testing/gtest_util.h"
1921
#include "arrow/util/io_util.h"
2022
#include "arrow/util/utf8.h"

0 commit comments

Comments
 (0)