GH-49482: [C++][FlightRPC][ODBC] Fix inconsistent SQLGetInfo values in global connection#50021
Conversation
lidavidm
left a comment
There was a problem hiding this comment.
Thanks for the PR!
Also CC @alinaliBQ
| bool supported = | ||
| reinterpret_cast<BooleanScalar*>(scalar->child_value().get())->value; |
There was a problem hiding this comment.
Maybe we can use checked_cast from arrow/util/checked_cast.h?
There was a problem hiding this comment.
It seems there's some failing tests - some more test cases need updating?
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Resolves inconsistent return values for several ODBC connection info properties (SQL_CATALOG_LOCATION, SQL_DROP_SCHEMA, SQL_DROP_TABLE) by properly deriving them from Flight SQL boolean info responses, and replaces unchecked reinterpret_cast with checked_cast for scalar conversions.
Changes:
- Use scalar boolean values from
SQL_DDL_SCHEMAandSQL_DDL_TABLEto determineSQL_DROP_SCHEMA,SQL_CREATE_SCHEMA,SQL_DROP_TABLE, andSQL_CREATE_TABLE. - Avoid overwriting
SQL_CATALOG_LOCATIONwhen previously set, by usingSetDefaultIfMissing. - Replace
reinterpret_cast<BooleanScalar*>withchecked_cast<BooleanScalar*>and update affected tests.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| cpp/src/arrow/flight/sql/odbc/odbc_impl/get_info_cache.cc | Derives DDL-related info values from server-provided booleans, guards SQL_CATALOG_LOCATION against overwrite, and switches to checked_cast. |
| cpp/src/arrow/flight/sql/odbc/tests/connection_info_test.cc | Updates tests to reflect corrected behavior, moving some tests from ConnectionInfoHandleTest to ConnectionInfoTest/ConnectionInfoMockTest. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Hi @lidavidm, |
There was a problem hiding this comment.
Hi @vanshaj2023 thanks for raising the PR. Please build and test ODBC locally first.
FYI - Once these 2 PRs are merged, ODBC will be tested against a Dremio instance in the Linux CI. This might be helpful.
|
|
||
| TYPED_TEST(ConnectionInfoHandleTest, TestSQLGetInfoDropSchema) { | ||
| // GH-49482 TODO: resolve inconsitent return value for SQL_DROP_SCHEMA and change test | ||
| // type to `ConnectionInfoTest` | ||
| this->ConnectWithString(this->GetConnectionString(), this->conn); | ||
|
|
||
| TEST_F(ConnectionInfoMockTest, TestSQLGetInfoDropSchema) { |
There was a problem hiding this comment.
Could you use TYPED_TEST(ConnectionInfoTest, here to be consistent with rest of code base?
| // type to `ConnectionInfoTest` | ||
| this->ConnectWithString(this->GetConnectionString(), this->conn); | ||
|
|
||
| TEST_F(ConnectionInfoMockTest, TestSQLGetInfoDropTable) { |
There was a problem hiding this comment.
Could you use TYPED_TEST(ConnectionInfoTest, here to be consistent with rest of code base?
There was a problem hiding this comment.
@vanshaj2023 To ensure maximum coverage, please build and run the ODBC tests locally against a Dremio docker instance with documentation here:
arrow/cpp/src/arrow/flight/sql/odbc/README.md
Lines 88 to 89 in cd1811b
| transactions_supported = | ||
| reinterpret_cast<BooleanScalar*>(scalar->child_value().get())->value; |
There was a problem hiding this comment.
Please fix the CI build failures from checked_cast in this file:
https://github.com/apache/arrow/actions/runs/26406439067/job/77730895486?pr=50021#step:7:4419
/Users/runner/work/arrow/arrow/cpp/src/arrow/flight/sql/odbc/odbc_impl/get_info_cache.cc:499:19: error: use of undeclared identifier 'checked_cast'; did you mean 'internal::checked_cast'?
499 | checked_cast<BooleanScalar*>(scalar->child_value().get())->value;
| ^~~~~~~~~~~~
| internal::checked_cast
/Users/runner/work/arrow/arrow/cpp/src/arrow/util/checked_cast.h:28:19: note: 'internal::checked_cast' declared here
What changed
SQL_DDL_SCHEMAcase now reads the boolean scalar to conditionally setSQL_DROP_SCHEMAandSQL_CREATE_SCHEMAto0when unsupported, instead of always writing non-zero valuesSQL_DDL_TABLEcase applies the same pattern forSQL_DROP_TABLEandSQL_CREATE_TABLESQL_CATALOG_AT_STARTchanged to useSetDefaultIfMissingso it does not overwriteSQL_CATALOG_LOCATIONalready set byARROW_SQL_CATALOG_TERM, eliminating an ordering-dependent conflictConnectionInfoHandleTestback toConnectionInfoTestHow to test
TestSQLGetInfoCatalogLocation,TestSQLGetInfoDropSchema,TestSQLGetInfoDropTablewith both mock server and global connection fixtureCloses #49482