Skip to content

Commit b7ab6e7

Browse files
committed
Merge remote-tracking branch 'upstream/main' into crossbow-pygithub-migration
2 parents f18c3a8 + 16fe342 commit b7ab6e7

10 files changed

Lines changed: 148 additions & 81 deletions

File tree

ci/scripts/cpp_test.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ if ! type minio >/dev/null 2>&1; then
5555
fi
5656
case "$(uname)" in
5757
Linux)
58-
exclude_tests+=("arrow-flight-sql-odbc-test")
5958
n_jobs=$(nproc)
6059
;;
6160
Darwin)

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

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ TYPED_TEST_SUITE(ColumnsOdbcV2Test, TestTypesOdbcV2);
4646

4747
namespace {
4848
// Helper functions
49+
50+
// GH-49702: TODO Disabled on Linux due to BlockingQueue issue
51+
#ifndef __linux__
4952
void CheckSQLColumns(
5053
SQLHSTMT stmt, const std::wstring& expected_table,
5154
const std::wstring& expected_column, const SQLINTEGER& expected_data_type,
@@ -125,6 +128,7 @@ void CheckRemoteSQLColumns(
125128
expected_octet_char_length, expected_ordinal_position,
126129
expected_is_nullable);
127130
}
131+
#endif // __linux__
128132

129133
void CheckSQLColAttribute(SQLHSTMT stmt, SQLUSMALLINT idx,
130134
const std::string& expected_column_name,
@@ -416,6 +420,8 @@ TYPED_TEST(ColumnsTest, SQLColumnsTestInputData) {
416420
ValidateFetch(this->stmt, SQL_SUCCESS);
417421
}
418422

423+
// GH-49702: TODO Disabled on Linux due to BlockingQueue issue
424+
#ifndef __linux__
419425
TEST_F(ColumnsMockTest, TestSQLColumnsAllColumns) {
420426
// Check table pattern and column pattern returns all columns
421427

@@ -1210,6 +1216,7 @@ TEST_F(ColumnsMockTest, TestSQLColumnsTableColumnPattern) {
12101216
// There is no more column
12111217
EXPECT_EQ(SQL_NO_DATA, SQLFetch(this->stmt));
12121218
}
1219+
#endif // __linux__
12131220

12141221
TEST_F(ColumnsMockTest, TestSQLColumnsInvalidTablePattern) {
12151222
ASSIGN_SQLWCHAR_ARR(table_pattern, L"non-existent-table");
@@ -2560,10 +2567,6 @@ TEST_F(ColumnsMockTest, SQLDescribeColUnicodeTableMetadata) {
25602567

25612568
ASSIGN_SQLWCHAR_ARR_AND_LEN(sql_query, L"SELECT * from 数据 LIMIT 1;");
25622569

2563-
ASSIGN_SQLWCHAR_ARR_AND_LEN(expected_column_name, L"资料");
2564-
SQLSMALLINT expected_column_data_type = SQL_WVARCHAR;
2565-
SQLULEN expected_column_size = 0;
2566-
25672570
ASSERT_EQ(SQL_SUCCESS, SQLExecDirect(this->stmt, sql_query, sql_query_len));
25682571

25692572
ASSERT_EQ(SQL_SUCCESS, SQLFetch(this->stmt));
@@ -2572,13 +2575,14 @@ TEST_F(ColumnsMockTest, SQLDescribeColUnicodeTableMetadata) {
25722575
buf_char_len, &name_length, &column_data_type,
25732576
&column_size, &decimal_digits, &nullable));
25742577

2575-
EXPECT_EQ(name_length, expected_column_name_len);
2578+
std::wstring expected_column_name_wstr = std::wstring(L"资料");
2579+
size_t expected_column_name_len = expected_column_name_wstr.length();
25762580

25772581
std::wstring returned(column_name, column_name + name_length);
2578-
std::wstring expected_col_name_str = ConvertToWString(expected_column_name);
2579-
EXPECT_EQ(expected_col_name_str, returned);
2580-
EXPECT_EQ(expected_column_data_type, column_data_type);
2581-
EXPECT_EQ(expected_column_size, column_size);
2582+
EXPECT_EQ(expected_column_name_wstr, returned);
2583+
EXPECT_EQ(expected_column_name_len, name_length);
2584+
EXPECT_EQ(SQL_WVARCHAR, column_data_type);
2585+
EXPECT_EQ(0, column_size);
25822586
EXPECT_EQ(0, decimal_digits);
25832587
EXPECT_EQ(SQL_NULLABLE, nullable);
25842588

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

Lines changed: 52 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,13 @@ using TestTypes =
3333
::testing::Types<FlightSQLODBCMockTestBase, FlightSQLODBCRemoteTestBase>;
3434
TYPED_TEST_SUITE(ConnectionAttributeTest, TestTypes);
3535

36+
template <typename T>
37+
class ConnectionAttributePreConnectTest : public T {};
38+
39+
using TestTypesHandle = ::testing::Types<FlightSQLOdbcEnvConnHandleMockTestBase,
40+
FlightSQLOdbcEnvConnHandleRemoteTestBase>;
41+
TYPED_TEST_SUITE(ConnectionAttributePreConnectTest, TestTypesHandle);
42+
3643
#ifdef SQL_ATTR_ASYNC_DBC_EVENT
3744
TYPED_TEST(ConnectionAttributeTest, TestSQLSetConnectAttrAsyncDbcEventUnsupported) {
3845
ASSERT_EQ(SQL_ERROR, SQLSetConnectAttr(this->conn, SQL_ATTR_ASYNC_DBC_EVENT, 0, 0));
@@ -117,31 +124,32 @@ TYPED_TEST(ConnectionAttributeTest, TestSQLSetConnectAttrTraceDMOnly) {
117124
}
118125
#endif // __APPLE__
119126

120-
TYPED_TEST(ConnectionAttributeTest, TestSQLSetConnectAttrTracefileDMOnly) {
127+
TYPED_TEST(ConnectionAttributePreConnectTest, TestSQLSetConnectAttrTracefileDMOnly) {
121128
// Verify DM-only attribute is handled by Driver Manager
122129

123-
// Use placeholder value as we want the call to fail, or else
124-
// the driver manager will produce a trace file.
125-
std::wstring trace_file = L"invalid/file/path";
126-
std::vector<SQLWCHAR> trace_file0(trace_file.begin(), trace_file.end());
127-
ASSERT_EQ(SQL_ERROR, SQLSetConnectAttr(this->conn, SQL_ATTR_TRACEFILE, &trace_file0[0],
128-
static_cast<SQLINTEGER>(trace_file0.size())));
129-
#ifdef __APPLE__
130-
VerifyOdbcErrorState(SQL_HANDLE_DBC, this->conn, kErrorStateHYC00);
131-
#else
130+
// Use placeholder value to avoid the driver manager producing a trace file.
131+
ASSIGN_SQLWCHAR_ARR_AND_LEN(trace_file, L"invalid/file/path");
132+
133+
SQLRETURN rc =
134+
SQLSetConnectAttr(this->conn, SQL_ATTR_TRACEFILE, trace_file, trace_file_len);
135+
136+
#ifdef _WIN32
137+
ASSERT_EQ(SQL_ERROR, rc);
132138
VerifyOdbcErrorState(SQL_HANDLE_DBC, this->conn, kErrorStateHY000);
133-
#endif // __APPLE__
139+
#else // Mac & Linux
140+
ASSERT_EQ(SQL_SUCCESS, rc);
141+
#endif
134142
}
135143

136144
TYPED_TEST(ConnectionAttributeTest, TestSQLSetConnectAttrTranslateLabDMOnly) {
137145
// Verify DM-only attribute is handled by Driver Manager
138146
ASSERT_EQ(SQL_ERROR, SQLSetConnectAttr(this->conn, SQL_ATTR_TRANSLATE_LIB, 0, 0));
139147
// Checks for invalid argument return error
140-
#ifdef __APPLE__
141-
VerifyOdbcErrorState(SQL_HANDLE_DBC, this->conn, kErrorStateHYC00);
142-
#else
148+
#ifdef _WIN32
143149
VerifyOdbcErrorState(SQL_HANDLE_DBC, this->conn, kErrorStateHY024);
144-
#endif // __APPLE__
150+
#else // Mac & Linux
151+
VerifyOdbcErrorState(SQL_HANDLE_DBC, this->conn, kErrorStateHYC00);
152+
#endif
145153
}
146154

147155
TYPED_TEST(ConnectionAttributeTest, TestSQLSetConnectAttrTranslateOptionUnsupported) {
@@ -166,8 +174,8 @@ TYPED_TEST(ConnectionAttributeTest, TestSQLGetConnectAttrDbcInfoTokenSetOnly) {
166174
}
167175
#endif
168176

169-
// iODBC does not treat SQL_ATTR_ODBC_CURSORS as DM-only
170-
#ifndef __APPLE__
177+
// Driver Manager behavior tests for Windows only.
178+
#ifdef _WIN32
171179
TYPED_TEST(ConnectionAttributeTest, TestSQLGetConnectAttrOdbcCursorsDMOnly) {
172180
// Verify that DM-only attribute is handled by driver manager
173181
SQLULEN cursor_attr;
@@ -176,7 +184,6 @@ TYPED_TEST(ConnectionAttributeTest, TestSQLGetConnectAttrOdbcCursorsDMOnly) {
176184
EXPECT_EQ(SQL_CUR_USE_DRIVER, cursor_attr);
177185
}
178186

179-
// iODBC needs to be compiled with tracing enabled to handle SQL_ATTR_TRACE
180187
TYPED_TEST(ConnectionAttributeTest, TestSQLGetConnectAttrTraceDMOnly) {
181188
// Verify that DM-only attribute is handled by driver manager
182189
SQLUINTEGER trace;
@@ -185,7 +192,6 @@ TYPED_TEST(ConnectionAttributeTest, TestSQLGetConnectAttrTraceDMOnly) {
185192
EXPECT_EQ(SQL_OPT_TRACE_OFF, trace);
186193
}
187194

188-
// iODBC needs to be compiled with tracing enabled to handle SQL_ATTR_TRACEFILE
189195
TYPED_TEST(ConnectionAttributeTest, TestSQLGetConnectAttrTraceFileDMOnly) {
190196
// Verify that DM-only attribute is handled by driver manager
191197
SQLWCHAR out_str[kOdbcBufferSize];
@@ -199,7 +205,7 @@ TYPED_TEST(ConnectionAttributeTest, TestSQLGetConnectAttrTraceFileDMOnly) {
199205
ODBC::SqlWcharToString(out_str, static_cast<SQLSMALLINT>(out_str_len));
200206
EXPECT_FALSE(out_connection_string.empty());
201207
}
202-
#endif // __APPLE__
208+
#endif // _WIN32
203209

204210
TYPED_TEST(ConnectionAttributeTest, TestSQLGetConnectAttrTranslateLibUnsupported) {
205211
SQLWCHAR out_str[kOdbcBufferSize];
@@ -226,11 +232,17 @@ TYPED_TEST(ConnectionAttributeTest, TestSQLGetConnectAttrTxnIsolationUnsupported
226232
#ifdef SQL_ATTR_ASYNC_DBC_FUNCTIONS_ENABLE
227233
TYPED_TEST(ConnectionAttributeTest,
228234
TestSQLGetConnectAttrAsyncDbcFunctionsEnableUnsupported) {
229-
// Verifies that the Windows driver manager returns HY114 for unsupported functionality
230235
SQLUINTEGER enable;
236+
# ifdef _WIN32
237+
// Verifies that the Windows driver manager returns HY114 for unsupported functionality
231238
ASSERT_EQ(SQL_ERROR, SQLGetConnectAttr(this->conn, SQL_ATTR_ASYNC_DBC_FUNCTIONS_ENABLE,
232239
&enable, 0, 0));
233240
VerifyOdbcErrorState(SQL_HANDLE_DBC, this->conn, kErrorStateHY114);
241+
# else // Mac & Linux
242+
ASSERT_EQ(
243+
SQL_SUCCESS,
244+
SQLGetConnectAttr(this->conn, SQL_ATTR_ASYNC_DBC_FUNCTIONS_ENABLE, &enable, 0, 0));
245+
# endif
234246
}
235247
#endif
236248

@@ -357,14 +369,24 @@ TYPED_TEST(ConnectionAttributeTest, TestSQLSetConnectAttrLoginTimeoutValid) {
357369
EXPECT_EQ(42, timeout);
358370
}
359371

372+
#ifdef __linux__
373+
// On Linux, SQL_ATTR_PACKET_SIZE can only be set before connection
374+
// which is why use a different test fixture for Linux.
375+
TYPED_TEST(ConnectionAttributePreConnectTest, TestSQLSetConnectAttrPacketSizeValid) {
376+
#else // Windows & Mac
360377
TYPED_TEST(ConnectionAttributeTest, TestSQLSetConnectAttrPacketSizeValid) {
361-
// The driver always returns 0. PACKET_SIZE value is unused by the driver.
362-
378+
#endif
363379
// Check default value first
364380
SQLUINTEGER size = -1;
381+
#ifdef __linux__
382+
ASSERT_EQ(SQL_ERROR,
383+
SQLGetConnectAttr(this->conn, SQL_ATTR_PACKET_SIZE, &size, 0, nullptr));
384+
VerifyOdbcErrorState(SQL_HANDLE_DBC, this->conn, kErrorState08003);
385+
#else // Windows & Mac
365386
ASSERT_EQ(SQL_SUCCESS,
366387
SQLGetConnectAttr(this->conn, SQL_ATTR_PACKET_SIZE, &size, 0, nullptr));
367388
EXPECT_EQ(0, size);
389+
#endif
368390

369391
ASSERT_EQ(SQL_SUCCESS, SQLSetConnectAttr(this->conn, SQL_ATTR_PACKET_SIZE,
370392
reinterpret_cast<SQLPOINTER>(0), 0));
@@ -374,12 +396,18 @@ TYPED_TEST(ConnectionAttributeTest, TestSQLSetConnectAttrPacketSizeValid) {
374396
SQLGetConnectAttr(this->conn, SQL_ATTR_PACKET_SIZE, &size, 0, nullptr));
375397
EXPECT_EQ(0, size);
376398

377-
// Attempt to set to non-zero value, driver should return warning and not error
399+
// Attempt to set to non-zero value,
400+
#ifdef __linux__
401+
EXPECT_EQ(SQL_SUCCESS, SQLSetConnectAttr(this->conn, SQL_ATTR_PACKET_SIZE,
402+
reinterpret_cast<SQLPOINTER>(2), 0));
403+
#else // Windows & Mac
404+
// driver should return warning and not error
378405
EXPECT_EQ(SQL_SUCCESS_WITH_INFO, SQLSetConnectAttr(this->conn, SQL_ATTR_PACKET_SIZE,
379406
reinterpret_cast<SQLPOINTER>(2), 0));
380407

381408
// Verify warning status
382409
VerifyOdbcErrorState(SQL_HANDLE_DBC, this->conn, kErrorState01S02);
410+
#endif
383411
}
384412

385413
} // namespace arrow::flight::sql::odbc

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

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,9 @@ TYPED_TEST(ConnectionInfoTest, TestSQLGetInfoDataSourceName) {
143143
}
144144

145145
#ifdef SQL_DRIVER_AWARE_POOLING_SUPPORTED
146+
// GH-49782: TODO Disabled on Linux until SQL_DRIVER_AWARE_POOLING_SUPPORTED is
147+
// implemented in the driver.
148+
# ifndef __linux__
146149
TYPED_TEST(ConnectionInfoTest, TestSQLGetInfoDriverAwarePoolingSupported) {
147150
// According to Microsoft documentation, ODBC driver does not need to implement
148151
// SQL_DRIVER_AWARE_POOLING_SUPPORTED and the Driver Manager will ignore the
@@ -153,7 +156,8 @@ TYPED_TEST(ConnectionInfoTest, TestSQLGetInfoDriverAwarePoolingSupported) {
153156

154157
EXPECT_EQ(static_cast<SQLUINTEGER>(SQL_DRIVER_AWARE_POOLING_NOT_CAPABLE), value);
155158
}
156-
#endif
159+
# endif // __linux__
160+
#endif // SQL_DRIVER_AWARE_POOLING_SUPPORTED
157161

158162
// These information types are implemented by the Driver Manager alone.
159163
TYPED_TEST(ConnectionInfoTest, TestSQLGetInfoDriverHdbc) {
@@ -331,11 +335,13 @@ TYPED_TEST(ConnectionInfoTest, TestSQLGetInfoOdbcVer) {
331335

332336
std::wstring result = ConvertToWString(value);
333337

334-
#ifdef __APPLE__
338+
#if defined(__APPLE__)
335339
EXPECT_EQ(std::wstring(L"03.52.0000"), result);
336-
#else
340+
#elif defined(__linux__)
341+
EXPECT_EQ(std::wstring(L"03.52"), result);
342+
#else // WINDOWS
337343
EXPECT_EQ(std::wstring(L"03.80.0000"), result);
338-
#endif // __APPLE__
344+
#endif
339345
}
340346

341347
TYPED_TEST(ConnectionInfoTest, TestSQLGetInfoParamArrayRowCounts) {

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

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -313,15 +313,20 @@ TYPED_TEST(ErrorsTest, TestSQLGetDiagRecInputData) {
313313
EXPECT_EQ(SQL_NO_DATA, SQLGetDiagRec(SQL_HANDLE_DBC, this->conn, 1, nullptr, nullptr,
314314
nullptr, 0, nullptr));
315315

316-
// Invalid handle
317316
#ifdef __APPLE__
318317
// MacOS ODBC driver manager requires connection handle
319318
EXPECT_EQ(SQL_INVALID_HANDLE,
320319
SQLGetDiagRec(0, this->conn, 1, nullptr, nullptr, nullptr, 0, nullptr));
321320
#else
322-
EXPECT_EQ(SQL_INVALID_HANDLE,
321+
// Linux & Windows driver managers have different expected return values
322+
# ifdef __linux__
323+
SQLRETURN expected_rc = SQL_ERROR;
324+
# else // Windows
325+
SQLRETURN expected_rc = SQL_INVALID_HANDLE;
326+
# endif
327+
EXPECT_EQ(expected_rc,
323328
SQLGetDiagRec(0, nullptr, 0, nullptr, nullptr, nullptr, 0, nullptr));
324-
#endif // __APPLE__
329+
#endif
325330
}
326331

327332
TYPED_TEST(ErrorsOdbcV2Test, TestSQLErrorInputData) {
@@ -491,13 +496,13 @@ TYPED_TEST(ErrorsOdbcV2Test, TestSQLErrorEnvErrorFromDriverManager) {
491496
EXPECT_EQ(0, native_error);
492497

493498
// Function sequence error state from driver manager
494-
#ifdef _WIN32
495-
// Windows Driver Manager returns S1010
496-
EXPECT_EQ(kErrorStateS1010, SqlWcharToString(sql_state));
497-
#else
498-
// unix Driver Manager returns HY010
499+
#ifdef __APPLE__
500+
// MacOS Driver Manager returns HY010
499501
EXPECT_EQ(kErrorStateHY010, SqlWcharToString(sql_state));
500-
#endif // _WIN32
502+
#else // Linux & Windows
503+
// Linux & Windows Driver Managers returns S1010
504+
EXPECT_EQ(kErrorStateS1010, SqlWcharToString(sql_state));
505+
#endif
501506

502507
std::string msg = SqlWcharToString(message);
503508
EXPECT_FALSE(msg.empty());

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,9 @@ using TestTypesOdbcV2 =
4040
::testing::Types<FlightSQLOdbcV2MockTestBase, FlightSQLOdbcV2RemoteTestBase>;
4141
TYPED_TEST_SUITE(GetFunctionsOdbcV2Test, TestTypesOdbcV2);
4242

43-
// MacOS driver manager iODBC does not support SQLGetFunctions for ODBC 3.x or 2.x driver
44-
#ifndef __APPLE__
43+
// Unix driver managers iODBC and Unix-ODBC do not support SQLGetFunctions
44+
// for ODBC 3.x or 2.x driver
45+
#ifdef _WIN32
4546
TYPED_TEST(GetFunctionsTest, TestSQLGetFunctionsAllFunctions) {
4647
// Verify driver manager return values for SQLGetFunctions
4748

@@ -218,6 +219,6 @@ TYPED_TEST(GetFunctionsOdbcV2Test, TestSQLGetFunctionsUnsupportedSingleAPI) {
218219
api_exists = -1;
219220
}
220221
}
221-
#endif // __APPLE__
222+
#endif // _WIN32
222223

223224
} // namespace arrow::flight::sql::odbc

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,11 @@ TYPED_TEST(StatementAttributeTest, TestSQLSetStmtAttrAsyncEnableUnsupported) {
427427
TYPED_TEST(StatementAttributeTest, TestSQLSetStmtAttrAsyncStmtEventUnsupported) {
428428
// Driver does not support asynchronous notification
429429
ValidateSetStmtAttrErrorCode(this->stmt, SQL_ATTR_ASYNC_STMT_EVENT, 0, SQL_ERROR,
430+
# ifdef __linux__
431+
kErrorStateHYC00);
432+
# else // Windows & Mac
430433
kErrorStateHY118);
434+
# endif
431435
}
432436
#endif
433437

0 commit comments

Comments
 (0)