Skip to content

Commit 9dec7a6

Browse files
committed
add readme
1 parent f0cc1fb commit 9dec7a6

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

README.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@ console.log(rows)
7878
* <a href="#fetch-result">Fetch result</a>
7979
* <a href="#stream-result">Stream result</a>
8080
* <a href="#result-hydration">Result hydration</a>
81+
* <a href="#server-side-async-query-execution">Server-side async queries</a>
82+
* <a href="#execute-async-query">Execute Async Query</a>
83+
* <a href="#check-async-query-status">Check Async Query Status</a>
84+
* <a href="#cancel-async-query">Cancel Async Query</a>
8185
* <a href="#engine-management">Engine management</a>
8286
* <a href="#getbyname">getByName</a>
8387
* <a href="#engine">Engine</a>
@@ -340,6 +344,44 @@ firebolt-sdk maps SQL data types to their corresponding JavaScript equivalents.
340344
| | STRING | String | |
341345
| Date & Time | DATE | Date | |
342346

347+
<a id="Server-side async queries"></a>
348+
## Server-side async query execution
349+
350+
Firebolt supports server-side asynchronous query execution. This feature allows you to run
351+
queries in the background and fetch the results later. This is especially useful for long-running
352+
queries that you don't want to wait for or maintain a persistent connection to the server.
353+
354+
<a id="Execute Async Query"></a>
355+
### Execute Async Query
356+
357+
Executes a query asynchronously. This is useful for long-running queries that you don't want to block the main thread. The resulting statement does not contain data and should only be used to receive an async query token. Token can be saved elsewhere and reused, even on a new connection to check on this query.
358+
359+
```typescript
360+
const statement = await connection.executeAsync(query, executeQueryOptions);
361+
const token = statement.asyncQueryToken; // used to check query status and cancel it
362+
// statement.fetchResult() -- not allowed as there's no result to fetch
363+
```
364+
365+
<a id="Check Async Query Status"></a>
366+
### Check Async Query Status
367+
368+
Checks the status of an asynchronous query. Use this to determine if the query is still running or has completed. `isAsyncQueryRunning` woudl return true or false if the query is running or has finished. `isAsyncQuerySuccessful` would return true if the query has completed successfully, false if it has failed and `undefined` if the query is still running.
369+
370+
```typescript
371+
const token = statement.asyncQueryToken; // can only be fetched for async query
372+
const isRunning = await connection.isAsyncQueryRunning(token);
373+
const isSuccessful = await connection.isAsyncQuerySuccessful(token);
374+
```
375+
376+
<a id="Cancel Async Query"></a>
377+
### Cancel Async Query
378+
379+
Cancels a running asynchronous query. Use this if you need to stop a long-running query, if its execution is no longer needed.
380+
381+
```typescript
382+
const token = statement.asyncQueryToken; // can only be fetched for async query
383+
await connection.cancelAsyncQuery(token);
384+
```
343385

344386
<a id="engine-management"></a>
345387
### Engine management

0 commit comments

Comments
 (0)