Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions NEXT_CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@
### Fixed
- Integrated Azure U2M flow into driver for improved stability.
- Fixed `ResultSet.getString` for Boolean columns in Metadata result set.
- Fixed volume operations not completing unless the ResultSet is fully iterated.
---
*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 @@ -47,7 +47,8 @@ public VolumeOperationResult(
long totalColumns,
IDatabricksSession session,
IExecutionResult resultHandler,
IDatabricksStatementInternal statement) {
IDatabricksStatementInternal statement)
throws DatabricksSQLException {
this.rowCount = totalRows;
this.columnCount = totalColumns;
this.session = session;
Expand All @@ -57,6 +58,7 @@ public VolumeOperationResult(
DatabricksHttpClientFactory.getInstance()
.getClient(session.getConnectionContext(), HttpClientType.VOLUME);
this.currentRowIndex = -1;
completeVolumeOperation();
}

@VisibleForTesting
Expand All @@ -65,14 +67,16 @@ public VolumeOperationResult(
IDatabricksSession session,
IExecutionResult resultHandler,
IDatabricksHttpClient httpClient,
IDatabricksStatementInternal statement) {
IDatabricksStatementInternal statement)
throws DatabricksSQLException {
this.rowCount = manifest.getTotalRowCount();
this.columnCount = manifest.getSchema().getColumnCount();
this.session = session;
this.resultHandler = resultHandler;
this.statement = statement;
this.httpClient = httpClient;
this.currentRowIndex = -1;
completeVolumeOperation();
}

private void initHandler(IExecutionResult resultHandler) throws DatabricksSQLException {
Expand Down Expand Up @@ -181,7 +185,12 @@ public Object getObject(int columnIndex) throws DatabricksSQLException {
if (columnIndex == 0) {
return volumeOperationProcessor.getStatus().name();
}
String errorMessage = (currentRowIndex < 0) ? "Invalid row access" : "Invalid column access";
String userMessage = (currentRowIndex < 0) ? "Invalid row access" : "Invalid column access";
String errorMessage =
String.format(
"%s, Row: %s, Column: %s, statementID %s",
userMessage, currentRowIndex, columnIndex, statement.getStatementId());
LOGGER.error(errorMessage);
throw new DatabricksVolumeOperationException(
errorMessage, DatabricksDriverErrorCode.VOLUME_OPERATION_INVALID_STATE);
}
Expand All @@ -193,16 +202,21 @@ public long getCurrentRow() {

@Override
public boolean next() throws DatabricksSQLException {
if (hasNext()) {
if (currentRowIndex == -1) {
currentRowIndex++;
return true;
} else {
return false;
}
}

private void completeVolumeOperation() throws DatabricksSQLException {
while (resultHandler.hasNext()) {
validateMetadata();
resultHandler.next();
initHandler(resultHandler);
volumeOperationProcessor.process();
ensureSuccessVolumeProcessorStatus();
currentRowIndex++;
return true;
} else {
return false;
}
}

Expand All @@ -217,7 +231,7 @@ public InputStreamEntity getVolumeOperationInputStream() {

@Override
public boolean hasNext() {
return resultHandler.hasNext();
return currentRowIndex == -1;
}

@Override
Expand Down
Loading
Loading