Skip to content

Commit 9bb0603

Browse files
alinaliBQjusting-bqvic-tsang
committed
Enable ODBC build in MacOS CI
Co-Authored-By: justing-bq <justin.gossett@improving.com> Co-Authored-By: Victor Tsang <victor.tsang@improving.com> Co-Authored-By: Alina (Xi) Li <alina.li@improving.com>
1 parent 5de6aa6 commit 9bb0603

File tree

12 files changed

+57
-11
lines changed

12 files changed

+57
-11
lines changed

ci/scripts/cpp_build.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ else
259259
-DCMAKE_BUILD_TYPE=${ARROW_BUILD_TYPE:-debug} \
260260
-DCMAKE_VERBOSE_MAKEFILE=${CMAKE_VERBOSE_MAKEFILE:-OFF} \
261261
-DCMAKE_C_FLAGS="${CFLAGS:-}" \
262-
-DCMAKE_CXX_FLAGS="${CXXFLAGS:-}" \
262+
-DCMAKE_CXX_FLAGS="${CXXFLAGS:-} -I${ODBC_INCLUDE_DIR:-} -L${ODBC_LIB_DIR:-}" \
263263
-DCMAKE_CXX_STANDARD="${CMAKE_CXX_STANDARD:-17}" \
264264
-DCMAKE_INSTALL_LIBDIR=${CMAKE_INSTALL_LIBDIR:-lib} \
265265
-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX:-${ARROW_HOME}} \
@@ -270,6 +270,7 @@ else
270270
-DgRPC_SOURCE=${gRPC_SOURCE:-} \
271271
-DGTest_SOURCE=${GTest_SOURCE:-} \
272272
-Dlz4_SOURCE=${lz4_SOURCE:-} \
273+
-DODBC_INCLUDE_DIR="${ODBC_INCLUDE_DIR:-}" \
273274
-Dopentelemetry-cpp_SOURCE=${opentelemetry_cpp_SOURCE:-} \
274275
-DORC_SOURCE=${ORC_SOURCE:-} \
275276
-DPARQUET_BUILD_EXAMPLES=${PARQUET_BUILD_EXAMPLES:-OFF} \

ci/scripts/cpp_test.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ case "$(uname)" in
6161
n_jobs=$(sysctl -n hw.ncpu)
6262
# TODO: https://github.com/apache/arrow/issues/40410
6363
exclude_tests+=("arrow-s3fs-test")
64+
exclude_tests+=("arrow-flight-sql-odbc-test")
6465
;;
6566
MINGW*)
6667
n_jobs=${NUMBER_OF_PROCESSORS:-1}

cpp/Brewfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ brew "git"
2828
brew "glog"
2929
brew "googletest"
3030
brew "grpc"
31+
brew "libiodbc"
3132
brew "llvm"
3233
brew "lz4"
3334
brew "mimalloc"

cpp/CMakePresets.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,17 @@
314314
"displayName": "Debug build with tests and Flight SQL",
315315
"cacheVariables": {}
316316
},
317+
{
318+
"name": "ninja-debug-flight-sql-odbc",
319+
"inherits": [
320+
"features-flight-sql",
321+
"base-debug"
322+
],
323+
"displayName": "Debug build with tests and Flight SQL ODBC",
324+
"cacheVariables": {
325+
"ARROW_FLIGHT_SQL_ODBC": "ON"
326+
}
327+
},
317328
{
318329
"name": "ninja-debug-gandiva",
319330
"inherits": [
@@ -510,6 +521,17 @@
510521
"displayName": "Release build with Flight SQL",
511522
"cacheVariables": {}
512523
},
524+
{
525+
"name": "ninja-release-flight-sql-odbc",
526+
"inherits": [
527+
"features-flight-sql",
528+
"base-release"
529+
],
530+
"displayName": "Release build with Flight SQL ODBC",
531+
"cacheVariables": {
532+
"ARROW_FLIGHT_SQL_ODBC": "ON"
533+
}
534+
},
513535
{
514536
"name": "ninja-release-gandiva",
515537
"inherits": [

cpp/cmake_modules/DefineOptions.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@ macro(tsort_bool_option_dependencies)
107107
endmacro()
108108

109109
macro(resolve_option_dependencies)
110-
# Arrow Flight SQL ODBC is available only for Windows for now.
111-
if(NOT WIN32)
110+
# Arrow Flight SQL ODBC is available only for Windows and macOS for now.
111+
if(NOT WIN32 AND NOT APPLE)
112112
set(ARROW_FLIGHT_SQL_ODBC OFF)
113113
endif()
114114
if(MSVC_TOOLCHAIN)

cpp/src/arrow/flight/sql/odbc/odbc_api.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -855,7 +855,7 @@ SQLRETURN SQLDriverConnect(SQLHDBC conn, SQLHWND window_handle,
855855
}
856856
#else
857857
// Attempt connection without loading DSN window on macOS/Linux
858-
connection->Connect(dsn, properties, missing_properties);
858+
connection->Connect(dsn_value, properties, missing_properties);
859859
#endif
860860
// Copy connection string to out_connection_string after connection attempt
861861
return ODBC::GetStringAttribute(true, connection_string, false, out_connection_string,

cpp/src/arrow/flight/sql/odbc/odbc_impl/odbc_handle.h

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,18 @@ class ODBCHandle {
4646
try {
4747
GetDiagnostics().Clear();
4848
rc = function();
49-
} catch (const arrow::flight::sql::odbc::DriverException& ex) {
49+
} catch (const arrow::flight::sql::odbc::AuthenticationException& ex) {
50+
GetDiagnostics().AddError(arrow::flight::sql::odbc::DriverException(
51+
ex.GetMessageText(), ex.GetSqlState(), ex.GetNativeError()));
52+
} catch (const arrow::flight::sql::odbc::NullWithoutIndicatorException& ex) {
53+
GetDiagnostics().AddError(arrow::flight::sql::odbc::DriverException(
54+
ex.GetMessageText(), ex.GetSqlState(), ex.GetNativeError()));
55+
}
56+
// on mac, DriverException doesn't catch the subclass exceptions hence we added
57+
// the following above.
58+
// GH-48278 TODO investigate if there is a way to catch all the subclass exceptions under
59+
// DriverException
60+
catch (const arrow::flight::sql::odbc::DriverException& ex) {
5061
GetDiagnostics().AddError(ex);
5162
} catch (const std::bad_alloc&) {
5263
GetDiagnostics().AddError(arrow::flight::sql::odbc::DriverException(

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,11 @@
1717

1818
add_custom_target(tests)
1919

20-
find_package(ODBC REQUIRED)
21-
include_directories(${ODBC_INCLUDE_DIRS})
20+
if(WIN32)
21+
include_directories(${ODBC_INCLUDE_DIRS})
22+
else()
23+
include_directories(${ODBC_INCLUDE_DIR})
24+
endif()
2225

2326
find_package(SQLite3Alt REQUIRED)
2427

cpp/src/arrow/flight/sql/odbc/tests/connection_test.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ TEST_F(ConnectionRemoteTest, TestSQLDriverConnectInvalidUid) {
442442
arrow::util::UTF8ToWideString(connect_str));
443443
std::vector<SQLWCHAR> connect_str0(wconnect_str.begin(), wconnect_str.end());
444444

445-
SQLWCHAR out_str[kOdbcBufferSize];
445+
SQLWCHAR out_str[kOdbcBufferSize] = {0};
446446
SQLSMALLINT out_str_len;
447447

448448
// Connecting to ODBC server.

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,9 @@ std::wstring ODBCRemoteTestBase::GetQueryAllDataTypes() {
130130
CAST(true AS BOOLEAN) AS bit_true,
131131
132132
--Character types
133-
'Z' AS c_char, '你' AS c_wchar,
133+
'Z' AS c_char, _utf8'你' AS c_wchar,
134134
135-
'你好' AS c_wvarchar,
135+
_utf8'你好' AS c_wvarchar,
136136
137137
'XYZ' AS c_varchar,
138138
@@ -245,7 +245,7 @@ std::string ODBCMockTestBase::GetConnectionString() {
245245
std::string connect_str(
246246
"driver={Apache Arrow Flight SQL ODBC Driver};HOST=localhost;port=" +
247247
std::to_string(port) + ";token=" + std::string(kTestToken) +
248-
";useEncryption=false;");
248+
";useEncryption=false;UseWideChar=true;");
249249
return connect_str;
250250
}
251251

0 commit comments

Comments
 (0)