Skip to content

Fix NPE when server returns null resultLinks for small CloudFetch results#1466

Open
gopalldb wants to merge 1 commit into
databricks:mainfrom
gopalldb:fix/npe-null-result-links-cloud-fetch
Open

Fix NPE when server returns null resultLinks for small CloudFetch results#1466
gopalldb wants to merge 1 commit into
databricks:mainfrom
gopalldb:fix/npe-null-result-links-cloud-fetch

Conversation

@gopalldb
Copy link
Copy Markdown
Collaborator

Summary

Fixes NullPointerException in AbstractRemoteChunkProvider.populateChunkIndexMap() when the server returns resultLinks=null for small inline results delivered via CloudFetch format (URL_BASED_SET).

Root cause: When canDownloadResult=true, the server may return URL_BASED_SET format but inline the actual data for small results, leaving resultLinks=null. The driver creates a RemoteChunkProvider which calls resultData.getResultLinks().iterator() without a null check — NPE.

Stack trace (reported by Fivetran via support):

java.lang.NullPointerException: Cannot invoke "java.util.List.iterator()" because
the return value of "TRowSet.getResultLinks()" is null
  at AbstractRemoteChunkProvider.populateChunkIndexMap()
  at AbstractRemoteChunkProvider.initializeChunksMap()
  at AbstractRemoteChunkProvider.<init>()
  at RemoteChunkProvider.<init>()
  at ArrowStreamResult.createThriftRemoteChunkProvider()

Fix: Add null guard before iterating resultLinks.

Workaround: Set EnableQueryResultDownload=0 to disable CloudFetch.

Test plan

  • ArrowStreamResultTest — 15 tests pass
  • Code inspection: DatabricksThriftServiceClient at line 367 already has the same null guard pattern (resultLinks == null || resultLinks.isEmpty())

This pull request was AI-assisted by Isaac.

…ults

When canDownloadResult=true, the server may return URL_BASED_SET format
but inline the actual data for small results, leaving resultLinks=null
and putting data in arrowBatches instead.

Two-layer fix:
1. ExecutionResultFactory: when URL_BASED_SET has no resultLinks but has
   inline arrowBatches, fall back to inline arrow path instead of creating
   RemoteChunkProvider.
2. AbstractRemoteChunkProvider: null guard on getResultLinks() as
   defense-in-depth for subsequent fetch responses.

Reported by Fivetran partner via support ticket (driver 3.3.1).

Co-authored-by: Isaac
Signed-off-by: Gopal Lal <gopal.lal@databricks.com>
@gopalldb gopalldb force-pushed the fix/npe-null-result-links-cloud-fetch branch from d20db37 to 290e366 Compare May 22, 2026 11:21
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.

1 participant