Skip to content

Conversation

@alinaliBQ
Copy link
Contributor

@alinaliBQ alinaliBQ commented Oct 8, 2025

Rationale for this change

Putting the tests for diagnostics in a separate PR from #47763, because non-diagnostic ODBC APIs are required to get diagnostics.

What changes are included in this PR?

  • Add tests for ODBC diagnostics

Are these changes tested?

PR depends on #47971 for tests to work.

Tested locally.

Are there any user-facing changes?

No

@alinaliBQ
Copy link
Contributor Author

@lidavidm @kou Please review this draft ODBC API PR. The implementation PR is at #47763.


namespace arrow::flight::sql::odbc {

TYPED_TEST(FlightSQLODBCTestBase, TestSQLGetDiagFieldWForConnectFailure) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment here, we can subclass the base fixture and create a specific fixture for this file.

// Allocate an environment handle
SQLRETURN ret = SQLAllocEnv(&env);

EXPECT_EQ(SQL_SUCCESS, ret);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test will continue even if EXPECT_ fails. Usually these kinds of checks should be ASSERT.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be more concise to just ASSERT_EQ(SQL_SUCCESS, SQLAllocEnv(&env)) and so on.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup, updated the code to use ASSERT_EQ

Comment on lines 137 to 139
// Test is disabled because driver manager on Windows does not pass through SQL_NTS
// This test case can be potentially used on macOS/Linux
GTEST_SKIP();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the test name starts with DISABLED_, GTest will ignore the test automatically

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed to use DISABLED_ and removed GTEST_SKIP

@github-actions github-actions bot added awaiting changes Awaiting changes and removed awaiting review Awaiting review labels Oct 9, 2025
@alinaliBQ alinaliBQ force-pushed the gh-46575-odbc-diagnostics-tests branch from 19da64d to 4f4bbc0 Compare October 21, 2025 21:55
Copy link
Contributor Author

@alinaliBQ alinaliBQ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In-progress of addressing comments. The team is still working on improving the subclass logic for separate test fixture (discussion is in #47788)

// Allocate an environment handle
SQLRETURN ret = SQLAllocEnv(&env);

EXPECT_EQ(SQL_SUCCESS, ret);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup, updated the code to use ASSERT_EQ

Comment on lines 137 to 139
// Test is disabled because driver manager on Windows does not pass through SQL_NTS
// This test case can be potentially used on macOS/Linux
GTEST_SKIP();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed to use DISABLED_ and removed GTEST_SKIP

@github-actions github-actions bot added awaiting change review Awaiting change review and removed awaiting changes Awaiting changes labels Oct 21, 2025
Comment on lines 31 to 32
public:
using List = std::list<T>;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public:
using List = std::list<T>;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done, removed using List

Comment on lines 39 to 43
template <typename T>
class ErrorsOdbcV2Test : public T {
public:
using List = std::list<T>;
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
template <typename T>
class ErrorsOdbcV2Test : public T {
public:
using List = std::list<T>;
};
template <typename T>
class ErrorsOdbcV2Test : public T {
};

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Comment on lines 133 to 134
// Free connection handle
EXPECT_EQ(SQL_SUCCESS, SQLFreeHandle(SQL_HANDLE_DBC, conn));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe consider an RAII helper to free resources in tests

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added RAII helper for this (ErrorsHandleTest)

// API not implemented error from driver manager
EXPECT_EQ(std::wstring(L"IM001"), std::wstring(sql_state));

EXPECT_TRUE(!std::wstring(message).empty());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EXPECT_FALSE?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup good catch, fixed

@github-actions github-actions bot added awaiting changes Awaiting changes and removed awaiting change review Awaiting change review labels Oct 22, 2025
@alinaliBQ alinaliBQ force-pushed the gh-46575-odbc-diagnostics-tests branch from 4f4bbc0 to 99d8ec6 Compare October 22, 2025 22:30
@github-actions github-actions bot added awaiting change review Awaiting change review and removed awaiting changes Awaiting changes labels Oct 22, 2025
@alinaliBQ alinaliBQ force-pushed the gh-46575-odbc-diagnostics-tests branch from 99d8ec6 to eddea34 Compare October 22, 2025 22:34
Copy link
Contributor Author

@alinaliBQ alinaliBQ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed comments

Comment on lines 31 to 32
public:
using List = std::list<T>;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done, removed using List

Comment on lines 39 to 43
template <typename T>
class ErrorsOdbcV2Test : public T {
public:
using List = std::list<T>;
};
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Comment on lines 133 to 134
// Free connection handle
EXPECT_EQ(SQL_SUCCESS, SQLFreeHandle(SQL_HANDLE_DBC, conn));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added RAII helper for this (ErrorsHandleTest)

// API not implemented error from driver manager
EXPECT_EQ(std::wstring(L"IM001"), std::wstring(sql_state));

EXPECT_TRUE(!std::wstring(message).empty());
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup good catch, fixed

@alinaliBQ alinaliBQ requested a review from lidavidm October 22, 2025 22:34
Comment on lines 100 to 102
static constexpr std::string_view authorization_header = "authorization";
static constexpr std::string_view bearer_prefix = "Bearer ";
static constexpr std::string_view test_token = "t0k3n";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we keep to the naming scheme? kAuthorizationHeader etc.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the change was added by accident. Fixed.
The RAII helper logic will also be in #47971, after #47971 is merged, I will rebase this PR.

@github-actions github-actions bot added awaiting changes Awaiting changes and removed awaiting change review Awaiting change review labels Oct 27, 2025
@alinaliBQ alinaliBQ force-pushed the gh-46575-odbc-diagnostics-tests branch from eddea34 to 2768502 Compare October 27, 2025 23:51
@github-actions github-actions bot added awaiting change review Awaiting change review and removed awaiting changes Awaiting changes labels Oct 27, 2025
kou pushed a commit that referenced this pull request Oct 29, 2025
### Rationale for this change
ODBC needs to provide diagnostic information so users can debug the error

### What changes are included in this PR?
- Implementation of  SQLGetDiagField and SQLGetDiagRec 
Tests are included in separate PR (see #47764)

### Are these changes tested?
Tests will be in a separate PR (see #47764). Other APIs depend on SQLGetDiagField and SQLGetDiagRec to get error reporting functionality, and tests for SQLGetDiagField and SQLGetDiagRec depend on other APIs for creating errors, as these diagnostic APIs alone do not initiate any errors. 

Changes tested locally

### Are there any user-facing changes?
No

* GitHub Issue: #46575

Authored-by: Alina (Xi) Li <[email protected]>
Signed-off-by: Sutou Kouhei <[email protected]>
@github-actions github-actions bot added awaiting merge Awaiting merge and removed awaiting change review Awaiting change review labels Oct 31, 2025
@alinaliBQ alinaliBQ force-pushed the gh-46575-odbc-diagnostics-tests branch from 2768502 to d808e34 Compare November 7, 2025 00:41
@justing-bq justing-bq force-pushed the gh-46575-odbc-diagnostics-tests branch 2 times, most recently from 3bdd474 to fdaf290 Compare November 17, 2025 21:46
@alinaliBQ alinaliBQ marked this pull request as ready for review November 21, 2025 00:23
@alinaliBQ alinaliBQ requested a review from lidavidm December 1, 2025 19:12
@justing-bq justing-bq force-pushed the gh-46575-odbc-diagnostics-tests branch from fdaf290 to 34546b5 Compare December 2, 2025 20:56
Requires SQLDriverConnect Implementation
Co-authored-by: rscales <[email protected]>
@justing-bq justing-bq force-pushed the gh-46575-odbc-diagnostics-tests branch from 34546b5 to 9a1ebf4 Compare December 3, 2025 18:25
@jduo jduo merged commit 6fed4f3 into apache:main Dec 8, 2025
45 checks passed
@kou
Copy link
Member

kou commented Dec 9, 2025

@jduo Could you use our merge script https://github.com/apache/arrow/tree/main/dev#how-to-merge-a-pull-request in this repository?

@jduo
Copy link
Member

jduo commented Dec 9, 2025

@jduo Could you use our merge script https://github.com/apache/arrow/tree/main/dev#how-to-merge-a-pull-request in this repository?

Sure @kou . Do you mean to re-do the last two merges using the scripts or use the merge script going forward?

Thanks

@kou
Copy link
Member

kou commented Dec 9, 2025

The latter. (We can't re-do merges in public repositories because it changes commit hashes...)

@conbench-apache-arrow
Copy link

After merging your PR, Conbench analyzed the 3 benchmarking runs that have been run so far on merge-commit 6fed4f3.

There were no benchmark performance regressions. 🎉

The full Conbench report has more details. It also includes information about 1 possible false positive for unstable benchmarks that are known to sometimes produce them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants