Skip to content

Implement SQLDescribeCol - #79

Closed
rscales wants to merge 47 commits into
apache-odbcfrom
sql-describe-col
Closed

Implement SQLDescribeCol#79
rscales wants to merge 47 commits into
apache-odbcfrom
sql-describe-col

Conversation

@rscales

@rscales rscales commented Jul 31, 2025

Copy link
Copy Markdown

Implement SQLDescribeCol

alinaliBQ and others added 30 commits June 17, 2025 14:38
Co-authored-by: rscales <robscales@icloud.com>

 Add initial framework for odbc dll

- Add ARROW_FLIGHT_SQL_ODBC option. If we set `ARROW_FLIGHT_SQL_ODBC=ON`, the flightsql odbc folder will be built
- Add odbc api layer for entry_point.cc
- builds odbc dll file, with ODBC APIs exported in odbc.def

Address James' comments

Fix `odbcabstraction` build errors and partially fix `flightsql_odbc` errors

Fix boost-variant not found error
- Adding dependencies from odbc/vcpkg.json to cpp/vcpkg.json

- Fix whereami.cc and .h dependency; ported lates code

Update whereami.cc

- use `long` instead of `int64`. Fixed namespace issues.

- PR CI fix: Add `parquet-testing` back

Partial build fix for `flight_sql` folder

- Replaced `namespace arrow` and `namespace odbcabstraction` with `using namespace ...`

- fix flight_sql_connection.cc

Fix `util::nullopt` to use `std::nullopt`

- fix std::optional

- fix BufferReader

- Fix GetSchema

- fix json_converter.cc

- partial fix configuration.h

-  partial fix get_info_cache.cc

- Fix winsock build error

- Comment out `flight_sql` files that cannot build
   - Comment out configuration and unit tests
   - Comment out get info cache and system trust store

Create initial odbc tests folder

Implement SQLAllocEnv

Fix cmake build

Implement SQLFreeEnv

Fix rest of build errors from `flightsql-odbc`

- Fix get info errors

- Fix for configuration window

  - added odbcinst library

- Fix system trust store

- unit test fixes

   - Add dependency of ARROW_COMPUTE. `arrow/compute/api.h` is used in
     `flight_sql`. Adding `ARROW_COMPUTE=ON` during build fixed run time unit
     tests failures.

Implement SQLAllocConnect and SQLFreeConnect

Fix build issue from static flight sql driver

Lint and code style fixes

Re-add deleted submodule parquet-testing

clang-format lint fix

cpplint lint fix

Exclude whereami in rat exclude list

C++/CLI lint fix

Update parquet-testing to match commit from `main`

Address Kou's comments

ODBC directory lint fixes

Catching the lint fixes outside of `flightsql-odbc` code

Fix build warnings that get treated as error

Implement SQLSetEnvAttr and SQLGetEnvAttr

Implement use of ExecuteWithDiagnostics

Doxygen Error Fixes and Address comments from Kou and James

Address comments from Kou

- Updates License.txt
- Update cmake toolchain
- Move whereami to `vendored`
- Use string_view instead of NOLINT std::string

Remove `whereami.cc` from arrow util build

We are building whereami.cc as part of odbc

Fix include headers to replace <> with ""

Address comments from James

Implement SQLGetDiagField
Implement stubs for SQLGetInfo, SQLGetDiagField and SQLGetDiagRec

Separate RegisterDsn and UnregisterDsn from windows build

Update code to save driver value from connection string

Add ReadMes for ODBC and tests

Fix test issues with string_view

Address code reviews

Update entry_points.cc to fix build issue

Remove Dremio references

Use emplace properly

Address comment from Rob and add SQLDisconnect test case
Accidentally committed the change during git rebase
Tests are skipped for now.
Add todo to update logging system later

Add logs
* Add todo for noauth validation

* mock server with token auth

Add tests

* run same test with both modes

* Enable ODBC tests in workflow

* Switch current test cases to use FlightSQLODBCTestBase

So the tests can be skipped when `TEST_CONNECT_STR` is not set.

* Change tests to run on both mock and remote modes

Wrap usage of TEST_CONNECT_STR where possible

* Rename test fixtures and make connection string functions virtual

* Fix lint issue

* Attempt to enable ODBC build on Windows platforms

* Attempt to fix clang64 and MinGW errors

* Attempt to register ODBC

* Address James' comments

Use constant string for token

* use ServerMiddleware to validate token
PopulateCallOptions before making a connection

Fix dsn window bug with advance properties

Fix seg fault issue from empty string
* Let compiler append `W` to ODBC APIs where applicable.
As per changes from apache#46261, we need to initialize Kernel library explicitly to get the functions registered
* Move `connection_test.cc` to last in `CMakeLists.txt`, this resolves the seg fault. The seg fault was not reproducible on my local environment, even when I use the msys2 shell. 
* Rename test executable to flight_sql_odbc_test
* SQLGetStmtAttr stub implementation

* Fix missing break statement in SQLGetDiagRec

* Run ShutdownProtobufLibrary as part of test environment

* Add comment for apacheGH-46889

* Pass call options to executed prepared statement

`call_options_` contains the authentication token which is needed
SQLGetStmtAttr stub implementation

Stub call for SQLGetStmtAttr

Enable statement handle allocation

Implement SQLExecDirect - test hang issue

Update odbc_api.cc

Run `ShutdownProtobufLibrary` after all ODBC tests

Resolves test hanging problem

Fix missing break statement in SQLGetDiagRec

Add tests

Lint fixes

Run ShutdownProtobufLibrary as part of test environment

Add debug messages

Draft code

Remove drafts

Add comment

Add comment for apacheGH-46889

Update statement test headers

Pass call options to executed prepared statement

`call_options_` contains the authentication token which is needed

SQLFetch & SQLGetData initial impl

EVERYTHING before this commit is for SQLExecDirect

SQLFetch and SQLGetData TestSQLExecDirectSimpleQuery test

Make GetData() return SQLRETURN

`TestSQLExecDirectDataQuery` for remote and mock servers

Remove unneeded test case

Add more data types

* Add SQL_GUID in getCTypeForSQLType

* Add data types in query

* Add checks for columns 1 to 25

* Update statement_test.cc

Add varbinary test

* Implement SQLNumResultCols

Will leave tests for later

* Implement SQLRowCount

* Implement SQLMoreResults

* Work on date retrieval fix

The `TestSQLExecDirectDataQuery` checks for date is not working.

* Fix date retrieval error by importing fix from Paul

* imported fix from dremio/flightsql-odbc@d44d862, an Apache-Licensed repository

* Add more checks for get data

* Add more tests

* Continue work on float truncation test

* Disable float truncation test

* Address comments from James

- do not return errors for invalid rowCountPtr and columnCountPtr
- add static cast for columnCount
- Add tests with SQL_C_DEFAULT as target type
- Add test checks for indicator
- Fix SQL_NUMERIC, SQL_BIT, SQL_FLOAT target type

* Fix build issues in CI

* More fix for CI

* Add test for invalid buffer length
* Add tests
* Address comments from Rob
* Move ifdefs outside of test cases

* use `stmt`

* Move logs to first line

* fix test for `SQL_DRIVER_HSTMT`

* Use camel case for tests
* SQL_UNBIND implementation + tests

* Add tests for `SQL_ATTR_ROW_ARRAY_SIZE`

* Add check for `SQL_ATTR_ROWS_FETCHED_PTR`
alinaliBQ and others added 17 commits July 16, 2025 13:12
* Add checks for SQL_ATTR_ROWS_FETCHED_PTR

* SQLFetchScroll is supposed to return the number of rows fetched using SQL_ATTR_ROWS_FETCHED_PTR
* Implement rowCountPtr and rowStatusArray for SQLExtendedFetch

* Add tests for SQLExtendedFetch

* `SQLExtendedFetch` doesn't return `SQL_SUCCESS_WITH_INFO` for error state 22002.

* Add tests for `SQL_ROWSET_SIZE`

* Address comments from James
* 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
* Initial impl for SQLColumns

* Add test for SQLColumns

* Add columns test with all supported column types

- mock server doesn't support schema

* Address comments from James

- Test different data type return value for SQLColumns
- Add todo comment for SQLDescribeCol tests

---------

Co-authored-by: rscales <robscales@icloud.com>
* Fix reading DSN bug

Use a simpler, more robust way to load the DSN
* SQLColAttribute initial impl

* Switch to use `GetAttributeSQLWCHAR` to be unicode-compatible

* Add SQLColAttribute tests and fix bugs in `flightsql-odbc` impl

* Fixed bug with incorrect column count. It was returning column count + 1.
* Fixed bug with incorrect numPrecRadix. It was returning SQL_NO_TOTAL (maps to -4) for non-numeric columns, but the correct value is 0.
* Fixed bug with unsigned column to return true for unsigned columns (non-numeric columns or unsigned numeric columns) and false for signed columns (numeric columns)
* Fixed bug with incorrect non-concise data type return value for date time type types. The correct return is SQL_DATETIME for all date time types

* Address comments from James

* use const for `ConvertToWString`
* add nullptr check in odbc_api.cc layer
* Add support for `SQL_COLUMN_LENGTH`, `SQL_COLUMN_PRECISION`, and `SQL_COLUMN_SCALE`. The driver will return the same values for ODBC2 and ODBC3.
* Add tests for ODBC v2 SQLColAttributes values
* I converted tests that can be run on remote servers where possible

* Address comment from Rob
* Add support for building with C++20

* Upgrade spdlogs version as an attempt to fix build issues

* Fix issue of missing unique_ptr definition
* remove `SQLErrors`, as the driver manager is supposed to map `SQLErrors` to `SQLGetDiagRec`
* fix error state to return the correct state 24000.

* add tests for SQLCloseCursor and SQLFreeStmt(SQL_CLOSE)
* Modify SQLTables test to run on both mock and remote
* reorder error msg alphabetically
@rscales
rscales marked this pull request as draft July 31, 2025 18:52
@rscales rscales closed this Jul 31, 2025
@rscales
rscales deleted the sql-describe-col branch July 31, 2025 19:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants