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
2 changes: 1 addition & 1 deletion lib/DBSQLSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ export default class DBSQLSession implements IDBSQLSession {
...getArrowOptions(clientConfig),
canDownloadResult: options.useCloudFetch ?? clientConfig.useCloudFetch,
parameters: getQueryParameters(options.namedParameters, options.ordinalParameters),
canDecompressLZ4Result: clientConfig.useLZ4Compression && Boolean(LZ4),
canDecompressLZ4Result: (options.useLZ4Compression ?? clientConfig.useLZ4Compression) && Boolean(LZ4),
});
const response = await this.handleResponse(operationPromise);
const operation = this.createOperation(response);
Expand Down
1 change: 1 addition & 0 deletions lib/contracts/IDBSQLSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export type ExecuteStatementOptions = {
runAsync?: boolean;
maxRows?: number | bigint | Int64 | null;
useCloudFetch?: boolean;
useLZ4Compression?: boolean;
stagingAllowedLocalPath?: string | string[];
namedParameters?: Record<string, DBSQLParameter | DBSQLParameterValue>;
ordinalParameters?: Array<DBSQLParameter | DBSQLParameterValue>;
Expand Down
13 changes: 13 additions & 0 deletions tests/unit/result/ArrowResultHandler.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,4 +229,17 @@ describe('ArrowResultHandler', () => {
});
expect(await result.hasMore()).to.be.false;
});

it('should handle data without LZ4 compression', async () => {
const rowSetProvider = new ResultsProviderStub([sampleRowSet1], undefined);
const result = new ArrowResultHandler(new ClientContextStub(), rowSetProvider, {
status: { statusCode: TStatusCode.SUCCESS_STATUS },
arrowSchema: sampleArrowSchema,
lz4Compressed: false,
});

const { batches } = await result.fetchNext({ limit: 10000 });
const expectedBatches = sampleRowSet1.arrowBatches?.map(({ batch }) => batch) ?? []; // Ensure iterable
expect(batches).to.deep.eq([sampleArrowSchema, ...expectedBatches]);
});
});
20 changes: 20 additions & 0 deletions tests/unit/result/CloudFetchResultHandler.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -379,4 +379,24 @@ describe('CloudFetchResultHandler', () => {
expect(context.invokeWithRetryStub.callCount).to.be.equal(1);
}
});

it('should handle data without LZ4 compression', async () => {
const context = new ClientContextStub();
const rowSetProvider = new ResultsProviderStub([sampleRowSet1], undefined);

const result = new CloudFetchResultHandler(context, rowSetProvider, {
lz4Compressed: false,
status: { statusCode: TStatusCode.SUCCESS_STATUS },
});

context.invokeWithRetryStub.callsFake(async () => ({
request: new Request('localhost'),
response: new Response(sampleArrowBatch, { status: 200 }), // Return only the batch
}));

const { batches } = await result.fetchNext({ limit: 10000 });

// Ensure the batches array matches the expected structure
expect(batches).to.deep.eq([sampleArrowBatch]);
});
});
Loading