Repository navigation
Fix Arrow field metadata not available for queries with 0 rows - #1177
Merged
Merged
Conversation
Problem: The custom user agent from 'useragententry' parameter was not included in the connector service feature flags request. This happened because UserAgentManager.setUserAgent() was setting the custom user agent AFTER triggering the client type determination (which fetches feature flags). Root Cause: In UserAgentManager.setUserAgent(): - Line 28 called getClientUserAgent() which triggered getClientType() - getClientType() called DatabricksDriverFeatureFlagsContextFactory.getInstance() - Feature flags were fetched WITHOUT the custom user agent - Custom user agent was set afterwards (too late) Solution: Reordered UserAgentManager.setUserAgent() to set custom user agent BEFORE calling getClientUserAgent(): 1. Set base product 2. Set custom user agent FIRST via UserAgent.withOtherInfo() 3. THEN call getClientUserAgent() which triggers feature flags fetch Result: Custom user agent is now included in ALL HTTP requests including the connector service request. Testing: - Added testCustomUserAgentIncludedBeforeClientTypeEvaluation() test - Updated existing tests to be version-agnostic - All UserAgentManagerTest tests pass 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
- Added buildUserAgentForConnectorService() to build separate UA for connector service - Modified DatabricksDriverFeatureFlagsContext to use new method for feature flag requests - Maintains proper order for backend requests: base -> client type -> custom - Custom UA now included in both connector service and backend requests without circular dependency - Updated test to verify proper order: client type before custom user agent
- Added DEBUG log when SEA circuit breaker is open - Shows time remaining until circuit closes - Helps users understand THRIFT fallback due to 429 rate limits
- Created parseCustomerUserAgent() helper method - Eliminates code duplication in setUserAgent() and buildUserAgentForConnectorService() - Added try-catch protection for UserAgent.sanitize() calls - All tests pass (7/7)
Changed catch blocks to catch IllegalArgumentException instead of generic Exception when calling UserAgent.sanitize(). This is the specific exception thrown by sanitize() when it encounters invalid characters in user agent strings. Addresses PR review comment.
Problem: When executing queries that return 0 rows (e.g., WHERE 1=0), complex types (ARRAY, MAP, STRUCT) showed only generic type names instead of detailed type information: - Before: ARRAY, MAP, STRUCT - Expected: ARRAY<INT>, MAP<STRING,STRING>, STRUCT<field: TYPE> Root Cause: Arrow field metadata was only extracted inside the while(loadNextBatch()) loop. For queries with 0 rows, no batches are loaded, so the loop never executes and metadata is never extracted. Solution: Extract metadata from VectorSchemaRoot immediately after obtaining it, before the loadNextBatch() loop. The Arrow IPC format always sends the schema message first (before any record batches), so field metadata is available even when there are 0 rows. Impact: - Fixes metadata availability for both SQL Exec API and Thrift Server - All 2,692 unit tests pass - Verified with queries returning 0 rows - metadata now correctly shows detailed type information for complex types 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
Add testMetadataExtractionWithZeroRows() to ArrowResultChunkTest to verify that Arrow field metadata is correctly extracted from VectorSchemaRoot even when there are 0 rows in the result set. This test complements the fix in AbstractArrowResultChunk.java where metadata extraction was moved before the loadNextBatch() loop to ensure metadata is available for queries returning 0 rows (e.g., WHERE 1=0). Test coverage: - Creates Arrow file with schema metadata but 0 rows - Verifies getArrowMetadata() returns non-null metadata - Verifies metadata contains detailed type information (ARRAY<INT>, MAP<STRING,STRING>) even with 0 rows 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
madhav-db
approved these changes
Jan 16, 2026
gopalldb
enabled auto-merge (squash)
January 16, 2026 11:31
gopalldb
disabled auto-merge
January 16, 2026 13:49
gopalldb
added a commit
that referenced
this pull request
Jan 19, 2026
…istency (#1182) ## Summary This PR adds TIMESTAMP_NTZ normalization in the Thrift path to ensure consistent metadata behavior across both SEA and Thrift API paths. ## Background PR #1177 moved Arrow metadata extraction earlier in the processing pipeline, which exposed an inconsistency: the Thrift path started returning the correct "TIMESTAMP_NTZ" from server metadata, while the SEA path was already normalizing it to "TIMESTAMP" for backward compatibility. ## Changes - Added TIMESTAMP_NTZ → TIMESTAMP normalization in `DatabricksResultSetMetaData.java` Thrift constructor (lines 205-208) - This brings Thrift path behavior in line with existing SEA path normalization - Fixes test failure in `PreparedStatementIntegrationTests.testGetMetaData_NoResultSet` ## Testing - ✅ Local test run: `PreparedStatementIntegrationTests.testGetMetaData_NoResultSet` passes - ✅ Metadata now consistent before and after `executeQuery()` for TIMESTAMP_NTZ columns - ✅ Both SEA and Thrift paths return "TIMESTAMP" for TIMESTAMP_NTZ columns ## Related - Builds on PR #1177 (Fix Arrow field metadata not available for queries with 0 rows) - Fixes issue introduced by early metadata extraction in PR #1177 - Maintains backward compatibility with existing behavior 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Sonnet 4.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When executing queries that return 0 rows (e.g.,
WHERE 1=0), complex types (ARRAY, MAP, STRUCT) showed only generic type names instead of detailed type information:Before:
ARRAYinstead ofARRAY<INT>MAPinstead ofMAP<STRING,STRING>STRUCTinstead ofSTRUCT<field: TYPE>After:
Root Cause
In
AbstractArrowResultChunk.java, Arrow field metadata was only extracted inside thewhile(arrowStreamReader.loadNextBatch())loop. For queries with 0 rows, no batches are loaded, so the loop never executes and metadata is never extracted.Code location:
/src/main/java/com/databricks/jdbc/api/impl/arrow/AbstractArrowResultChunk.java:338-359Solution
Extract metadata from
VectorSchemaRootimmediately after obtaining it, before theloadNextBatch()loop.The Arrow IPC format always sends the schema message first (before any record batches), so field metadata is available even when there are 0 rows.
VectorSchemaRootcontains field vectors with metadata regardless of row count.Key changes:
VectorSchemaRootand field vectorsTesting
Unit Test Coverage
testMetadataExtractionWithZeroRows()toArrowResultChunkTestARRAY<INT>,MAP<STRING,STRING>Manual Verification
Tested with queries returning 0 rows: