Repository navigation
Add NonRowcountQueryPrefixes configuration parameter - #1189
Conversation
Implements NonRowcountQueryPrefixes flag to match Simba JDBC driver behavior. This allows users to specify comma-separated query prefixes (like INSERT, UPDATE, DELETE) that should return result sets instead of row counts. Changes: - Added NON_ROWCOUNT_QUERY_PREFIXES parameter to DatabricksJdbcUrlParams - Added getNonRowcountQueryPrefixes() method to connection context interface and implementation - Updated shouldReturnResultSet() logic to check configured prefixes before SQL patterns - Added 11 comprehensive unit tests covering various scenarios - Updated NEXT_CHANGELOG.md with feature description Usage: NonRowcountQueryPrefixes=INSERT,UPDATE,DELETE,MERGE Tests: All 75 tests pass (64 existing + 11 new) Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
| String upperQuery = trimmedQuery.toUpperCase(); | ||
| for (String prefix : nonRowcountQueryPrefixes) { | ||
| if (upperQuery.startsWith(prefix)) { | ||
| return true; | ||
| } | ||
| } |
There was a problem hiding this comment.
can we use a simple lambda to write this
| String prefixesStr = getParameter(DatabricksJdbcUrlParams.NON_ROWCOUNT_QUERY_PREFIXES); | ||
| if (prefixesStr == null || prefixesStr.trim().isEmpty()) { | ||
| return Collections.emptyList(); | ||
| } |
There was a problem hiding this comment.
this will actually never be null because default value is empty? and empty condition will be handled by the lambda below
| String trimmedQuery = trimCommentsAndWhitespaces(query); | ||
|
|
||
| // Check configured non-rowcount prefixes first | ||
| if (nonRowcountQueryPrefixes != null && !nonRowcountQueryPrefixes.isEmpty()) { |
There was a problem hiding this comment.
why have this null and empty check? it can never be null and empty is implicitly handled
Removed the single-parameter static method shouldReturnResultSet(String) in favor of requiring callers to explicitly pass the list of non-rowcount query prefixes. This improves code clarity by making the prefix configuration explicit at all call sites. Updated all test cases to pass Collections.emptyList() or specific prefix lists (INSERT, UPDATE, DELETE) as appropriate. Enhanced UPDATE and DELETE tests to verify behavior both with and without configured prefixes. All 75 tests passing. Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
- Use lambda/stream for prefix matching instead of explicit loop - Remove unnecessary null/empty checks in getNonRowcountQueryPrefixes() since default value is empty string and filter handles empty strings - Remove null test case as the method is only called from connection context which always returns a non-null list All 74 tests passing. Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
sreekanth-db
left a comment
There was a problem hiding this comment.
All the tests we have seems to be focused on the functionality of shouldReturnResultSet and shouldReturnResultSetWithConfig. Can we also add an e2e test (or a fake service test) to test the end user behaviour ?
or we can just cover it in unit tests for |
Added two unit tests to verify execute() method behavior: 1. testExecuteInsertWithNonRowcountQueryPrefixes - verifies INSERT returns result set when NonRowcountQueryPrefixes=INSERT 2. testExecuteInsertWithoutNonRowcountQueryPrefixes - verifies INSERT returns update count (not result set) without prefix configuration These tests demonstrate end-to-end behavior of the configuration parameter through the Statement.execute() API. All 76 tests passing (74 original + 2 new). Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
done |
Description
Implements NonRowcountQueryPrefixes flag to match exiting JDBC driver behavior. This allows users to specify comma-separated query prefixes (like INSERT, UPDATE, DELETE) that should return result sets instead of row counts.
Changes:
Usage:
NonRowcountQueryPrefixes=INSERT,UPDATE,DELETE,MERGE
Testing
Tests: All 75 tests pass (64 existing + 11 new)
Additional Notes to the Reviewer