-
Notifications
You must be signed in to change notification settings - Fork 3.9k
GH-46574: [C++][FlightRPC] ODBC Driver Connectivity support #47971
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
|
f28ed1f to
8ad5b6a
Compare
* use suggestion from James for one-liner change to return `Status::OK` directly * fix for iterating endpoints, it is based on JDBC's fix for the same bug * save value of `FlightClientOptions` * Use `TestFlightServer` Add `arrow_flight_sql_shared` to enable usages for `TestFlightServer` * Fix build errors from missing `gmock` * Add checks for array data Update flight_sql_stream_chunk_buffer_test.cc Add `FlightStreamChunkBufferTest` unit test Draft test with `FlightSQLODBCMockEndpointTestBase` * Reference apacheGH-47117 and Clean up code * Add driver and DSN to built-in properties to not pass driver/dsn as attributes to server * Allow `=` in values inside connection strings, fixes connectivity problems * Address comments from Rob
* SQLDriverConnect requires SQLGetInfo to be implemented for tests to pass, because driver manager requires SQLGetInfo Co-Authored-By: alinalibq <[email protected]>
Co-authored-by: justing-bq <[email protected]>
Co-authored-by: justing-bq <[email protected]>
b5159a7 to
fc95da6
Compare
|
Rebased onto Edit: getting segfault error, looking into it. |
Iirc, there is segfault error associated with `SQLGetStmtAttrW` Attempt to fix segfault error by adding impl for `SQLSetConnectAttr` Part-fix remove `using` that isn't needed
| #include "arrow/flight/sql/odbc/odbc_impl/platform.h" | ||
|
|
||
| #include "arrow/flight/sql/odbc/odbc_impl/config/configuration.h" | ||
| #include "arrow/result.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: if you wanted arrow::Status, just include status.h
| namespace arrow::flight::sql::odbc { | ||
|
|
||
| /// \brief Case insensitive comparator that takes string_view | ||
| struct CaseInsensitiveComparatorStrView { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this defined here? It seems to only be used inside the implementation
|
|
||
| // PropertyMap is case-insensitive for keys. | ||
| typedef std::map<std::string_view, std::string, CaseInsensitiveComparator> PropertyMap; | ||
| typedef std::map<std::string, std::string, CaseInsensitiveComparator> PropertyMap; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With the right definitions, you should be able to avoid wrapping every lookup in std::string. Can we avoid that? (See the note about 'transparent' comparator in https://en.cppreference.com/w/cpp/container/map/find)
| #include "arrow/flight/sql/odbc/odbc_impl/exceptions.h" | ||
| #include "arrow/flight/sql/odbc/odbc_impl/platform.h" | ||
|
|
||
| namespace ODBC { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(maybe for a separate issue but) can we fix this namespace?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yea we can do it for a separate issue. Are we thinking of replacing ODBC with namespace arrow::flight::sql::odbc?
| // Return the number of bytes required for the conversion. | ||
| template <typename CHAR_TYPE> | ||
| inline size_t ConvertToSqlWChar(const std::string& str, SQLWCHAR* buffer, | ||
| inline size_t ConvertToSqlWChar(const std::string_view& str, SQLWCHAR* buffer, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
string_view can (and should) be passed by value.
| /// \return wchar_msg in std::string format | ||
| inline std::string SqlWcharToString(SQLWCHAR* wchar_msg, SQLINTEGER msg_len = SQL_NTS) { | ||
| if (msg_len == 0 || !wchar_msg || wchar_msg[0] == 0) { | ||
| if (!wchar_msg || wchar_msg[0] == 0 || msg_len == 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't you check length before dereferencing the pointer?
| static std::string GetPropertiesFromConnString( | ||
| /// @return the DSN or an empty string if the DSN is not found or is found after the | ||
| /// driver | ||
| static std::string GetDsnIfExists(const std::string& conn_str); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would std::optional<std::string> be better?
| /// @return the DSN or an empty string if the DSN is not found or is found after the | ||
| /// driver |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We use \return not @return.
| #if defined _WIN32 | ||
| // For displaying DSN Window | ||
| # include "arrow/flight/sql/odbc/odbc_impl/system_dsn.h" | ||
| #endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| #endif | |
| #endif // defined(_WIN32) |
Rationale for this change
Add ODBC driver connection support for the driver, so the driver can connect to servers.
What changes are included in this PR?
Implementation of unicode APIs:
Are these changes tested?
Tested locally on Windows.
Note that this PR depends on #47763 to get tests passing.
Are there any user-facing changes?
N/A