Skip to content

Commit eaa7c5b

Browse files
authored
return response in async mode (#52)
1 parent f4dee40 commit eaa7c5b

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

src/statement/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,10 +164,16 @@ export class Statement {
164164
async fetchResult() {
165165
const response = await this.request.ready();
166166
const text = await response.text();
167+
168+
if (this.executeQueryOptions?.settings?.async_execution) {
169+
return JSONbig.parse(text);
170+
}
171+
167172
const parsed = this.handleParseResponse(text);
168173
const normalized = normalizeResponse(parsed, this.executeQueryOptions);
169174

170175
const { data, meta, statistics } = normalized;
176+
171177
return {
172178
data,
173179
meta,

test/integration/index.test.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,19 @@ describe("integration test", () => {
6060
const row = data[0];
6161
expect(row).toMatchObject({ "1": 1 });
6262
});
63+
it("async query", async () => {
64+
const firebolt = Firebolt({
65+
apiEndpoint: process.env.FIREBOLT_API_ENDPOINT as string
66+
});
67+
68+
const connection = await firebolt.connect(connectionParams);
69+
const statement = await connection.execute("SELECT 1", {
70+
settings: { async_execution: true },
71+
response: { normalizeData: false }
72+
});
73+
const result = await statement.fetchResult();
74+
expect(result.query_id).toBeTruthy();
75+
});
6376
it("returns Date type", async () => {
6477
const firebolt = Firebolt({
6578
apiEndpoint: process.env.FIREBOLT_API_ENDPOINT as string

0 commit comments

Comments
 (0)