Skip to content

[PECOBLR-239][PECOBLR-279] added sql types integration tests - #769

Merged
shivam2680 merged 5 commits into
mainfrom
shivam2680/data-types-fs-tests
Apr 9, 2025
Merged

shivam2680 merged 5 commits into
mainfrom
shivam2680/data-types-fs-tests

Conversation

@shivam2680

@shivam2680 shivam2680 commented Apr 1, 2025 •

Copy link
Copy Markdown
Collaborator

Description

Added fake service tests for various sql types, covering following base and edge cases:

  • string variations
  • variant type
  • null handling
  • timestamp (with timezone as well)

The tests (except for VARIANT) are run with both inline and arrow mode

Testing

Integration tests CI checks

Additional Notes to the Reviewer

@shivam2680 shivam2680 changed the title added edge cases for string and null [PECOBLR-239][PECOBLR-279] added edge cases for string and null Apr 1, 2025
@shivam2680 shivam2680 changed the title [PECOBLR-239][PECOBLR-279] added edge cases for string and null [PECOBLR-239][PECOBLR-279] added sql types integration tests Apr 1, 2025
@shivam2680
shivam2680 marked this pull request as ready for review April 1, 2025 22:39

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds integration tests for various SQL types including string edge cases, null handling, variant types, and timestamp conversions to ensure comprehensive coverage of base and edge cases.

  • Added tests for strings with spacing, special characters, and Unicode.
  • Added tests to verify null handling and type inference with union queries.
  • Integrated tests to validate timestamp conversion with timezone handling.
Files not reviewed (19)
  • src/test/resources/cloudfetchapi/datatypesintegrationtests/testnullhandling.invocation1/mappings/oregon-staging_6051921418418893.jobs_sql_extended_results_2025-04-02t223316z_cfe75cc7-a4ec-4b74-acaf-4afd29a23b6c-6fcb956f-3961-4522-ad6d-3b72dfe84c50.json: Language not supported
  • src/test/resources/cloudfetchapi/datatypesintegrationtests/testnullhandling.invocation2/mappings/oregon-staging_6051921418418893.jobs_sql_extended_results_2025-04-02t223328z_8bdd9299-944a-4ef4-9597-1227609a5329-a57f1ff8-b16f-42e9-bcdf-88eaab7323ac.json: Language not supported
  • src/test/resources/cloudfetchapi/datatypesintegrationtests/testnullhandling.invocation3/mappings/oregon-staging_6051921418418893.jobs_sql_extended_results_2025-04-02t223340z_53730ed5-970f-4203-a778-8f24401488b4-a22178e3-5bb8-488e-a15a-3fe93df35e00.json: Language not supported
  • src/test/resources/cloudfetchapi/datatypesintegrationtests/teststringedgecases/mappings/oregon-staging_6051921418418893.jobs_sql_extended_results_2025-04-02t223244z_fdfe0cab-9e01-45cc-a985-5fdcb191246e-07102a2e-25c1-4fc3-88a2-16e6cfeee342.json: Language not supported
  • src/test/resources/cloudfetchapi/datatypesintegrationtests/teststringedgecases/mappings/oregon-staging_6051921418418893.jobs_sql_extended_results_2025-04-02t223246z_18bf001f-2ad1-4304-97ed-1d1ef3d46cc5-3b6cbe5b-b787-4eb7-949c-dd64934ac0d0.json: Language not supported
  • src/test/resources/cloudfetchapi/datatypesintegrationtests/testtimestamp/mappings/oregon-staging_6051921418418893.jobs_sql_extended_results_2025-04-02t232949z_7ee4b77c-bce5-4b27-9a01-62a7e3e87f67-d816af11-074a-449a-a2c6-f7c323664358.json: Language not supported
  • src/test/resources/cloudfetchapi/datatypesintegrationtests/testtimestamp/mappings/oregon-staging_6051921418418893.jobs_sql_extended_results_2025-04-02t232951z_504b9d09-3935-4694-870c-cbe0b5e4f49b-ef671e9b-3502-448f-bcf1-adffbfd8b5ba.json: Language not supported
  • src/test/resources/cloudfetchapi/datatypesintegrationtests/testtimestampwithtimezoneconversion/mappings/oregon-staging_6051921418418893.jobs_sql_extended_results_2025-04-02t233125z_6b0867c1-29c9-430f-b468-b7f965255493-4b7aee32-c1d7-4f85-bfb2-05f59332d7ab.json: Language not supported
  • src/test/resources/cloudfetchapi/datatypesintegrationtests/testtimestampwithtimezoneconversion/mappings/oregon-staging_6051921418418893.jobs_sql_extended_results_2025-04-02t233127z_c10cf53a-22d1-44ba-acd9-583d69a8de8c-01e2b049-f103-425b-b1cb-e183b7f9bde7.json: Language not supported
  • src/test/resources/cloudfetchapi/datatypesintegrationtests/testvarianttypes/mappings/oregon-staging_6051921418418893.jobs_sql_extended_results_2025-04-02t230530z_55a085f2-30c1-4209-8340-3a69bc4ca1cd-1974ef03-34fe-43bb-96a5-6e8f53232500.json: Language not supported
  • src/test/resources/cloudfetchapi/datatypesintegrationtests/testvarianttypes/mappings/oregon-staging_6051921418418893.jobs_sql_extended_results_2025-04-02t230532z_c18577c4-038a-49ad-8c9b-a28759d08958-c25916ac-52c9-42a6-91fc-10d59166c043.json: Language not supported
  • src/test/resources/sqlexecapi/datatypesintegrationtests/testnullhandling.invocation1/mappings/api_2.0_sql_sessions-238e9623-cd70-41cc-8e36-1c5d85e5101e.json: Language not supported
  • src/test/resources/sqlexecapi/datatypesintegrationtests/testnullhandling.invocation1/mappings/api_2.0_sql_sessions-53307f92-0659-4e3b-95c3-1b4b956d0b7b.json: Language not supported
  • src/test/resources/sqlexecapi/datatypesintegrationtests/testnullhandling.invocation1/mappings/api_2.0_sql_sessions_01f00f40-ea86-1416-9d48-d14081d7fbf9-ea0570cc-d068-45af-af5e-4866007d31e6.json: Language not supported
  • src/test/resources/sqlexecapi/datatypesintegrationtests/testnullhandling.invocation1/mappings/api_2.0_sql_sessions_01f00f40-eb63-1471-b392-2ae43c27aecd-86ea8031-9f74-4aa2-beef-fb08fd8d261c.json: Language not supported
  • src/test/resources/sqlexecapi/datatypesintegrationtests/testnullhandling.invocation1/mappings/api_2.0_sql_statements-381c963e-4a99-4974-ae73-ff151110c712.json: Language not supported
  • src/test/resources/sqlexecapi/datatypesintegrationtests/testnullhandling.invocation1/mappings/api_2.0_sql_statements-f444f57b-f172-4a78-905b-b8fc281db853.json: Language not supported
  • src/test/resources/sqlexecapi/datatypesintegrationtests/testnullhandling.invocation1/mappings/api_2.0_sql_statements_01f00f40-ec5a-10a9-972b-922abf8c65fd-e803c0ca-1437-41c8-923a-986ac1a355c2.json: Language not supported
  • src/test/resources/sqlexecapi/datatypesintegrationtests/testnullhandling.invocation1/mappings/api_2.0_sql_statements_01f00f40-ed5c-160a-be8d-f6210ccca1b8-4dd86b21-4b75-483f-ae2d-7b83612d86c8.json: Language not supported
Comments suppressed due to low confidence (1)

src/test/java/com/databricks/jdbc/integration/fakeservice/tests/DataTypesIntegrationTests.java:202

  • Consider closing the ResultSet after its use in this test to ensure proper resource cleanup and to avoid potential resource leaks.
ResultSet rs = executeQuery(connection, query);

return Stream.of(
Arguments.of("SELECT NULL", Types.VARCHAR),
Arguments.of("SELECT CAST(NULL AS DOUBLE)", Types.DOUBLE),
Arguments.of("SELECT NULL UNION (SELECT 1) order by 1", Types.INTEGER));

Copilot AI Apr 2, 2025

Copy link

Choose a reason for hiding this comment

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

Consider explicitly casting NULL to the expected type in the UNION query to avoid potential type inference issues across different SQL dialects.

Suggested change
Arguments.of("SELECT NULL UNION (SELECT 1) order by 1", Types.INTEGER));
Arguments.of("SELECT CAST(NULL AS INTEGER) UNION (SELECT 1) order by 1", Types.INTEGER));

Copilot uses AI. Check for mistakes.
Comment on lines +42 to +60
String tableName = "string_edge_cases_table";
String createTableSQL =
"CREATE TABLE IF NOT EXISTS "
+ getFullyQualifiedTableName(tableName)
+ " (id INT PRIMARY KEY, test_string VARCHAR(255))";
setupDatabaseTable(connection, tableName, createTableSQL);
String insertSQL =
"INSERT INTO "
+ getFullyQualifiedTableName(tableName)
+ " (id, test_string) VALUES "
+ "(1, ' leading and trailing spaces '),"
+ "(2, 'こんにちは'),"
+ "(3, 'special chars: !@#$%^&*()'),"
+ "(4, 'string with \"double quotes\" inside'),"
+ "(5, NULL)";
executeSQL(connection, insertSQL);

String query =
"SELECT id, test_string FROM " + getFullyQualifiedTableName(tableName) + " ORDER BY id";

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

do we need to create the table, is there a benefit to just executing the select like so:

String query =
    "SELECT * FROM (VALUES " +
    "(1, '   leading and trailing spaces   ')," +
    "(2, 'こんにちは')," +
    "(3, 'special chars: !@#$%^&*()')," +
    "(4, 'string with \"double quotes\" inside')," +
    "(5, NULL)" +
    ") AS string_edge_cases(id, test_string) " +
    "ORDER BY id";

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

yea makes sense, I'll try to avoid creating tables where I can.

@shivam2680
shivam2680 merged commit 4a3aef7 into databricks:main Apr 9, 2025
samikshya-db added a commit that referenced this pull request Apr 12, 2025
* [PECOBLR-272] Retry handler fixes for http client (#764)

* Support Azure Managed Identity OAuth in OSS JDBC (#756)

* draft for azure msi

* add unit tests

* remove debug line

* fmt

* Address comments

* Add debug logs

* [PECOBLR-262] implement todos in DBFS volume client (#763)

* [PECOBLR-182] Add support for retry timeout for UC vol operations (#760)

* Add support for retry timeout for UC vol operations

* [PECOBLR-161][PECOBLR-282] add support for configurable row fetch limit in thrift inline and fix setMaxRows (#765)

* [PECOBLR-126] added DefaultStringColumnLength config (#761)

* Add client-side statement execution timeout (#767)

## Description
- DatabricksStatement uses the same-thread executor for the statement's CompletableFuture. By the time the code reaches the `futureResultSet.get(timeoutInSeconds, TimeUnit.SECONDS)` line, the task has already fully executed (or failed), so the timeout has no practical effect.
- Create a reusable TimeoutHandler utility class that centralizes timeout logic.
- Implement timeout checks during statement execution polling instead of relying on the CompletableFuture timeout.
- Add automatic cancellation of statements when timeouts occur.
- Ensure consistent timeout behavior across both SDK and Thrift client implementations.
- Move the DatabricksSdkClientTest class to the test counterpart of its source package. Delete the duplicate DatabricksSdkClientTest class.
- DatabricksThriftAccessor will now use connection param `asyncPollIntervalMillis`. Previously, the poll interval was hardcoded to 1 second.

## Testing
- Unit tests
- E2E testing

* [PECOBLR-106][PECOBLR-235] Fixes Logging Test intermittent failures and adds support for thriftclient in test (#766)

* logging fixes

* fix logging test

* fix logging test

* fix logging test

* fix logging test

* fix logging test

* use printf in place of echo

* use powershell

* try java side fix

* fix comments

* minor fixes

* Hybrid Results are enabled by default in SEA Mode (#771)

* Made Hybrid results default

* Fixed unit test

* Added Fake service stubs

* Added stubs for Default hybrid mode

* Reverted to old stubs

* Reverted stubs

* Fix

* [PECOBLR-289] Throw exception for column not found (#773)

* [PECOBLR-145] Implement OAuth2RedirectUrlPort (#775)

* Support for providing custom headers from URL (#776)

* Support for custom headers

* Made headers case insensitive

* Added back the case matching in headers

* Formatting fix

* Align behaviour for ResultSet#getBoolean (#774)

* Update version to 1.0.3 (#772)

* make changes for 1.0.3 release

* adds changelog

* updates changelog

* updates changelog

* updates changelog

* [PECOBLR-239][PECOBLR-279] added sql types integration tests (#769)

* added edge cases for string and null

* update stubs

* add test for variant type

* add test for timestamp

* [PECOBLR-310] Refactor internal interfaces into internal package, and fix javadoc for public interfaces (#770)

* Fix javadoc for all public interfaces

* [PECOBLR-164] Support connection param SocketTimeout (#777)

- The default value of the param is kept as 900 seconds (same as earlier value and default in databricks-sdk-java)
- Set the param in thrift, dbfs, and sql-exec clients

* Renaming UC Volume retryable codes and retry timeout parameters as per Docs team feedback (#780)

* Rename UC timeout and retryable parameters based on Docs team feedback

* Set default value as null for BigDecimal (#782)

* [PECOBLR-322] Update SDK to the latest version (0.43.0) (#781)

* [PECOBLR-301] Handle server returned Thrift version as part of open session response gracefully (#779)

* init changes

* Refactor TSparkArrowTypes initialization based on protocol version

* added comments

* added several unit tests

* added more unit tests

* ran ProtocolFeatureUtilTest for all protocol versions

* store protocol version as TProtocolVersion enum.

* move db compute check to protocol feature util

---------

Co-authored-by: Vikrant Puppala <[email protected]>
Co-authored-by: Shivam Raj <[email protected]>
Co-authored-by: Gopal Lal <[email protected]>
Co-authored-by: jayant <[email protected]>
Co-authored-by: Madhav Sainanee <[email protected]>
Co-authored-by: Jothi Prakash <[email protected]>
samikshya-db added a commit that referenced this pull request Apr 12, 2025
* [PECOBLR-272] Retry handler fixes for http client (#764)

* Support Azure Managed Identity OAuth in OSS JDBC (#756)

* draft for azure msi

* add unit tests

* remove debug line

* fmt

* Address comments

* Add debug logs

* [PECOBLR-262] implement todos in DBFS volume client (#763)

* [PECOBLR-182] Add support for retry timeout for UC vol operations (#760)

* Add support for retry timeout for UC vol operations

* [PECOBLR-161][PECOBLR-282] add support for configurable row fetch limit in thrift inline and fix setMaxRows (#765)

* [PECOBLR-126] added DefaultStringColumnLength config (#761)

* Add client-side statement execution timeout (#767)

## Description
- DatabricksStatement uses the same-thread executor for the statement's CompletableFuture. By the time the code reaches the `futureResultSet.get(timeoutInSeconds, TimeUnit.SECONDS)` line, the task has already fully executed (or failed), so the timeout has no practical effect.
- Create a reusable TimeoutHandler utility class that centralizes timeout logic.
- Implement timeout checks during statement execution polling instead of relying on the CompletableFuture timeout.
- Add automatic cancellation of statements when timeouts occur.
- Ensure consistent timeout behavior across both SDK and Thrift client implementations.
- Move the DatabricksSdkClientTest class to the test counterpart of its source package. Delete the duplicate DatabricksSdkClientTest class.
- DatabricksThriftAccessor will now use connection param `asyncPollIntervalMillis`. Previously, the poll interval was hardcoded to 1 second.

## Testing
- Unit tests
- E2E testing

* [PECOBLR-106][PECOBLR-235] Fixes Logging Test intermittent failures and adds support for thriftclient in test (#766)

* logging fixes

* fix logging test

* fix logging test

* fix logging test

* fix logging test

* fix logging test

* use printf in place of echo

* use powershell

* try java side fix

* fix comments

* minor fixes

* Hybrid Results are enabled by default in SEA Mode (#771)

* Made Hybrid results default

* Fixed unit test

* Added Fake service stubs

* Added stubs for Default hybrid mode

* Reverted to old stubs

* Reverted stubs

* Fix

* [PECOBLR-289] Throw exception for column not found (#773)

* [PECOBLR-145] Implement OAuth2RedirectUrlPort (#775)

* Support for providing custom headers from URL (#776)

* Support for custom headers

* Made headers case insensitive

* Added back the case matching in headers

* Formatting fix

* Align behaviour for ResultSet#getBoolean (#774)

* Update version to 1.0.3 (#772)

* make changes for 1.0.3 release

* adds changelog

* updates changelog

* updates changelog

* updates changelog

* [PECOBLR-239][PECOBLR-279] added sql types integration tests (#769)

* added edge cases for string and null

* update stubs

* add test for variant type

* add test for timestamp

* [PECOBLR-310] Refactor internal interfaces into internal package, and fix javadoc for public interfaces (#770)

* Fix javadoc for all public interfaces

* [PECOBLR-164] Support connection param SocketTimeout (#777)

- The default value of the param is kept as 900 seconds (same as earlier value and default in databricks-sdk-java)
- Set the param in thrift, dbfs, and sql-exec clients

* Renaming UC Volume retryable codes and retry timeout parameters as per Docs team feedback (#780)

* Rename UC timeout and retryable parameters based on Docs team feedback

* Set default value as null for BigDecimal (#782)

* [PECOBLR-322] Update SDK to the latest version (0.43.0) (#781)

* [PECOBLR-301] Handle server returned Thrift version as part of open session response gracefully (#779)

* init changes

* Refactor TSparkArrowTypes initialization based on protocol version

* added comments

* added several unit tests

* added more unit tests

* ran ProtocolFeatureUtilTest for all protocol versions

* store protocol version as TProtocolVersion enum.

* move db compute check to protocol feature util

---------

Co-authored-by: Vikrant Puppala <[email protected]>
Co-authored-by: Shivam Raj <[email protected]>
Co-authored-by: Gopal Lal <[email protected]>
Co-authored-by: jayant <[email protected]>
Co-authored-by: Madhav Sainanee <[email protected]>
Co-authored-by: Jothi Prakash <[email protected]>

This branch was previously deployed

1 inactive deployment
azure-prod — 2b5435b3 Deployed Apr 8, 2025 by shivam2680
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.

3 participants