Repository navigation
[PECOBLR-262] implement todos in DBFS volume client - #763
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR implements the missing todos in DBFSVolumeClient by providing working implementations for prefixExists, objectExists, and volumeExists, and adds comprehensive tests (integration, E2E, and unit) for these methods.
- Implements real functionality instead of throwing not-implemented exceptions.
- Updates and adds parameterized tests in multiple test files.
- Introduces a new utility function (constructListPath) to streamline list path construction.
Reviewed Changes
Copilot reviewed 7 out of 22 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/test/java/com/databricks/jdbc/integration/fakeservice/tests/DBFSVolumeIntegrationTests.java | Adds new parameterized tests for prefixExists, objectExists, and volumeExists. |
| src/test/java/com/databricks/jdbc/integration/e2e/DBFSVolumeTests.java | Introduces new E2E tests for the implemented methods and adjusts connection context initialization. |
| src/test/java/com/databricks/jdbc/api/impl/volume/DBFSVolumeClientTest.java | Updates tests to reflect the newly implemented functionality instead of not-implemented exceptions. |
| src/main/java/com/databricks/jdbc/api/impl/volume/DBFSVolumeClient.java | Implements prefixExists, objectExists, and volumeExists using listObjects and getListResponse; replaces the unsupported exception behavior. |
| src/main/java/com/databricks/jdbc/common/util/StringUtil.java | Adds the constructListPath utility method to standardize path construction for listing objects. |
Files not reviewed (15)
- src/test/resources/sqlexecapi/dbfsvolumeintegrationtests/testobjectexists.invocation1/mappings/api_2.0_fs_list-43434788-9136-4833-8b5d-2c68a22c6f54.json: Language not supported
- src/test/resources/sqlexecapi/dbfsvolumeintegrationtests/testobjectexists.invocation2/mappings/api_2.0_fs_list-e328925e-d386-4968-b145-c4d2c87918ca.json: Language not supported
- src/test/resources/sqlexecapi/dbfsvolumeintegrationtests/testobjectexists.invocation3/mappings/api_2.0_fs_list-56247609-dd17-4fd5-b187-24c379378fb0.json: Language not supported
- src/test/resources/sqlexecapi/dbfsvolumeintegrationtests/testobjectexists.invocation4/mappings/api_2.0_fs_list-a0481538-72d9-4d04-8871-4535124c3e5b.json: Language not supported
- src/test/resources/sqlexecapi/dbfsvolumeintegrationtests/testobjectexists.invocation5/mappings/api_2.0_fs_list-4d1e2b5d-6a01-4604-b71a-aaab955083ef.json: Language not supported
- src/test/resources/sqlexecapi/dbfsvolumeintegrationtests/testobjectexists.invocation6/mappings/api_2.0_fs_list-763b3832-5743-402b-9191-e1d60fe0404c.json: Language not supported
- src/test/resources/sqlexecapi/dbfsvolumeintegrationtests/testprefixexists.invocation2/mappings/api_2.0_fs_list-e0b492ea-7772-496e-aabe-ed4f3dee7f19.json: Language not supported
- src/test/resources/sqlexecapi/dbfsvolumeintegrationtests/testprefixexists.invocation3/mappings/api_2.0_fs_list-4659140e-5aad-4d12-9ccb-09864b2aa7e9.json: Language not supported
- src/test/resources/sqlexecapi/dbfsvolumeintegrationtests/testprefixexists.invocation4/mappings/api_2.0_fs_list-5bf2f814-cd83-4230-a08a-17397fb59591.json: Language not supported
- src/test/resources/sqlexecapi/dbfsvolumeintegrationtests/testprefixexists.invocation5/mappings/api_2.0_fs_list-3825c80d-1e12-48d2-88cb-f64af793f606.json: Language not supported
- src/test/resources/sqlexecapi/dbfsvolumeintegrationtests/testprefixexists.invocation6/mappings/api_2.0_fs_list-90fd70d5-c7ed-4e35-908f-5abf66694919.json: Language not supported
- src/test/resources/sqlexecapi/dbfsvolumeintegrationtests/testprefixexists.invocation7/mappings/api_2.0_fs_list-47a506ba-d6fe-4db0-8210-f493368f6d44.json: Language not supported
- src/test/resources/sqlexecapi/dbfsvolumeintegrationtests/testprefixexists.invocation8/mappings/api_2.0_fs_list-53d7817c-32db-40fd-b1f2-bd859bac7083.json: Language not supported
- src/test/resources/sqlexecapi/dbfsvolumeintegrationtests/testprefixexists.invocation9/mappings/api_2.0_fs_list-28ae08da-03dd-42a1-beda-0a8db7f67a38.json: Language not supported
- src/test/resources/sqlexecapi/dbfsvolumeintegrationtests/testvolumeexists.invocation1/mappings/api_2.0_fs_list-7e2dbc94-e45b-48c4-9764-a60513adca6f.json: Language not supported
Comments suppressed due to low confidence (2)
src/main/java/com/databricks/jdbc/api/impl/volume/DBFSVolumeClient.java:146
- Ensure that 'constructListPath' correctly distinguishes between folder prefixes and file names; if 'prefix' represents a file rather than a folder, this may lead to an unintended directory scan.
ListResponse listResponse = getListResponse(constructListPath(catalog, schema, volume, prefix));
src/test/java/com/databricks/jdbc/api/impl/volume/DBFSVolumeClientTest.java:112
- [nitpick] Review whether resetting the client in this context may inadvertently affect other state-dependent tests; ensuring proper isolation between tests could further stabilize test outcomes.
reset(client);
| } catch (DatabricksVolumeOperationException e) { | ||
| // If the exception indicates an invalid path (i.e. missing volume name), | ||
| // then the volume does not exist. Otherwise, rethrow with proper error details. | ||
| if (e.getMessage().contains("does not exist")) { |
There was a problem hiding this comment.
Consider checking an error code or a more structured property of the exception instead of relying on substring matching against the exception message, as this approach may be fragile if the message text changes.
| if (e.getMessage().contains("does not exist")) { | |
| if (e.getErrorCode() == DatabricksDriverErrorCode.VOLUME_NOT_FOUND) { |
| try { | ||
| String baseName = StringUtil.getBaseNameFromPath(objectPath); | ||
| ListResponse listResponse = | ||
| getListResponse(constructListPath(catalog, schema, volume, objectPath)); |
There was a problem hiding this comment.
can you explain what are you doing here? don't you need to match the file name?
There was a problem hiding this comment.
The idea is to fetch all files with specified objectPath using /list api. Then do case-sensitive name matching to determine whether object exists or not
samikshya-db
left a comment
There was a problem hiding this comment.
overall, I don't have any concerns on this. Just a few nits. Thanks.
* [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]>
* [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]>
Description
Implemented objectExists, volumeExists and prefixExists functions in DBFSVolumeClient
Testing
Driver test
unit tests
e2e tests
integration tests
Additional Notes to the Reviewer