forked from databricks/databricks-sql-nodejs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbatched_fetch.test.js
41 lines (35 loc) · 1.25 KB
/
batched_fetch.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
const { expect } = require('chai');
const config = require('./utils/config');
const logger = require('./utils/logger')(config.logger);
const { DBSQLClient } = require('../..');
const openSession = async () => {
const client = new DBSQLClient();
const connection = await client.connect({
host: config.host,
path: config.path,
token: config.token,
});
return connection.openSession({
initialCatalog: config.database[0],
initialSchema: config.database[1],
});
};
describe('Data fetching', () => {
const query = `
SELECT *
FROM range(0, 1000) AS t1
LEFT JOIN (SELECT 1) AS t2
`;
it('fetch chunks should return a max row set of chunkSize', async () => {
const session = await openSession();
const operation = await session.executeStatement(query, { runAsync: true, maxRows: null });
let chunkedOp = await operation.fetchChunk({ maxRows: 10 }).catch((error) => logger(error));
expect(chunkedOp.length).to.be.equal(10);
});
it('fetch all should fetch all records', async () => {
const session = await openSession();
const operation = await session.executeStatement(query, { runAsync: true, maxRows: null });
let all = await operation.fetchAll();
expect(all.length).to.be.equal(1000);
});
});