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 and others added 4 commits October 27, 2025 16:39
Requires SQLDriverConnect Implementation
Co-authored-by: rscales <[email protected]>
* the test suite fixture is still being worked on
Co-authored-by: justing-bq <[email protected]>
- rebased onto master

Use RAII helper for allocating and freeing env/conn handles
@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
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.

2 participants