Skip to content

Commit e6dfb52

Browse files
alinaliBQjusting-bq
authored andcommitted
Add Arrow Flight SQL ODBC driver
Co-authored-by: alinalibq <[email protected]> Co-authored-by: rscales <[email protected]> Co-authored-by: justing-bq <[email protected]> Co-authored-by: vic-tsang <[email protected]> ODBC commits squashed into 1 to make rebasing to main easier. Add initial framework for odbc dll - Add ARROW_FLIGHT_SQL_ODBC option. If we set `ARROW_FLIGHT_SQL_ODBC=ON`, the flightsql odbc folder will be built - Add odbc api layer for entry_point.cc - builds odbc dll file, with ODBC APIs exported in odbc.def Address James' comments Fix `odbcabstraction` build errors and partially fix `flightsql_odbc` errors Fix boost-variant not found error - Adding dependencies from odbc/vcpkg.json to cpp/vcpkg.json - Fix whereami.cc and .h dependency; ported lates code Update whereami.cc - use `long` instead of `int64`. Fixed namespace issues. - PR CI fix: Add `parquet-testing` back Partial build fix for `flight_sql` folder - Replaced `namespace arrow` and `namespace odbcabstraction` with `using namespace ...` - fix flight_sql_connection.cc Fix `util::nullopt` to use `std::nullopt` - fix std::optional - fix BufferReader - Fix GetSchema - fix json_converter.cc - partial fix configuration.h - partial fix get_info_cache.cc - Fix winsock build error - Comment out `flight_sql` files that cannot build - Comment out configuration and unit tests - Comment out get info cache and system trust store Create initial odbc tests folder Implement SQLAllocEnv Fix cmake build Implement SQLFreeEnv Fix rest of build errors from `flightsql-odbc` - Fix get info errors - Fix for configuration window - added odbcinst library - Fix system trust store - unit test fixes - Add dependency of ARROW_COMPUTE. `arrow/compute/api.h` is used in `flight_sql`. Adding `ARROW_COMPUTE=ON` during build fixed run time unit tests failures. Implement SQLAllocConnect and SQLFreeConnect Fix build issue from static flight sql driver Lint and code style fixes Re-add deleted submodule parquet-testing clang-format lint fix cpplint lint fix Exclude whereami in rat exclude list C++/CLI lint fix Update parquet-testing to match commit from `main` Address Kou's comments ODBC directory lint fixes Catching the lint fixes outside of `flightsql-odbc` code Fix build warnings that get treated as error Implement SQLSetEnvAttr and SQLGetEnvAttr Implement use of ExecuteWithDiagnostics Doxygen Error Fixes and Address comments from Kou and James Address comments from Kou - Updates License.txt - Update cmake toolchain - Move whereami to `vendored` - Use string_view instead of NOLINT std::string Remove `whereami.cc` from arrow util build We are building whereami.cc as part of odbc Fix include headers to replace <> with "" Address comments from James Implement SQLGetDiagField SQLDriverConnect, SQLConnect and SQLDisconnect Implement stubs for SQLGetInfo, SQLGetDiagField and SQLGetDiagRec Separate RegisterDsn and UnregisterDsn from windows build Update code to save driver value from connection string Add ReadMes for ODBC and tests Fix test issues with string_view Address code reviews Update entry_points.cc to fix build issue Remove Dremio references Use emplace properly Address comment from Rob and add SQLDisconnect test case Add odbc.def and cmd file to rat_exclude Nit - remove duplicate lines Accidentally committed the change during git rebase Nit - remove usage of nullptr DSN window implementation Add licenses to `.cmd` and `.def` files Implement SQLGetDiagRec Build ODBC in Windows Workflow Tests are skipped for now. Updates for SQLGetDiagFieldW Enable Driver Logging Add todo to update logging system later Add logs Implement ODBC API with debug logging Enable mock test * Add todo for noauth validation * mock server with token auth Add tests * run same test with both modes * Enable ODBC tests in workflow * Switch current test cases to use FlightSQLODBCTestBase So the tests can be skipped when `TEST_CONNECT_STR` is not set. * Change tests to run on both mock and remote modes Wrap usage of TEST_CONNECT_STR where possible * Rename test fixtures and make connection string functions virtual * Fix lint issue * Attempt to enable ODBC build on Windows platforms * Attempt to fix clang64 and MinGW errors * Attempt to register ODBC * Address James' comments Use constant string for token * use ServerMiddleware to validate token Fix connection issues to DBT Labs PopulateCallOptions before making a connection Fix dsn window bug with advance properties Fix seg fault issue from empty string Implement SQLAllocStmt Follow-up DBT Labs connection fix Implement SQLGetDiag Rec and Field for statement Unicode support for DSN ODBC APIs * Let compiler append `W` to ODBC APIs where applicable. Initialize Kernel functions As per changes from #46261, we need to initialize Kernel library explicitly to get the functions registered Implement SQLSetConnectAttr and SQLGetConnectAttr ODBC Test Segfault Fix * Move `connection_test.cc` to last in `CMakeLists.txt`, this resolves the seg fault. The seg fault was not reproducible on my local environment, even when I use the msys2 shell. * Rename test executable to flight_sql_odbc_test SQLExecDirect implementation * SQLGetStmtAttr stub implementation * Fix missing break statement in SQLGetDiagRec * Run ShutdownProtobufLibrary as part of test environment * Add comment for GH-46889 * Pass call options to executed prepared statement `call_options_` contains the authentication token which is needed Implement SQLGetInfo SQLGetInfo Workflow Fixes SQLFetch & SQLGetData Implementation SQLGetStmtAttr stub implementation Stub call for SQLGetStmtAttr Enable statement handle allocation Implement SQLExecDirect - test hang issue Update odbc_api.cc Run `ShutdownProtobufLibrary` after all ODBC tests Resolves test hanging problem Fix missing break statement in SQLGetDiagRec Add tests Lint fixes Run ShutdownProtobufLibrary as part of test environment Add debug messages Draft code Remove drafts Add comment Add comment for GH-46889 Update statement test headers Pass call options to executed prepared statement `call_options_` contains the authentication token which is needed SQLFetch & SQLGetData initial impl EVERYTHING before this commit is for SQLExecDirect SQLFetch and SQLGetData TestSQLExecDirectSimpleQuery test Make GetData() return SQLRETURN `TestSQLExecDirectDataQuery` for remote and mock servers Remove unneeded test case Add more data types * Add SQL_GUID in getCTypeForSQLType * Add data types in query * Add checks for columns 1 to 25 * Update statement_test.cc Add varbinary test * Implement SQLNumResultCols Will leave tests for later * Implement SQLRowCount * Implement SQLMoreResults * Work on date retrieval fix The `TestSQLExecDirectDataQuery` checks for date is not working. * Fix date retrieval error by importing fix from Paul * imported fix from dremio/flightsql-odbc@d44d862, an Apache-Licensed repository * Add more checks for get data * Add more tests * Continue work on float truncation test * Disable float truncation test * Address comments from James - do not return errors for invalid rowCountPtr and columnCountPtr - add static cast for columnCount - Add tests with SQL_C_DEFAULT as target type - Add test checks for indicator - Fix SQL_NUMERIC, SQL_BIT, SQL_FLOAT target type * Fix build issues in CI * More fix for CI * Add test for invalid buffer length SQLPrepare & SQLExecute Implementation * Add tests * Address comments from Rob Code Style fixes * Move ifdefs outside of test cases * use `stmt` * Move logs to first line * fix test for `SQL_DRIVER_HSTMT` * Use camel case for tests Implement SQLGetStmtAttr and SQLSetStmtAttr SQLBindCol Implementation * SQL_UNBIND implementation + tests * Add tests for `SQL_ATTR_ROW_ARRAY_SIZE` * Add check for `SQL_ATTR_ROWS_FETCHED_PTR` Enable TestCloseConnectionWithOpenStatement test case SQLFetchScroll Implementation * Add checks for SQL_ATTR_ROWS_FETCHED_PTR * SQLFetchScroll is supposed to return the number of rows fetched using SQL_ATTR_ROWS_FETCHED_PTR SQLExtendedFetch Implementation * Implement rowCountPtr and rowStatusArray for SQLExtendedFetch * Add tests for SQLExtendedFetch * `SQLExtendedFetch` doesn't return `SQL_SUCCESS_WITH_INFO` for error state 22002. * Add tests for `SQL_ROWSET_SIZE` * Address comments from James GH-46584 Iterate endpoint * use suggestion from James for one-liner change to return `Status::OK` directly * fix for iterating endpoints, it is based on JDBC's fix for the same bug * save value of `FlightClientOptions` * Use `TestFlightServer` Add `arrow_flight_sql_shared` to enable usages for `TestFlightServer` * Fix build errors from missing `gmock` * Add checks for array data Update flight_sql_stream_chunk_buffer_test.cc Add `FlightStreamChunkBufferTest` unit test Draft test with `FlightSQLODBCMockEndpointTestBase` * Reference GH-47117 and Clean up code * Add driver and DSN to built-in properties to not pass driver/dsn as attributes to server * Allow `=` in values inside connection strings, fixes connectivity problems * Address comments from Rob SQLColumns Implementation * Initial impl for SQLColumns * Add test for SQLColumns * Add columns test with all supported column types - mock server doesn't support schema * Address comments from James - Test different data type return value for SQLColumns - Add todo comment for SQLDescribeCol tests --------- Co-authored-by: rscales <[email protected]> Fix bug of DSN not read properly * Fix reading DSN bug Use a simpler, more robust way to load the DSN SQLColAttribute implementation * SQLColAttribute initial impl * Switch to use `GetAttributeSQLWCHAR` to be unicode-compatible * Add SQLColAttribute tests and fix bugs in `flightsql-odbc` impl * Fixed bug with incorrect column count. It was returning column count + 1. * Fixed bug with incorrect numPrecRadix. It was returning SQL_NO_TOTAL (maps to -4) for non-numeric columns, but the correct value is 0. * Fixed bug with unsigned column to return true for unsigned columns (non-numeric columns or unsigned numeric columns) and false for signed columns (numeric columns) * Fixed bug with incorrect non-concise data type return value for date time type types. The correct return is SQL_DATETIME for all date time types * Address comments from James * use const for `ConvertToWString` * add nullptr check in odbc_api.cc layer * Add support for `SQL_COLUMN_LENGTH`, `SQL_COLUMN_PRECISION`, and `SQL_COLUMN_SCALE`. The driver will return the same values for ODBC2 and ODBC3. * Add tests for ODBC v2 SQLColAttributes values * I converted tests that can be run on remote servers where possible * Address comment from Rob Implement SQLTables Use C++ 20 standard for ODBC * Add support for building with C++20 * Upgrade spdlogs version as an attempt to fix build issues * Fix issue of missing unique_ptr definition Add tests for SQLMoreResults Implement SQLNativeSql Add diagnostic records * remove `SQLErrors`, as the driver manager is supposed to map `SQLErrors` to `SQLGetDiagRec` Implement tests for SQLNumResultCols SQLCloseCursor Implementation * fix error state to return the correct state 24000. * add tests for SQLCloseCursor and SQLFreeStmt(SQL_CLOSE) Add SQLColumns and SQLColAttribute tests with nullptr * Modify SQLTables test to run on both mock and remote * reorder error msg alphabetically Implement tests for SQLRowCount Fix merge conflicts Adjust searchable return value based on GH-46920 fix Fix `getCTypeForSQLType` return for interval types - Fix `getCTypeForSQLType` function to return the correct `C type` for interval SQL data types. Previously the function was checking for interval `C type` and returning interval `SQL type`, which was the opposite of the intended functionality. SQLGetTypeInfo implementation * Add tests for SQLGetTypeInfo * fix bug of createParams returning empty string instead of null * fix bug of non-concise data type being returned for datetime/interval * fix bug of longvarchar not converted to wlongvarchar when driver has unicode enabled * Address comments from James and add checks * test SQL_ALL_TYPES in ODBC 2.x. * test SQL_TYPE_* in ODBC 2.x, the driver manager reports invalid data type error. * test SQL_* datetime in ODBC 3.x for backwards compatibility. * add check for valid/invalid data type. Fix segfault issue from empty metadata * Use empty map in bug fix * Address comments from James Implement SQLDescribeCol Add SQLError Tests * add test to free null handles. Without handle value initialization, segfault error was seen Move `SQLGetDiagField` and `SQLGetDiagRec` tests to `errors_test.cc` * Address comments from James * Add ODBC Ver 2 tests * update test name to indicate if error handling is from driver manager. * add tests for warnings. * fix lint errors. * remove SQL_ATTR_APP_ROW_DESC that is not applicable to Environment Attribute. Add tests for SQLGetFunctions * Using `SQL_FUNC_EXISTS` macro fixed the issue of `api_exists` not read correctly * Fix SQLGetTypeInfo naming for ODBC ver 2 tests * Add more tests Add unsupported API checks. Add `TestSQLGetFunctionsODBCVer2`. Add `TestSQLGetFunctionsCheckSingleAPI`. * Update reset value * Add SQLDescribeCol function check Add additional SQLDescribeCol test cases Add Descriptor support in SQLAllocHandle and SQLFreeHandle * Descriptor allocation initial impl * Add descriptor handle tests * Add diagnostic error test for descriptor handle * the error is from driver manager as our driver doesn't have descriptor-specific APIs implemented yet * Add SQLGetDescField test from driver manager * Add doxygen doc comment Fix connection issues servers that require data in handshake * revert back to passing empty string in handshake Fix bug of system trust store not loaded properly * Bug: system trust store has default value of "true" regardless of "encryption" value. * But if encryption is set to false, system trust store cannot be used, so system trust store should be saved as false if user does not enable encryption. * It may confuse the user if they see encryption is set to false but system trust store is set to true. In this case, the driver will not do system trust store verification. The DSN window should reflect this accurately. CPack ODBC Windows msi installer Add ARROW_FLIGHT_SQL_ODBC_INSTALLER environment variable to enable creation of Windows installer. * Use CPack + WiX to create a `msi` installer. * run command `cpack` under the build directory to generate the installer. Register ODBC Driver on Windows in installer * In `wxs`, cannot use `package`, need to use `fragment` instead * Use component as feature will automatically be generated * Set Patch version + add installer instructions Use Arrow logo banner * replaces default banner with Arrow logo banner Indicate Driver Company and Version on Driver Manager * use versioninfo.rc.in template * use `1 VERSIONINFO` for it to work properly * Set version variables * Add `.rc` to gitignore * Add `@` variables to rc template Return nameLengthPtr value as length in characters Allow spaces while parsing Table Type mac changes added changes to build in MacOS Enable ODBC build on Windows Glib & Ruby workflows * Fix `boost::get` issue on GLib workflow * Fix GLib build issue with conflicts Compile entry_points.cc before odbc_api.cc due to conflict from sql.h and flight/types.h. Fix build warnings treated as error on Windows SQLDescribeCol expects `bufCharLen` to be of type `SQLSMALLINT`, so build warnings occur when `bufCharLen` is set to `SQLINTEGER`. Add more types for Array Conversion Set column attribute SQL_DESC_TYPE_NAME [Refactor] Remove reference of `Configuration` in odbc_connection.cc Remove reference of `Configuration` in odbc_connection.cc which is in library `odbcabstraction`. The reasoning is that `Configuration` is in `arrow_odbc_spi_impl` and this is a library that `odbcabstraction` depends on. I moved the logic for reading DSN values into `odbc_api.cc` instead, since that is a place that will result in no conflicts. The ODBC driver now does not save the DSN value in the connection string if the DSN value is put after Driver value. * Address comments from James Simply logic to check for first key value pair only Add TODO for non-UTC time zone support * Currently, the driver only supports UTC time zone Replace `spdlogs` with Arrow's Internal Logging * Add logging README * register kernel function conditionally * Resolves errors of kernel function already registered Logging files are not supported since GLOG is not enabled on Windows in Arrow repo. We can work + test on log file support on macOS/Linux phase Remove `RUN_ALL_TESTS` as they are not needed Previously, tests on Windows were not being run due to #47434. So we added `RUN_ALL_TESTS` as a workaround in early May, before #47434 was raised. Now that #47434 is resolved, we can remove `RUN_ALL_TESTS` as they are not needed. Other changes: * Renamed `arrow_odbc_spi_impl_test` to `odbc_spi_impl_test` so the test executable will be `arrow_odbc_spi_impl_test.exe` instead of `arrow_arrow_odbc_spi_impl_test.exe` Fix Function & Variable Naming Fix member variable naming Address code review comments for Arrow#40939 * Reword comment on null check Addresses comment #40939 (comment) * Use `std::memcpy` instead of `memcpy` Addresses comment #40939 (comment) * add include cstring * Remove warpdrive mentions * Fix lint * Address Justin's comments Combine utils and define utils namespace Use arrow::flight::sql::odbc namespace Update namespaces driver::flight_sql and driver::odbcabstraction to arrow::flight::sql::odbc. Fix seg fault from register log PR to keep apache-odbc in sync with arrow main branch. I found that, if the driver registers logs before compute kernel registration, segfault somehow occurs at when register kernel function is being used. I am not sure the root cause, but registering the logs after compute kernel registration seems to resolve the issue. Refactor odbcabstraction and odbc_impl flight_sql is renamed to odbc_impl. The files inside odbcabstraction have been moved to odbc_impl and odbcabstraction is removed. Replace boost::variant with std::variant * Remove `boost-optional` and `boost-variant` dependencies from vcpkg.json * Replace boost::variant with std::variant Fix EXPECT_EQ() to have expected on the left and actual on the right Code style naming convention Remove underscores in test names Sync arrow_flight_testing changes from Arrow::main branch Fix test failure due to typo Fix `FlightSQLODBCRemoteTestBase.TestSQLExecDirectDataQueryDefaultType` test failure due to typo The precision should be 38 in the original code. I think it got changed to 0 by accident somewhere. Disable tests with `DISABLED_` * Enable `TestSQLGetInfoDriverHdesc` We missed this test before, enabling the test now * Disable tests with `DISABLED_` Fix test assertions Define Test Fixtures * Connect/disconnect in SetUp/TearDown * Define Test Fixtures Resolve ODBC CI Build Errors * Fix `ConfigDSNW` not found error * Fix `TestFreeNullHandles` test `ConnectionTest` sets up the handles, so the `this->...` handles will not be null at beginning of test. Define New Base Test Fixtures Skip tests without connecting/disconnecting Address general test code review comments * Use RAII helper for allocating and freeing env/conn handles Avoids duplicated code Move test helper functions to anonymous namespace Add `[[nodiscard]]` for ODBC APIs Addresses community comment: https://github.com/apache/arrow/pull/47763/files#r2450014186 Remove `using List=` in test suite definitions Use static_cast for `SQLWCHAR` in type info test Use static_cast for `SQLWCHAR` in tables test * use mutable arrays for places where characters cannot be const Use static_cast for `SQLWCHAR` in columns test Update comment Use static_cast for `SQLWCHAR` in SQLGetInfo test * Address Justin's comments * Add fix for skipping the allocation of handles ^ Conflicts: ^ .github/workflows/cpp.yml ^ cpp/src/arrow/flight/sql/odbc/odbc_api.cc ^ cpp/src/arrow/flight/sql/odbc/odbc_impl/attribute_utils.h ^ cpp/src/arrow/flight/sql/odbc/odbc_impl/config/configuration.cc ^ cpp/src/arrow/flight/sql/odbc/odbc_impl/config/configuration.h ^ cpp/src/arrow/flight/sql/odbc/odbc_impl/encoding_utils.h ^ cpp/src/arrow/flight/sql/odbc/odbc_impl/flight_sql_connection.cc ^ cpp/src/arrow/flight/sql/odbc/odbc_impl/flight_sql_connection_test.cc ^ cpp/src/arrow/flight/sql/odbc/odbc_impl/main.cc ^ cpp/src/arrow/flight/sql/odbc/odbc_impl/odbc_connection.cc ^ cpp/src/arrow/flight/sql/odbc/odbc_impl/odbc_connection.h ^ cpp/src/arrow/flight/sql/odbc/odbc_impl/spi/connection.h ^ cpp/src/arrow/flight/sql/odbc/odbc_impl/system_dsn.h ^ cpp/src/arrow/flight/sql/odbc/odbc_impl/ui/dsn_configuration_window.cc ^ cpp/src/arrow/flight/sql/odbc/odbc_impl/util.cc ^ cpp/src/arrow/flight/sql/odbc/odbc_impl/util.h ^ cpp/src/arrow/flight/sql/odbc/tests/connection_test.cc ^ cpp/src/arrow/flight/sql/odbc/tests/odbc_test_suite.cc
1 parent 398fc5a commit e6dfb52

File tree

102 files changed

+12427
-617
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

102 files changed

+12427
-617
lines changed

.github/workflows/cpp.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,8 @@ jobs:
310310
ARROW_DATASET: ON
311311
ARROW_FLIGHT: ON
312312
ARROW_FLIGHT_SQL: ON
313-
ARROW_FLIGHT_SQL_ODBC: OFF
313+
ARROW_FLIGHT_SQL_ODBC: ON
314+
ARROW_FLIGHT_SQL_ODBC_INSTALLER: ON
314315
ARROW_GANDIVA: ON
315316
ARROW_GCS: ON
316317
ARROW_HDFS: OFF

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ dependency-reduced-pom.xml
3232
MANIFEST
3333
compile_commands.json
3434
build.ninja
35+
build*/
3536

3637
# Generated Visual Studio files
3738
*.vcxproj
@@ -107,3 +108,6 @@ java/.mvn/.develocity/
107108
# rat
108109
filtered_rat.txt
109110
rat.txt
111+
112+
# rc
113+
*.rc

ci/scripts/cpp_build.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ else
213213
-DARROW_FLIGHT=${ARROW_FLIGHT:-OFF} \
214214
-DARROW_FLIGHT_SQL=${ARROW_FLIGHT_SQL:-OFF} \
215215
-DARROW_FLIGHT_SQL_ODBC=${ARROW_FLIGHT_SQL_ODBC:-OFF} \
216+
-DARROW_FLIGHT_SQL_ODBC_INSTALLER=${ARROW_FLIGHT_SQL_ODBC_INSTALLER:-OFF} \
216217
-DARROW_FUZZING=${ARROW_FUZZING:-OFF} \
217218
-DARROW_GANDIVA_PC_CXX_FLAGS=${ARROW_GANDIVA_PC_CXX_FLAGS:-} \
218219
-DARROW_GANDIVA=${ARROW_GANDIVA:-OFF} \

cpp/CMakeLists.txt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -720,9 +720,13 @@ endif()
720720

721721
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/../LICENSE.txt
722722
${CMAKE_CURRENT_SOURCE_DIR}/../NOTICE.txt
723-
${CMAKE_CURRENT_SOURCE_DIR}/README.md DESTINATION "${ARROW_DOC_DIR}")
723+
${CMAKE_CURRENT_SOURCE_DIR}/README.md
724+
DESTINATION "${ARROW_DOC_DIR}"
725+
COMPONENT arrow_doc)
724726

725-
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/gdb_arrow.py DESTINATION "${ARROW_GDB_DIR}")
727+
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/gdb_arrow.py
728+
DESTINATION "${ARROW_GDB_DIR}"
729+
COMPONENT arrow_gdb)
726730

727731
#
728732
# Validate and print out Arrow configuration options

cpp/CMakePresets.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@
180180
"ARROW_BUILD_EXAMPLES": "ON",
181181
"ARROW_BUILD_UTILITIES": "ON",
182182
"ARROW_FLIGHT_SQL_ODBC": "ON",
183+
"ARROW_FLIGHT_SQL_ODBC_INSTALLER": "ON",
183184
"ARROW_TENSORFLOW": "ON",
184185
"PARQUET_BUILD_EXAMPLES": "ON",
185186
"PARQUET_BUILD_EXECUTABLES": "ON"

cpp/cmake_modules/BuildUtils.cmake

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,10 +178,12 @@ function(arrow_install_cmake_package PACKAGE_NAME EXPORT_NAME)
178178
write_basic_package_version_file("${BUILT_CONFIG_VERSION_CMAKE}"
179179
COMPATIBILITY SameMajorVersion)
180180
install(FILES "${BUILT_CONFIG_CMAKE}" "${BUILT_CONFIG_VERSION_CMAKE}"
181-
DESTINATION "${ARROW_CMAKE_DIR}/${PACKAGE_NAME}")
181+
DESTINATION "${ARROW_CMAKE_DIR}/${PACKAGE_NAME}"
182+
COMPONENT config_cmake_file)
182183
set(TARGETS_CMAKE "${PACKAGE_NAME}Targets.cmake")
183184
install(EXPORT ${EXPORT_NAME}
184185
DESTINATION "${ARROW_CMAKE_DIR}/${PACKAGE_NAME}"
186+
COMPONENT config_cmake_export
185187
NAMESPACE "${PACKAGE_NAME}::"
186188
FILE "${TARGETS_CMAKE}")
187189
endfunction()
@@ -403,8 +405,11 @@ function(ADD_ARROW_LIB LIB_NAME)
403405
install(TARGETS ${LIB_NAME}_shared ${INSTALL_IS_OPTIONAL}
404406
EXPORT ${LIB_NAME}_targets
405407
ARCHIVE DESTINATION ${INSTALL_ARCHIVE_DIR}
408+
COMPONENT ${LIB_NAME}_shared_archive
406409
LIBRARY DESTINATION ${INSTALL_LIBRARY_DIR}
410+
COMPONENT ${LIB_NAME}_shared_library
407411
RUNTIME DESTINATION ${INSTALL_RUNTIME_DIR}
412+
COMPONENT ${LIB_NAME}_shared_runtime
408413
INCLUDES
409414
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
410415
endif()
@@ -471,8 +476,11 @@ function(ADD_ARROW_LIB LIB_NAME)
471476
install(TARGETS ${LIB_NAME}_static ${INSTALL_IS_OPTIONAL}
472477
EXPORT ${LIB_NAME}_targets
473478
ARCHIVE DESTINATION ${INSTALL_ARCHIVE_DIR}
479+
COMPONENT ${LIB_NAME}_static_library
474480
LIBRARY DESTINATION ${INSTALL_LIBRARY_DIR}
481+
COMPONENT ${LIB_NAME}_static_library
475482
RUNTIME DESTINATION ${INSTALL_RUNTIME_DIR}
483+
COMPONENT ${LIB_NAME}_static_library
476484
INCLUDES
477485
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
478486
endif()
@@ -934,7 +942,9 @@ function(ARROW_INSTALL_ALL_HEADERS PATH)
934942
endif()
935943
list(APPEND PUBLIC_HEADERS ${HEADER})
936944
endforeach()
937-
install(FILES ${PUBLIC_HEADERS} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${PATH}")
945+
install(FILES ${PUBLIC_HEADERS}
946+
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${PATH}"
947+
COMPONENT ${HEADER}_header)
938948
endfunction()
939949

940950
function(ARROW_ADD_PKG_CONFIG MODULE)
@@ -944,7 +954,8 @@ function(ARROW_ADD_PKG_CONFIG MODULE)
944954
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>/${MODULE}.pc"
945955
INPUT "${CMAKE_CURRENT_BINARY_DIR}/${MODULE}.pc.generate.in")
946956
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>/${MODULE}.pc"
947-
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig/")
957+
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig/"
958+
COMPONENT ${MODULE}_pkg_config)
948959
endfunction()
949960

950961
# Implementations of lisp "car" and "cdr" functions

cpp/cmake_modules/ThirdpartyToolchain.cmake

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,8 @@ function(provide_cmake_module MODULE_NAME ARROW_CMAKE_PACKAGE_NAME)
236236
message(STATUS "Providing CMake module for ${MODULE_NAME} as part of ${ARROW_CMAKE_PACKAGE_NAME} CMake package"
237237
)
238238
install(FILES "${module}"
239-
DESTINATION "${ARROW_CMAKE_DIR}/${ARROW_CMAKE_PACKAGE_NAME}")
239+
DESTINATION "${ARROW_CMAKE_DIR}/${ARROW_CMAKE_PACKAGE_NAME}"
240+
COMPONENT ${MODULE_NAME}_module)
240241
endif()
241242
endfunction()
242243

@@ -2397,20 +2398,22 @@ function(build_gtest)
23972398
endforeach()
23982399
install(DIRECTORY "${googletest_SOURCE_DIR}/googlemock/include/"
23992400
"${googletest_SOURCE_DIR}/googletest/include/"
2400-
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
2401+
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
2402+
COMPONENT gtest_dir)
24012403
add_library(arrow::GTest::gtest_headers INTERFACE IMPORTED)
24022404
target_include_directories(arrow::GTest::gtest_headers
24032405
INTERFACE "${googletest_SOURCE_DIR}/googlemock/include/"
24042406
"${googletest_SOURCE_DIR}/googletest/include/")
24052407
install(TARGETS gmock gmock_main gtest gtest_main
24062408
EXPORT arrow_testing_targets
2407-
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
2408-
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
2409-
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}")
2409+
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" COMPONENT gtest_runtime
2410+
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT gtest_archive
2411+
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT gtest_library)
24102412
if(MSVC)
24112413
install(FILES $<TARGET_PDB_FILE:gmock> $<TARGET_PDB_FILE:gmock_main>
24122414
$<TARGET_PDB_FILE:gtest> $<TARGET_PDB_FILE:gtest_main>
24132415
DESTINATION "${CMAKE_INSTALL_BINDIR}"
2416+
COMPONENT gtest_pdb
24142417
OPTIONAL)
24152418
endif()
24162419
add_library(arrow::GTest::gmock ALIAS gmock)

cpp/src/arrow/CMakeLists.txt

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,8 @@ string(REPLACE "${CMAKE_BINARY_DIR}" "<CMAKE_BINARY_DIR>" REDACTED_CXX_FLAGS
349349
configure_file("util/config.h.cmake" "util/config.h" ESCAPE_QUOTES)
350350
configure_file("util/config_internal.h.cmake" "util/config_internal.h" ESCAPE_QUOTES)
351351
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/util/config.h"
352-
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/arrow/util")
352+
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/arrow/util"
353+
COMPONENT arrow_config)
353354

354355
set(ARROW_SRCS
355356
builder.cc
@@ -1044,7 +1045,8 @@ if(ARROW_BUILD_BUNDLED_DEPENDENCIES)
10441045
get_target_property(arrow_bundled_dependencies_path arrow_bundled_dependencies
10451046
IMPORTED_LOCATION)
10461047
install(FILES ${arrow_bundled_dependencies_path} ${INSTALL_IS_OPTIONAL}
1047-
DESTINATION ${CMAKE_INSTALL_LIBDIR})
1048+
DESTINATION ${CMAKE_INSTALL_LIBDIR}
1049+
COMPONENT arrow_bundled_dependencies)
10481050
string(PREPEND ARROW_PC_LIBS_PRIVATE " -larrow_bundled_dependencies")
10491051
list(INSERT ARROW_STATIC_INSTALL_INTERFACE_LIBS 0 "Arrow::arrow_bundled_dependencies")
10501052
endif()
@@ -1161,6 +1163,7 @@ if(ARROW_BUILD_SHARED AND NOT WIN32)
11611163
if(ARROW_GDB_AUTO_LOAD_LIBARROW_GDB_INSTALL)
11621164
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libarrow_gdb.py"
11631165
DESTINATION "${ARROW_GDB_AUTO_LOAD_LIBARROW_GDB_DIR}"
1166+
COMPONENT arrow_gdb
11641167
RENAME "$<TARGET_FILE_NAME:arrow_shared>-gdb.py")
11651168
endif()
11661169
endif()
@@ -1224,11 +1227,13 @@ arrow_install_all_headers("arrow")
12241227

12251228
config_summary_cmake_setters("${CMAKE_CURRENT_BINARY_DIR}/ArrowOptions.cmake")
12261229
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/ArrowOptions.cmake
1227-
DESTINATION "${ARROW_CMAKE_DIR}/Arrow")
1230+
DESTINATION "${ARROW_CMAKE_DIR}/Arrow"
1231+
COMPONENT arrow_options_cmake)
12281232

12291233
# For backward compatibility for find_package(arrow)
12301234
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/arrow-config.cmake
1231-
DESTINATION "${ARROW_CMAKE_DIR}/Arrow")
1235+
DESTINATION "${ARROW_CMAKE_DIR}/Arrow"
1236+
COMPONENT arrow_config_cmake)
12321237

12331238
#
12341239
# Unit tests

cpp/src/arrow/flight/sql/column_metadata.cc

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,15 @@ const char* ColumnMetadata::kIsSearchable = "ARROW:FLIGHT:SQL:IS_SEARCHABLE";
5858
const char* ColumnMetadata::kRemarks = "ARROW:FLIGHT:SQL:REMARKS";
5959

6060
ColumnMetadata::ColumnMetadata(
61-
std::shared_ptr<const arrow::KeyValueMetadata> metadata_map)
62-
: metadata_map_(std::move(metadata_map)) {}
61+
std::shared_ptr<const arrow::KeyValueMetadata> metadata_map) {
62+
if (metadata_map) {
63+
metadata_map_ = std::move(metadata_map);
64+
} else {
65+
std::shared_ptr<const arrow::KeyValueMetadata> empty_metadata_map(
66+
new arrow::KeyValueMetadata);
67+
metadata_map_ = std::move(empty_metadata_map);
68+
}
69+
}
6370

6471
arrow::Result<std::string> ColumnMetadata::GetCatalogName() const {
6572
return metadata_map_->Get(kCatalogName);

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

Lines changed: 94 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,29 @@ add_subdirectory(tests)
3838

3939
arrow_install_all_headers("arrow/flight/sql/odbc")
4040

41-
set(ARROW_FLIGHT_SQL_ODBC_SRCS entry_points.cc odbc_api.cc)
41+
# ODBC Release information
42+
set(ODBC_PACKAGE_VERSION_MAJOR "1")
43+
set(ODBC_PACKAGE_VERSION_MINOR "0")
44+
set(ODBC_PACKAGE_VERSION_PATCH "0")
45+
set(ODBC_PACKAGE_NAME "Apache Arrow Flight SQL ODBC")
46+
set(ODBC_PACKAGE_VENDOR "Apache Arrow")
47+
48+
# Compile entry_points.cc before odbc_api.cc due to conflict from sql.h and flight/types.h
49+
set(ARROW_FLIGHT_SQL_ODBC_SRCS odbc_api.cc entry_points.cc)
4250

4351
if(WIN32)
44-
list(APPEND ARROW_FLIGHT_SQL_ODBC_SRCS odbc.def)
52+
set(VER_FILEVERSION
53+
"${ODBC_PACKAGE_VERSION_MAJOR},${ODBC_PACKAGE_VERSION_MINOR},${ODBC_PACKAGE_VERSION_PATCH},0"
54+
)
55+
set(VER_FILEVERSION_STR
56+
${ODBC_PACKAGE_VERSION_MAJOR}.${ODBC_PACKAGE_VERSION_MINOR}.${ODBC_PACKAGE_VERSION_PATCH}
57+
)
58+
set(VER_COMPANYNAME_STR ${ODBC_PACKAGE_VENDOR})
59+
set(VER_PRODUCTNAME_STR ${ODBC_PACKAGE_NAME})
60+
61+
configure_file("install/versioninfo.rc.in" "install/versioninfo.rc" @ONLY)
62+
63+
list(APPEND ARROW_FLIGHT_SQL_ODBC_SRCS odbc.def install/versioninfo.rc)
4564
endif()
4665

4766
add_arrow_lib(arrow_flight_sql_odbc
@@ -75,3 +94,76 @@ add_arrow_lib(arrow_flight_sql_odbc
7594
foreach(LIB_TARGET ${ARROW_FLIGHT_SQL_ODBC_LIBRARIES})
7695
target_compile_definitions(${LIB_TARGET} PRIVATE ARROW_FLIGHT_SQL_ODBC_EXPORTING)
7796
endforeach()
97+
98+
# Construct ODBC Windows installer. Only Release installer is supported
99+
if(ARROW_FLIGHT_SQL_ODBC_INSTALLER)
100+
101+
include(InstallRequiredSystemLibraries)
102+
103+
set(CPACK_RESOURCE_FILE_LICENSE
104+
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../LICENSE.txt")
105+
# Tentative version 1.0.0
106+
set(CPACK_PACKAGE_VERSION_MAJOR ${ODBC_PACKAGE_VERSION_MAJOR})
107+
set(CPACK_PACKAGE_VERSION_MINOR ${ODBC_PACKAGE_VERSION_MINOR})
108+
set(CPACK_PACKAGE_VERSION_PATCH ${ODBC_PACKAGE_VERSION_PATCH})
109+
110+
set(CPACK_PACKAGE_NAME ${ODBC_PACKAGE_NAME})
111+
set(CPACK_PACKAGE_VENDOR ${ODBC_PACKAGE_VENDOR})
112+
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Apache Arrow Flight SQL ODBC Driver")
113+
set(CPACK_PACKAGE_CONTACT "#GH-47787 TODO arrow maintainers")
114+
115+
# GH-47876 TODO: set up `flight_sql_odbc_lib` component for macOS Installer
116+
# GH-47877 TODO: set up `flight_sql_odbc_lib` component for Linux Installer
117+
if(WIN32)
118+
install(DIRECTORY "${BUILD_OUTPUT_ROOT_DIRECTORY}${CMAKE_BUILD_TYPE}/"
119+
DESTINATION bin
120+
COMPONENT flight_sql_odbc_lib
121+
FILES_MATCHING
122+
# Use regex for dll name patterns with versions
123+
PATTERN "abseil_dll.dll"
124+
PATTERN "arrow.dll"
125+
PATTERN "arrow_compute.dll"
126+
PATTERN "arrow_flight.dll"
127+
PATTERN "arrow_flight_sql.dll"
128+
PATTERN "arrow_flight_sql_odbc.dll"
129+
PATTERN "boost_locale*.dll"
130+
PATTERN "cares.dll"
131+
PATTERN "libcrypto*.dll"
132+
PATTERN "libprotobuf.dll"
133+
PATTERN "libssl*.dll"
134+
PATTERN "re2.dll"
135+
PATTERN "utf8proc.dll"
136+
PATTERN "zlib1.dll")
137+
138+
set(CPACK_WIX_EXTRA_SOURCES
139+
"${CMAKE_CURRENT_SOURCE_DIR}/install/arrow-flight-sql-odbc.wxs")
140+
set(CPACK_WIX_PATCH_FILE
141+
"${CMAKE_CURRENT_SOURCE_DIR}/install/arrow-flight-sql-odbc-patch.xml")
142+
143+
set(CPACK_WIX_UI_BANNER "${CMAKE_CURRENT_SOURCE_DIR}/install/arrow-wix-banner.bmp")
144+
endif()
145+
146+
get_cmake_property(CPACK_COMPONENTS_ALL COMPONENTS)
147+
set(CPACK_COMPONENTS_ALL Unspecified)
148+
list(APPEND CPACK_COMPONENTS_ALL "flight_sql_odbc_lib")
149+
150+
if(WIN32)
151+
# WiX msi installer on Windows
152+
# CPack is compatible with WiX V.5 and V.6
153+
set(CPACK_GENERATOR "WIX")
154+
set(CPACK_WIX_VERSION 4)
155+
156+
# Upgrade GUID is required to be unchanged for ODBC installer to upgrade
157+
set(CPACK_WIX_UPGRADE_GUID "DBF27A18-F8BF-423F-9E3A-957414D52C4B")
158+
set(CPACK_WIX_PRODUCT_GUID "279D087B-93B5-4DC3-BA69-BCF485022A26")
159+
endif()
160+
# GH-47876 TODO: create macOS Installer using cpack
161+
# GH-47877 TODO: create Linux Installer using cpack
162+
163+
# Load CPack after all CPACK* variables are set
164+
include(CPack)
165+
cpack_add_component(flight_sql_odbc_lib
166+
DISPLAY_NAME "ODBC library"
167+
DESCRIPTION "ODBC library bin, required to install"
168+
REQUIRED)
169+
endif()

0 commit comments

Comments
 (0)