Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
e2000ad
[PECOBLR-1131] Fetch Thrift links from a start offset.
Nov 4, 2025
84e129d
[PECOBLR-1131] Fix chunk index in link creation.
Nov 5, 2025
7d198ec
[PECOBLR-1131] Add integration tests.
Nov 6, 2025
581b98d
[PECOBLR-1131] Fix chunk fetch validation.
Nov 7, 2025
fbedf44
[PECOBLR-1131] Unit tests for result fetch errors.
Nov 7, 2025
58eaec5
[PECOBLR-1131] Revert visibility of a method.
Nov 7, 2025
60fc546
[PECOBLR-1131] Throw exception when chunk absent.
Nov 7, 2025
0794307
[PECOBLR-1131] Format as per conventions.
Nov 7, 2025
0e633e3
Merge branch 'main' into PECOBLR-1131
Nov 8, 2025
070069e
[PECOBLR-1131] Apply spotless formatter.
Nov 8, 2025
4d79420
[PECOBLR--1131] Minor fixes.
Nov 10, 2025
13b33a0
Merge branch 'main' into PECOBLR-1131
samikshya-db Nov 12, 2025
51fca9e
Merge branch 'main' into PECOBLR-1131
Nov 25, 2025
ece4152
[PECOBLR-1131] Minor fixes.
tejassp-db Nov 25, 2025
fdb10bd
[PECOBLR-1131] Add fake integration tests.
tejassp-db Nov 25, 2025
eca4f03
[PECOBLR-1131] Fix failing unit tests.
tejassp-db Nov 28, 2025
25b7e5d
[PECOBLR-1131] Fix tests.
tejassp-db Nov 28, 2025
933fbfc
[PECOBLR-1131] Fix formatting issues.
tejassp-db Nov 28, 2025
6bd358f
PECOBLR-1131 Add Github actions for thrift integ tests.
tejassp-db Dec 1, 2025
ba249e9
PECOBLR-1131 Merge branch 'main' into PECOBLR-1131
tejassp-db Dec 1, 2025
c649d57
PECOBLR-1131 Do not fetch all links in getResultChunks.
tejassp-db Dec 4, 2025
44453e8
Merge branch 'main' into PECOBLR-1131
tejassp-db Dec 4, 2025
3420835
PECOBLR-1131 Update the NEXT_CHANGELOG.md
tejassp-db Dec 18, 2025
9eacee8
Merge branch 'main' into PECOBLR-1131
tejassp-db Dec 18, 2025
ddf4ed7
Merge branch 'main' into PECOBLR-1131
tejassp-db Dec 18, 2025
386736e
PECOBLR-1131 Fix github workflow script
tejassp-db Dec 18, 2025
b99bc72
Merge branch 'main' into PECOBLR-1131
tejassp-db Jan 1, 2026
0ad607d
PECOBLR-1131 Fix failing tests.
tejassp-db Jan 1, 2026
262b0c7
Merge branch 'main' into PECOBLR-1131
tejassp-db Jan 2, 2026
5e6ef1b
PECOBLR-1131 Fix failing tests.
tejassp-db Jan 2, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/prIntegrationTests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
include:
# SQL_EXEC mode: Tests SEA client behavior
# Note: CircuitBreakerIntegrationTests requires THRIFT_SERVER mode (tested in second matrix entry)
- test-command: mvn -B compile test -Dtest=*IntegrationTests,!M2MPrivateKeyCredentialsIntegrationTests,!M2MAuthIntegrationTests,!CircuitBreakerIntegrationTests
- test-command: mvn -B compile test -Dtest=*IntegrationTests,!M2MPrivateKeyCredentialsIntegrationTests,!M2MAuthIntegrationTests,!CircuitBreakerIntegrationTests,!ThriftCloudFetchFakeIntegrationTests
fake-service-type: 'SQL_EXEC'
# THRIFT_SERVER mode: Tests Thrift client behavior and circuit breaker fallback
- test-command: mvn -B compile test -Dtest=*IntegrationTests,!M2MPrivateKeyCredentialsIntegrationTests,!SqlExecApiHybridResultsIntegrationTests,!DBFSVolumeIntegrationTests,!M2MAuthIntegrationTests,!UCVolumeIntegrationTests,!SqlExecApiIntegrationTests
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/runIntegrationTests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Integration Tests Workflow - Main Branch

on:
push:
branches: [main]
branches: [ main ]

jobs:
build-and-test:
Expand All @@ -14,7 +14,7 @@ jobs:
strategy:
matrix:
include:
- test-command: mvn -B compile test -Dtest=*IntegrationTests,!CircuitBreakerIntegrationTests
- test-command: mvn -B compile test -Dtest=*IntegrationTests,!CircuitBreakerIntegrationTests,!ThriftCloudFetchFakeIntegrationTests
token-secret: DATABRICKS_TOKEN
fake-service-type: 'SQL_EXEC'
- test-command: mvn -B compile test -Dtest=*IntegrationTests,!M2MPrivateKeyCredentialsIntegrationTests,!SqlExecApiHybridResultsIntegrationTests,!DBFSVolumeIntegrationTests,!M2MAuthIntegrationTests,!UCVolumeIntegrationTests,!SqlExecApiIntegrationTests
Expand Down
6 changes: 5 additions & 1 deletion NEXT_CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
### Updated

### Fixed

- [PECOBLR-1131] Fix incorrect refetching of expired CloudFetch links when using Thrift protocol.
- Fixed logging to respect params when the driver is shaded.

---
*Note: When making changes, please add your change under the appropriate section with a brief description.*
*Note: When making changes, please add your change under the appropriate section
with a brief description.*
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.databricks.jdbc.api.IDatabricksResultSet;
import com.databricks.jdbc.api.IExecutionStatus;
import com.databricks.jdbc.api.impl.arrow.ArrowStreamResult;
import com.databricks.jdbc.api.impl.arrow.ChunkProvider;
import com.databricks.jdbc.api.impl.converters.ConverterHelper;
import com.databricks.jdbc.api.impl.converters.ObjectConverter;
import com.databricks.jdbc.api.impl.volume.VolumeOperationResult;
Expand Down Expand Up @@ -41,6 +42,7 @@
import java.util.Calendar;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.function.Supplier;
import org.apache.http.entity.InputStreamEntity;

Expand Down Expand Up @@ -2008,6 +2010,14 @@ private BigDecimal applyScaleToBigDecimal(BigDecimal bigDecimal, int columnIndex
return bigDecimal.setScale(scale, RoundingMode.HALF_UP);
}

@VisibleForTesting
public Optional<ChunkProvider> getChunkProvider() {
if (executionResult instanceof ArrowStreamResult) {
return Optional.ofNullable(((ArrowStreamResult) executionResult).getChunkProvider());
}
return Optional.empty();
}

@Override
public String toString() {
return (new ToStringer(DatabricksResultSet.class))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,11 @@ public Long getChunkIndex() {
}

/**
* Returns the starting row offset for this chunk.
* Returns the start row offset of this chunk in the overall result set.
*
* @return the row offset
* @return row offset
*/
public long getRowOffset() {
public long getStartRowOffset() {
return rowOffset;
}

Expand Down Expand Up @@ -156,6 +156,10 @@ public boolean releaseChunk() {
return true;
}

public ExternalLink getChunkLink() {
return chunkLink;
}

/**
* Sets the external link details for this chunk.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,10 @@ public long getAllowedChunksInMemory() {
return allowedChunksInMemory;
}

public T getChunkByIndex(long chunkIndex) {
return chunkIndexToChunksMap.get(chunkIndex);
}

/** Subclasses should override this method to perform their specific cleanup. */
protected void doClose() {
// Default implementation does nothing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,16 @@ public long getChunkCount() {
return chunkProvider.getChunkCount();
}

/**
* Returns the chunk provider for testing purposes.
*
* @return the chunk provider
*/
@VisibleForTesting
public ChunkProvider getChunkProvider() {
return chunkProvider;
}

private void setColumnInfo(TGetResultSetMetadataResp resultManifest) {
columnInfos = new ArrayList<>();
if (resultManifest.getSchema() == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,15 +215,18 @@ private void triggerNextBatchDownload() {
return;
}

// Calculate row offset for this batch
final long batchStartRowOffset = getChunkStartRowOffset(batchStartIndex);

LOGGER.info("Starting batch download from index {}", batchStartIndex);
currentDownloadTask =
CompletableFuture.runAsync(
() -> {
try {
// rowOffset is 0 here as this service is used by RemoteChunkProvider (SEA-only)
// which fetches by chunkIndex, not rowOffset
ChunkLinkFetchResult result =
session.getDatabricksClient().getResultChunks(statementId, batchStartIndex, 0);
session
.getDatabricksClient()
.getResultChunks(statementId, batchStartIndex, batchStartRowOffset);
LOGGER.info(
"Retrieved {} links for batch starting at {} for statement id {}",
result.getChunkLinks().size(),
Expand Down Expand Up @@ -419,6 +422,28 @@ private void prepareNewBatchDownload(long startIndex) {
isDownloadChainStarted.set(false);
}

/**
* Gets the start row offset for a given chunk index.
*
* @param chunkIndex the chunk index to get the row offset for
* @return the start row offset for the chunk
*/
private long getChunkStartRowOffset(long chunkIndex) {
T chunk = chunkIndexToChunksMap.get(chunkIndex);
if (chunk == null) {
// Should never happen.
Copy link
Collaborator

Choose a reason for hiding this comment

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

let's log this

throw new IllegalStateException(
Copy link
Collaborator

Choose a reason for hiding this comment

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

let's throw DatabricksValidationException here - as we push telemetry with these internal exceptions

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

DatabricksValidationException is linked to INPUT_VALIDATION_ERROR error code. Can you suggest an alternative exception.

Copy link
Collaborator

Choose a reason for hiding this comment

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

We could create a new exception stating DatabricksInvalidStateException but I guess just passing INVALID_STATE to DatabricksException lgtm

"Chunk not found in map for index "
+ chunkIndex
+ ". "
+ "Total chunks: "
+ totalChunks
+ ", StatementId: "
+ statementId);
}
return chunk.getStartRowOffset();
}

private boolean isChunkLinkExpired(ExternalLink link) {
if (link == null || link.getExpiration() == null) {
LOGGER.warn("Link or expiration is null, assuming link is expired");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public Void call() throws DatabricksSQLException {
if (chunk.isChunkLinkInvalid()) {
LOGGER.debug("Link invalid for chunk {}, refetching", chunk.getChunkIndex());
ExternalLink freshLink =
linkFetcher.refetchLink(chunk.getChunkIndex(), chunk.getRowOffset());
linkFetcher.refetchLink(chunk.getChunkIndex(), chunk.getStartRowOffset());
chunk.setChunkLink(freshLink);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ public static void verifySuccessStatus(TStatus status, String errorContext, Stri
"Error thrift response received [%s] for statementId [%s]",
errorContext, statementId)
: String.format("Error thrift response received [%s]", errorContext);
LOGGER.error(errorMessage);
Copy link
Collaborator

Choose a reason for hiding this comment

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

why removing the log? We cannot rely on application that it will be logging correctly

throw new DatabricksHttpException(errorMessage, status.getSqlState());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,11 @@ DatabricksResultSet getStatementResult(
* </ul>
*
* @param statementId statement-Id for which chunk should be fetched
* @param chunkIndex chunkIndex for which chunk should be fetched (used by SEA)
* @param rowOffset row offset for fetching results (used by Thrift with FETCH_ABSOLUTE)
* @return ChunkLinkFetchResult containing links and continuation information
* @param chunkIndex chunkIndex for which chunk should be fetched
* @param chunkStartRowOffset the row offset where the chunk starts in the result set
*/
ChunkLinkFetchResult getResultChunks(StatementId statementId, long chunkIndex, long rowOffset)
ChunkLinkFetchResult getResultChunks(
StatementId statementId, long chunkIndex, long chunkStartRowOffset)
throws DatabricksSQLException;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -430,8 +430,9 @@ public void cancelStatement(StatementId typedStatementId) throws DatabricksSQLEx

@Override
public ChunkLinkFetchResult getResultChunks(
StatementId typedStatementId, long chunkIndex, long rowOffset) throws DatabricksSQLException {
// SEA uses chunkIndex; rowOffset is ignored
StatementId typedStatementId, long chunkIndex, long chunkStartRowOffset)
throws DatabricksSQLException {
DatabricksThreadContextHolder.setStatementId(typedStatementId);
String statementId = typedStatementId.toSQLExecStatementId();
LOGGER.debug(
"getResultChunks(statementId={}, chunkIndex={}) using SEA client", statementId, chunkIndex);
Expand Down
Loading
Loading