@databricks/sql 0.1.8-beta.1 → 0.1.8-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +29 -1
- package/NOTICE +35 -0
- package/README.md +42 -19
- package/dist/DBSQLClient.d.ts +23 -39
- package/dist/DBSQLClient.js +110 -98
- package/dist/DBSQLClient.js.map +1 -1
- package/dist/DBSQLOperation/CompleteOperationHelper.d.ts +13 -0
- package/dist/DBSQLOperation/CompleteOperationHelper.js +61 -0
- package/dist/DBSQLOperation/CompleteOperationHelper.js.map +1 -0
- package/dist/DBSQLOperation/FetchResultsHelper.d.ts +14 -0
- package/dist/DBSQLOperation/FetchResultsHelper.js +79 -0
- package/dist/DBSQLOperation/FetchResultsHelper.js.map +1 -0
- package/dist/DBSQLOperation/OperationStatusHelper.d.ts +17 -0
- package/dist/DBSQLOperation/OperationStatusHelper.js +115 -0
- package/dist/DBSQLOperation/OperationStatusHelper.js.map +1 -0
- package/dist/DBSQLOperation/SchemaHelper.d.ts +10 -0
- package/dist/DBSQLOperation/SchemaHelper.js +39 -0
- package/dist/DBSQLOperation/SchemaHelper.js.map +1 -0
- package/dist/DBSQLOperation/getResult.d.ts +2 -0
- package/dist/DBSQLOperation/getResult.js +19 -0
- package/dist/DBSQLOperation/getResult.js.map +1 -0
- package/dist/DBSQLOperation/index.d.ts +34 -0
- package/dist/DBSQLOperation/index.js +100 -0
- package/dist/DBSQLOperation/index.js.map +1 -0
- package/dist/{HiveSession.d.ts → DBSQLSession.d.ts} +8 -9
- package/dist/DBSQLSession.js +185 -0
- package/dist/DBSQLSession.js.map +1 -0
- package/dist/connection/auth/NoSaslAuthentication.d.ts +2 -2
- package/dist/connection/auth/NoSaslAuthentication.js +9 -9
- package/dist/connection/auth/NoSaslAuthentication.js.map +1 -1
- package/dist/connection/auth/PlainHttpAuthentication.d.ts +2 -2
- package/dist/connection/auth/PlainHttpAuthentication.js +9 -21
- package/dist/connection/auth/PlainHttpAuthentication.js.map +1 -1
- package/dist/connection/auth/helpers/SaslPackageFactory.js +5 -9
- package/dist/connection/auth/helpers/SaslPackageFactory.js.map +1 -1
- package/dist/connection/connections/HttpConnection.d.ts +4 -4
- package/dist/connection/connections/HttpConnection.js +39 -47
- package/dist/connection/connections/HttpConnection.js.map +1 -1
- package/dist/connection/contracts/IAuthentication.d.ts +1 -1
- package/dist/connection/transports/HttpTransport.d.ts +1 -1
- package/dist/connection/transports/HttpTransport.js +16 -31
- package/dist/connection/transports/HttpTransport.js.map +1 -1
- package/dist/contracts/IDBSQLClient.d.ts +14 -0
- package/dist/contracts/{IHiveClient.js → IDBSQLClient.js} +1 -1
- package/dist/contracts/IDBSQLClient.js.map +1 -0
- package/dist/contracts/{IHiveSession.d.ts → IDBSQLSession.d.ts} +9 -7
- package/dist/contracts/{IHiveSession.js → IDBSQLSession.js} +1 -1
- package/dist/contracts/IDBSQLSession.js.map +1 -0
- package/dist/contracts/IOperation.d.ts +21 -21
- package/dist/contracts/IOperation.js +4 -0
- package/dist/contracts/IOperation.js.map +1 -1
- package/dist/dto/InfoValue.d.ts +5 -3
- package/dist/dto/InfoValue.js +11 -14
- package/dist/dto/InfoValue.js.map +1 -1
- package/dist/dto/Status.js +9 -10
- package/dist/dto/Status.js.map +1 -1
- package/dist/errors/AuthenticationError.d.ts +1 -1
- package/dist/errors/AuthenticationError.js +3 -23
- package/dist/errors/AuthenticationError.js.map +1 -1
- package/dist/errors/HiveDriverError.js +2 -22
- package/dist/errors/HiveDriverError.js.map +1 -1
- package/dist/errors/OperationStateError.d.ts +4 -4
- package/dist/errors/OperationStateError.js +6 -24
- package/dist/errors/OperationStateError.js.map +1 -1
- package/dist/errors/StatusError.d.ts +2 -2
- package/dist/errors/StatusError.js +3 -4
- package/dist/errors/StatusError.js.map +1 -1
- package/dist/factory/StatusFactory.d.ts +2 -4
- package/dist/factory/StatusFactory.js +16 -21
- package/dist/factory/StatusFactory.js.map +1 -1
- package/dist/hive/Commands/BaseCommand.d.ts +3 -4
- package/dist/hive/Commands/BaseCommand.js +10 -12
- package/dist/hive/Commands/BaseCommand.js.map +1 -1
- package/dist/hive/Commands/CancelDelegationTokenCommand.d.ts +3 -10
- package/dist/hive/Commands/CancelDelegationTokenCommand.js +7 -26
- package/dist/hive/Commands/CancelDelegationTokenCommand.js.map +1 -1
- package/dist/hive/Commands/CancelOperationCommand.d.ts +3 -9
- package/dist/hive/Commands/CancelOperationCommand.js +7 -26
- package/dist/hive/Commands/CancelOperationCommand.js.map +1 -1
- package/dist/hive/Commands/CloseOperationCommand.d.ts +3 -9
- package/dist/hive/Commands/CloseOperationCommand.js +7 -26
- package/dist/hive/Commands/CloseOperationCommand.js.map +1 -1
- package/dist/hive/Commands/CloseSessionCommand.d.ts +3 -9
- package/dist/hive/Commands/CloseSessionCommand.js +7 -26
- package/dist/hive/Commands/CloseSessionCommand.js.map +1 -1
- package/dist/hive/Commands/ExecuteStatementCommand.d.ts +3 -15
- package/dist/hive/Commands/ExecuteStatementCommand.js +7 -26
- package/dist/hive/Commands/ExecuteStatementCommand.js.map +1 -1
- package/dist/hive/Commands/FetchResultsCommand.d.ts +4 -16
- package/dist/hive/Commands/FetchResultsCommand.js +10 -26
- package/dist/hive/Commands/FetchResultsCommand.js.map +1 -1
- package/dist/hive/Commands/GetCatalogsCommand.d.ts +3 -10
- package/dist/hive/Commands/GetCatalogsCommand.js +7 -26
- package/dist/hive/Commands/GetCatalogsCommand.js.map +1 -1
- package/dist/hive/Commands/GetColumnsCommand.d.ts +3 -14
- package/dist/hive/Commands/GetColumnsCommand.js +7 -26
- package/dist/hive/Commands/GetColumnsCommand.js.map +1 -1
- package/dist/hive/Commands/GetCrossReferenceCommand.d.ts +3 -16
- package/dist/hive/Commands/GetCrossReferenceCommand.js +7 -26
- package/dist/hive/Commands/GetCrossReferenceCommand.js.map +1 -1
- package/dist/hive/Commands/GetDelegationTokenCommand.d.ts +3 -12
- package/dist/hive/Commands/GetDelegationTokenCommand.js +7 -26
- package/dist/hive/Commands/GetDelegationTokenCommand.js.map +1 -1
- package/dist/hive/Commands/GetFunctionsCommand.d.ts +3 -13
- package/dist/hive/Commands/GetFunctionsCommand.js +7 -26
- package/dist/hive/Commands/GetFunctionsCommand.js.map +1 -1
- package/dist/hive/Commands/GetInfoCommand.d.ts +3 -14
- package/dist/hive/Commands/GetInfoCommand.js +7 -26
- package/dist/hive/Commands/GetInfoCommand.js.map +1 -1
- package/dist/hive/Commands/GetOperationStatusCommand.d.ts +3 -21
- package/dist/hive/Commands/GetOperationStatusCommand.js +7 -26
- package/dist/hive/Commands/GetOperationStatusCommand.js.map +1 -1
- package/dist/hive/Commands/GetPrimaryKeysCommand.d.ts +3 -13
- package/dist/hive/Commands/GetPrimaryKeysCommand.js +7 -26
- package/dist/hive/Commands/GetPrimaryKeysCommand.js.map +1 -1
- package/dist/hive/Commands/GetResultSetMetadataCommand.d.ts +3 -10
- package/dist/hive/Commands/GetResultSetMetadataCommand.js +7 -26
- package/dist/hive/Commands/GetResultSetMetadataCommand.js.map +1 -1
- package/dist/hive/Commands/GetSchemasCommand.d.ts +3 -12
- package/dist/hive/Commands/GetSchemasCommand.js +7 -26
- package/dist/hive/Commands/GetSchemasCommand.js.map +1 -1
- package/dist/hive/Commands/GetTableTypesCommand.d.ts +3 -10
- package/dist/hive/Commands/GetTableTypesCommand.js +7 -26
- package/dist/hive/Commands/GetTableTypesCommand.js.map +1 -1
- package/dist/hive/Commands/GetTablesCommand.d.ts +3 -14
- package/dist/hive/Commands/GetTablesCommand.js +7 -26
- package/dist/hive/Commands/GetTablesCommand.js.map +1 -1
- package/dist/hive/Commands/GetTypeInfoCommand.d.ts +3 -10
- package/dist/hive/Commands/GetTypeInfoCommand.js +7 -26
- package/dist/hive/Commands/GetTypeInfoCommand.js.map +1 -1
- package/dist/hive/Commands/OpenSessionCommand.d.ts +9 -28
- package/dist/hive/Commands/OpenSessionCommand.js +16 -26
- package/dist/hive/Commands/OpenSessionCommand.js.map +1 -1
- package/dist/hive/Commands/RenewDelegationTokenCommand.d.ts +3 -10
- package/dist/hive/Commands/RenewDelegationTokenCommand.js +7 -26
- package/dist/hive/Commands/RenewDelegationTokenCommand.js.map +1 -1
- package/dist/hive/HiveDriver.d.ts +24 -49
- package/dist/hive/HiveDriver.js +87 -99
- package/dist/hive/HiveDriver.js.map +1 -1
- package/dist/hive/Types/index.d.ts +7 -218
- package/dist/hive/Types/index.js +11 -2
- package/dist/hive/Types/index.js.map +1 -1
- package/dist/index.d.ts +14 -16
- package/dist/index.js +15 -51
- package/dist/index.js.map +1 -1
- package/dist/result/IOperationResult.d.ts +0 -2
- package/dist/result/JsonResult.d.ts +5 -8
- package/dist/result/JsonResult.js +81 -99
- package/dist/result/JsonResult.js.map +1 -1
- package/dist/result/NullResult.d.ts +1 -3
- package/dist/result/NullResult.js +4 -8
- package/dist/result/NullResult.js.map +1 -1
- package/dist/utils/buildUserAgentString.d.ts +1 -0
- package/dist/utils/buildUserAgentString.js +25 -0
- package/dist/utils/buildUserAgentString.js.map +1 -0
- package/dist/utils/definedOrError.d.ts +1 -0
- package/dist/utils/definedOrError.js +10 -0
- package/dist/utils/definedOrError.js.map +1 -0
- package/dist/utils/formatProgress.d.ts +9 -0
- package/dist/utils/formatProgress.js +24 -0
- package/dist/utils/formatProgress.js.map +1 -0
- package/dist/utils/index.d.ts +4 -0
- package/dist/utils/index.js +37 -0
- package/dist/utils/index.js.map +1 -0
- package/package.json +24 -6
- package/thrift/TCLIService.d.ts +196 -0
- package/thrift/{gen-nodejs/TCLIService.js → TCLIService.js} +1 -397
- package/thrift/TCLIService_types.d.ts +947 -0
- package/thrift/{gen-nodejs/TCLIService_types.js → TCLIService_types.js} +2830 -516
- package/.gitattributes +0 -32
- package/CONTRIBUTING.md +0 -55
- package/dist/HiveClient.d.ts +0 -35
- package/dist/HiveClient.js +0 -156
- package/dist/HiveClient.js.map +0 -1
- package/dist/HiveOperation.d.ts +0 -65
- package/dist/HiveOperation.js +0 -190
- package/dist/HiveOperation.js.map +0 -1
- package/dist/HiveSession.js +0 -197
- package/dist/HiveSession.js.map +0 -1
- package/dist/contracts/IHiveClient.d.ts +0 -10
- package/dist/contracts/IHiveClient.js.map +0 -1
- package/dist/contracts/IHiveSession.js.map +0 -1
- package/dist/hive/Commands/GetQueryIdCommand.d.ts +0 -11
- package/dist/hive/Commands/GetQueryIdCommand.js +0 -34
- package/dist/hive/Commands/GetQueryIdCommand.js.map +0 -1
- package/dist/hive/Commands/SetClientInfoCommand.d.ts +0 -12
- package/dist/hive/Commands/SetClientInfoCommand.js +0 -34
- package/dist/hive/Commands/SetClientInfoCommand.js.map +0 -1
- package/dist/utils/GetResult.d.ts +0 -16
- package/dist/utils/GetResult.js +0 -38
- package/dist/utils/GetResult.js.map +0 -1
- package/dist/utils/HiveUtils.d.ts +0 -11
- package/dist/utils/HiveUtils.js +0 -39
- package/dist/utils/HiveUtils.js.map +0 -1
- package/dist/utils/ProgressUpdateTransformer.d.ts +0 -8
- package/dist/utils/ProgressUpdateTransformer.js +0 -33
- package/dist/utils/ProgressUpdateTransformer.js.map +0 -1
- package/dist/utils/WaitUntilReady.d.ts +0 -16
- package/dist/utils/WaitUntilReady.js +0 -120
- package/dist/utils/WaitUntilReady.js.map +0 -1
- package/docs/readme.md +0 -227
- package/docs/troubleshooting.md +0 -84
- package/examples/data_types.js +0 -173
- package/examples/repl +0 -106
- package/examples/session.js +0 -55
- package/examples/usage.js +0 -18
- package/nyc.config.js +0 -8
- package/tests/e2e/data_types.test.js +0 -353
- package/tests/e2e/utils/config.js +0 -20
- package/tests/e2e/utils/logger.js +0 -22
- package/tests/unit/HiveClient.test.js +0 -153
- package/tests/unit/HiveOperation.test.js +0 -340
- package/tests/unit/HiveSession.test.js +0 -146
- package/tests/unit/connection/auth/PlainHttpAuthentication.test.js +0 -44
- package/tests/unit/connection/connections/HttpConnection.test.js +0 -141
- package/tests/unit/dto/InfoValue.test.js +0 -50
- package/tests/unit/factory/StatusFactory.test.js +0 -62
- package/tests/unit/hive/HiveDriver.test.js +0 -115
- package/tests/unit/hive/commands/CancelDelegationTokenCommand.test.js +0 -43
- package/tests/unit/hive/commands/CancelOperationCommand.test.js +0 -45
- package/tests/unit/hive/commands/CloseOperationCommand.test.js +0 -45
- package/tests/unit/hive/commands/CloseSessionCommand.test.js +0 -38
- package/tests/unit/hive/commands/ExecuteStatementCommand.test.js +0 -54
- package/tests/unit/hive/commands/FetchResultsCommand.test.js +0 -59
- package/tests/unit/hive/commands/GetCatalogsCommand.test.js +0 -50
- package/tests/unit/hive/commands/GetColumnsCommand.test.js +0 -50
- package/tests/unit/hive/commands/GetCrossReferenceCommand.test.js +0 -56
- package/tests/unit/hive/commands/GetDelegationTokenCommand.test.js +0 -45
- package/tests/unit/hive/commands/GetFunctionsCommand.test.js +0 -50
- package/tests/unit/hive/commands/GetInfoCommand.test.js +0 -51
- package/tests/unit/hive/commands/GetOperationStatusCommand.test.js +0 -63
- package/tests/unit/hive/commands/GetPrimaryKeysCommand.test.js +0 -50
- package/tests/unit/hive/commands/GetQueryIdCommand.test.js +0 -42
- package/tests/unit/hive/commands/GetResultSetMetadataCommand.test.js +0 -54
- package/tests/unit/hive/commands/GetSchemasCommand.test.js +0 -52
- package/tests/unit/hive/commands/GetTableTypesCommand.test.js +0 -50
- package/tests/unit/hive/commands/GetTablesCommand.test.js +0 -54
- package/tests/unit/hive/commands/GetTypeInfoCommand.test.js +0 -50
- package/tests/unit/hive/commands/OpenSessionCommand.test.js +0 -43
- package/tests/unit/hive/commands/RenewDelegationTokenCommand.test.js +0 -43
- package/tests/unit/hive/commands/SetClientInfoCommand.test.js +0 -45
- package/tests/unit/result/JsonResult.test.js +0 -295
- package/tests/unit/utils/GetResult.test.js +0 -30
- package/tests/unit/utils/HiveUtils.test.js +0 -60
- package/tests/unit/utils/ProgressUpdateTransformer.test.js +0 -28
- package/tests/unit/utils/WaitUntilReady.test.js +0 -105
- package/thrift/TCLIService.thrift +0 -1299
- package/tsconfig.json +0 -13
package/CHANGELOG.md
CHANGED
|
@@ -1 +1,29 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Release History
|
|
2
|
+
|
|
3
|
+
## 0.1.x (Unreleased)
|
|
4
|
+
|
|
5
|
+
## 0.1.8-beta.2 (2022-09-08)
|
|
6
|
+
|
|
7
|
+
- Operations will wait for cluster to start instead of failing
|
|
8
|
+
- Added support for DirectResults, which speeds up data fetches by reducing the number of server roundtrips when possible
|
|
9
|
+
- `DBSQLOperation` interface simplified: `HiveUtils` were removed and replaced with new methods
|
|
10
|
+
`DBSQLOperation.fetchChunk`/`DBSQLOperation.fetchAll`. New API implements all necessary waiting
|
|
11
|
+
and data conversion routines internally
|
|
12
|
+
- Better TypeScript support
|
|
13
|
+
- Thrift definitions updated to support additional Databricks features
|
|
14
|
+
- User-agent string updated; a part of user-agent string is configurable through `DBSQLClient`'s `clientId` option
|
|
15
|
+
- Connection now uses keep-alive (not configurable at this moment)
|
|
16
|
+
- `DBSQLClient` now prepends slash to path when needed
|
|
17
|
+
- `DBSQLOperation`: default chunk size for data fetching increased from 100 to 100.000
|
|
18
|
+
|
|
19
|
+
### Upgrading
|
|
20
|
+
|
|
21
|
+
`DBSQLClient.utils` was permanently removed. Code which used `utils.waitUntilReady`, `utils.fetchAll`
|
|
22
|
+
and `utils.getResult` to get data should now be replaced with the single `DBSQLOperation.fetchAll` method.
|
|
23
|
+
Progress reporting, previously supported by `utils.waitUntilReady`, is now configurable via
|
|
24
|
+
`DBSQLOperation.fetchChunk`/`DBSQLOperation.fetchAll` options. `DBSQLOperation.setMaxRows` also became
|
|
25
|
+
an option of methods mentioned above.
|
|
26
|
+
|
|
27
|
+
## 0.1.8-beta.1 (2022-06-24)
|
|
28
|
+
|
|
29
|
+
- Initial release
|
package/NOTICE
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
Databricks SQL Driver for NodeJS
|
|
2
|
+
|
|
3
|
+
Copyright (2022) Databricks, Inc.
|
|
4
|
+
|
|
5
|
+
This Software includes software developed at Databricks (https://www.databricks.com/) and its use is subject to the included LICENSE file.
|
|
6
|
+
|
|
7
|
+
Additionally, this Software contains code from the following open source projects:
|
|
8
|
+
|
|
9
|
+
- Hive-Driver version 0.1.7
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
Hive-Driver NOTICES AND INFORMATION BEGIN HERE
|
|
13
|
+
==============================================
|
|
14
|
+
|
|
15
|
+
MIT License
|
|
16
|
+
|
|
17
|
+
Copyright (c) 2020 Volodymyr Liench
|
|
18
|
+
|
|
19
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
20
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
21
|
+
in the Software without restriction, including without limitation the rights
|
|
22
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
23
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
24
|
+
furnished to do so, subject to the following conditions:
|
|
25
|
+
|
|
26
|
+
The above copyright notice and this permission notice shall be included in all
|
|
27
|
+
copies or substantial portions of the Software.
|
|
28
|
+
|
|
29
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
30
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
31
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
32
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
33
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
34
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
35
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,11 +1,20 @@
|
|
|
1
|
-
# Databricks SQL
|
|
1
|
+
# Databricks SQL Driver for NodeJS (Beta)
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+
[](https://www.npmjs.com/package/@databricks/sql)
|
|
5
|
+
[](https://github.com/databricks/databricks-sql-nodejs/actions?query=workflow%3Atest+branch%3Amain)
|
|
6
|
+
[](https://codecov.io/gh/databricks/databricks-sql-nodejs)
|
|
2
7
|
|
|
3
8
|
## Description
|
|
4
9
|
|
|
5
|
-
Databricks SQL Driver is a
|
|
10
|
+
The Databricks SQL Driver for NodeJS is a Javascript driver for applications that connect to Databricks clusters and SQL warehouses. This project is a fork of [Hive Driver](https://github.com/lenchv/hive-driver) which connects via Thrift API.
|
|
6
11
|
|
|
7
12
|
**NOTE: This Driver is Beta.**
|
|
8
13
|
|
|
14
|
+
## Documentation
|
|
15
|
+
|
|
16
|
+
For detailed documentation and usage examples, read the [Getting Started](docs/readme.md) guide.
|
|
17
|
+
|
|
9
18
|
## Requirements
|
|
10
19
|
|
|
11
20
|
- Node.js 14 or newer
|
|
@@ -19,60 +28,74 @@ npm i @databricks/sql
|
|
|
19
28
|
## Usage
|
|
20
29
|
|
|
21
30
|
[examples/usage.js](examples/usage.js)
|
|
31
|
+
|
|
22
32
|
```javascript
|
|
23
33
|
const { DBSQLClient } = require('@databricks/sql');
|
|
24
34
|
|
|
25
35
|
const client = new DBSQLClient();
|
|
26
|
-
const utils = DBSQLClient.utils;
|
|
27
36
|
|
|
28
|
-
client
|
|
37
|
+
client
|
|
38
|
+
.connect({
|
|
29
39
|
host: '********.databricks.com',
|
|
30
40
|
path: '/sql/1.0/endpoints/****************',
|
|
31
41
|
token: 'dapi********************************',
|
|
32
|
-
})
|
|
42
|
+
})
|
|
43
|
+
.then(async (client) => {
|
|
33
44
|
const session = await client.openSession();
|
|
34
45
|
|
|
35
46
|
const queryOperation = await session.executeStatement('SELECT "Hello, World!"', { runAsync: true });
|
|
36
|
-
await
|
|
37
|
-
await utils.fetchAll(queryOperation);
|
|
47
|
+
const result = await queryOperation.fetchAll();
|
|
38
48
|
await queryOperation.close();
|
|
39
49
|
|
|
40
|
-
const result = utils.getResult(queryOperation).getValue();
|
|
41
50
|
console.table(result);
|
|
42
51
|
|
|
43
52
|
await session.close();
|
|
44
53
|
await client.close();
|
|
45
|
-
})
|
|
54
|
+
})
|
|
55
|
+
.catch((error) => {
|
|
46
56
|
console.log(error);
|
|
47
|
-
});
|
|
57
|
+
});
|
|
48
58
|
```
|
|
49
59
|
|
|
50
|
-
|
|
60
|
+
## Run Tests
|
|
51
61
|
|
|
52
|
-
|
|
62
|
+
### Unit tests
|
|
53
63
|
|
|
54
|
-
|
|
64
|
+
You can run all unit tests, or specify a specific test to run:
|
|
55
65
|
|
|
56
66
|
```bash
|
|
57
|
-
npm
|
|
67
|
+
npm test
|
|
68
|
+
npm test <path/to/file.test.js>
|
|
58
69
|
```
|
|
59
70
|
|
|
60
|
-
e2e tests
|
|
71
|
+
### e2e tests
|
|
72
|
+
|
|
73
|
+
Before running end-to-end tests, create a file named `tests/e2e/utils/config.local.js` and set the Databricks SQL connection info:
|
|
74
|
+
|
|
75
|
+
```javascript
|
|
76
|
+
{
|
|
77
|
+
host: '***.databricks.com',
|
|
78
|
+
path: '/sql/1.0/endpoints/***',
|
|
79
|
+
token: 'dapi***',
|
|
80
|
+
database: ['catalog', 'database'],
|
|
81
|
+
}
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
Then run
|
|
61
85
|
|
|
62
86
|
```bash
|
|
63
87
|
npm run e2e
|
|
88
|
+
npm run e2e <path/to/file.test.js>
|
|
64
89
|
```
|
|
65
90
|
|
|
66
|
-
Before running e2e tests, create local [configuration file](tests/e2e/utils/config.js)
|
|
67
|
-
|
|
68
91
|
## Contributing
|
|
69
92
|
|
|
70
93
|
See [CONTRIBUTING.md](CONTRIBUTING.md)
|
|
71
94
|
|
|
72
95
|
## Issues
|
|
73
96
|
|
|
74
|
-
If you find
|
|
97
|
+
If you find any issues, feel free to create an issue or send a pull request directly.
|
|
75
98
|
|
|
76
99
|
## License
|
|
77
|
-
|
|
100
|
+
|
|
78
101
|
[Apache License 2.0](LICENSE)
|
package/dist/DBSQLClient.d.ts
CHANGED
|
@@ -1,42 +1,26 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
port?: number;
|
|
9
|
-
path: string;
|
|
10
|
-
token: string;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* @see IHiveClient
|
|
14
|
-
*/
|
|
15
|
-
interface IDBSQLClient {
|
|
16
|
-
connect(options: IConnectionOptions): Promise<IDBSQLClient>;
|
|
17
|
-
openSession(): Promise<IHiveSession>;
|
|
18
|
-
close(): void;
|
|
19
|
-
}
|
|
20
|
-
export default class DBSQLClient implements IDBSQLClient, EventEmitter {
|
|
21
|
-
static utils: HiveUtils;
|
|
2
|
+
import { EventEmitter } from 'events';
|
|
3
|
+
import TCLIService from '../thrift/TCLIService';
|
|
4
|
+
import { TOpenSessionReq } from '../thrift/TCLIService_types';
|
|
5
|
+
import IDBSQLClient, { IDBSQLConnectionOptions } from './contracts/IDBSQLClient';
|
|
6
|
+
import IDBSQLSession from './contracts/IDBSQLSession';
|
|
7
|
+
export default class DBSQLClient extends EventEmitter implements IDBSQLClient {
|
|
22
8
|
private client;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
eventNames(): (string | symbol)[];
|
|
9
|
+
private connection;
|
|
10
|
+
private statusFactory;
|
|
11
|
+
private connectionProvider;
|
|
12
|
+
private authProvider;
|
|
13
|
+
private thrift;
|
|
14
|
+
constructor();
|
|
15
|
+
private getConnectionOptions;
|
|
16
|
+
connect(options: IDBSQLConnectionOptions): Promise<IDBSQLClient>;
|
|
17
|
+
/**
|
|
18
|
+
* Starts new session
|
|
19
|
+
*
|
|
20
|
+
* @param request
|
|
21
|
+
* @throws {StatusError}
|
|
22
|
+
*/
|
|
23
|
+
openSession(request?: TOpenSessionReq): Promise<IDBSQLSession>;
|
|
24
|
+
getClient(): TCLIService.Client;
|
|
25
|
+
close(): Promise<void>;
|
|
41
26
|
}
|
|
42
|
-
export {};
|
package/dist/DBSQLClient.js
CHANGED
|
@@ -1,111 +1,123 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
12
|
+
var t = {};
|
|
13
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
14
|
+
t[p] = s[p];
|
|
15
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
16
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
17
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
18
|
+
t[p[i]] = s[p[i]];
|
|
7
19
|
}
|
|
8
|
-
|
|
9
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
20
|
+
return t;
|
|
10
21
|
};
|
|
11
22
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
23
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
24
|
};
|
|
14
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
26
|
+
const thrift_1 = __importDefault(require("thrift"));
|
|
27
|
+
const events_1 = require("events");
|
|
28
|
+
const TCLIService_1 = __importDefault(require("../thrift/TCLIService"));
|
|
29
|
+
const TCLIService_types_1 = __importDefault(require("../thrift/TCLIService_types"));
|
|
30
|
+
const HiveDriver_1 = __importDefault(require("./hive/HiveDriver"));
|
|
31
|
+
const DBSQLSession_1 = __importDefault(require("./DBSQLSession"));
|
|
32
|
+
const NoSaslAuthentication_1 = __importDefault(require("./connection/auth/NoSaslAuthentication"));
|
|
33
|
+
const HttpConnection_1 = __importDefault(require("./connection/connections/HttpConnection"));
|
|
34
|
+
const StatusFactory_1 = __importDefault(require("./factory/StatusFactory"));
|
|
35
|
+
const HiveDriverError_1 = __importDefault(require("./errors/HiveDriverError"));
|
|
36
|
+
const utils_1 = require("./utils");
|
|
37
|
+
const PlainHttpAuthentication_1 = __importDefault(require("./connection/auth/PlainHttpAuthentication"));
|
|
38
|
+
class DBSQLClient extends events_1.EventEmitter {
|
|
39
|
+
constructor() {
|
|
40
|
+
super();
|
|
41
|
+
this.thrift = thrift_1.default;
|
|
42
|
+
this.connectionProvider = new HttpConnection_1.default();
|
|
43
|
+
this.authProvider = new NoSaslAuthentication_1.default();
|
|
44
|
+
this.statusFactory = new StatusFactory_1.default();
|
|
45
|
+
this.client = null;
|
|
46
|
+
this.connection = null;
|
|
47
|
+
}
|
|
48
|
+
getConnectionOptions(options) {
|
|
49
|
+
const { host, port, token, clientId } = options, otherOptions = __rest(options, ["host", "port", "token", "clientId"]);
|
|
50
|
+
return {
|
|
51
|
+
host,
|
|
52
|
+
port: port || 443,
|
|
53
|
+
options: Object.assign({ https: true }, otherOptions),
|
|
54
|
+
};
|
|
24
55
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
56
|
+
connect(options) {
|
|
57
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
58
|
+
this.authProvider = new PlainHttpAuthentication_1.default({
|
|
59
|
+
username: 'token',
|
|
60
|
+
password: options.token,
|
|
61
|
+
headers: {
|
|
62
|
+
'User-Agent': (0, utils_1.buildUserAgentString)(options.clientId),
|
|
63
|
+
},
|
|
64
|
+
});
|
|
65
|
+
this.connection = yield this.connectionProvider.connect(this.getConnectionOptions(options), this.authProvider);
|
|
66
|
+
this.client = this.thrift.createClient(TCLIService_1.default, this.connection.getConnection());
|
|
67
|
+
this.connection.getConnection().on('error', (error) => {
|
|
68
|
+
this.emit('error', error);
|
|
69
|
+
});
|
|
70
|
+
this.connection.getConnection().on('reconnecting', (params) => {
|
|
71
|
+
this.emit('reconnecting', params);
|
|
72
|
+
});
|
|
73
|
+
this.connection.getConnection().on('close', () => {
|
|
74
|
+
this.emit('close');
|
|
75
|
+
});
|
|
76
|
+
this.connection.getConnection().on('timeout', () => {
|
|
77
|
+
this.emit('timeout');
|
|
78
|
+
});
|
|
79
|
+
return this;
|
|
42
80
|
});
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
};
|
|
52
|
-
DBSQLClient.prototype.on = function (event, listener) {
|
|
53
|
-
this.client.on(event, listener);
|
|
54
|
-
return this;
|
|
55
|
-
};
|
|
56
|
-
DBSQLClient.prototype.once = function (event, listener) {
|
|
57
|
-
this.client.once(event, listener);
|
|
58
|
-
return this;
|
|
59
|
-
};
|
|
60
|
-
DBSQLClient.prototype.removeListener = function (event, listener) {
|
|
61
|
-
this.client.removeListener(event, listener);
|
|
62
|
-
return this;
|
|
63
|
-
};
|
|
64
|
-
DBSQLClient.prototype.off = function (event, listener) {
|
|
65
|
-
this.client.off(event, listener);
|
|
66
|
-
return this;
|
|
67
|
-
};
|
|
68
|
-
DBSQLClient.prototype.removeAllListeners = function (event) {
|
|
69
|
-
this.client.removeAllListeners(event);
|
|
70
|
-
return this;
|
|
71
|
-
};
|
|
72
|
-
DBSQLClient.prototype.setMaxListeners = function (n) {
|
|
73
|
-
this.client.setMaxListeners(n);
|
|
74
|
-
return this;
|
|
75
|
-
};
|
|
76
|
-
DBSQLClient.prototype.getMaxListeners = function () {
|
|
77
|
-
return this.client.getMaxListeners();
|
|
78
|
-
};
|
|
79
|
-
DBSQLClient.prototype.listeners = function (event) {
|
|
80
|
-
return this.client.listeners(event);
|
|
81
|
-
};
|
|
82
|
-
DBSQLClient.prototype.rawListeners = function (event) {
|
|
83
|
-
return this.client.rawListeners(event);
|
|
84
|
-
};
|
|
85
|
-
DBSQLClient.prototype.emit = function (event) {
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Starts new session
|
|
84
|
+
*
|
|
85
|
+
* @param request
|
|
86
|
+
* @throws {StatusError}
|
|
87
|
+
*/
|
|
88
|
+
openSession(request) {
|
|
86
89
|
var _a;
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
+
if (!((_a = this.connection) === null || _a === void 0 ? void 0 : _a.isConnected())) {
|
|
91
|
+
return Promise.reject(new HiveDriverError_1.default('DBSQLClient: connection is lost'));
|
|
92
|
+
}
|
|
93
|
+
const driver = new HiveDriver_1.default(this.getClient());
|
|
94
|
+
if (!request) {
|
|
95
|
+
request = {
|
|
96
|
+
client_protocol: TCLIService_types_1.default.TProtocolVersion.SPARK_CLI_SERVICE_PROTOCOL_V6,
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
return driver.openSession(request).then((response) => {
|
|
100
|
+
this.statusFactory.create(response.status);
|
|
101
|
+
const session = new DBSQLSession_1.default(driver, (0, utils_1.definedOrError)(response.sessionHandle));
|
|
102
|
+
return session;
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
getClient() {
|
|
106
|
+
if (!this.client) {
|
|
107
|
+
throw new HiveDriverError_1.default('DBSQLClient: client is not initialized');
|
|
108
|
+
}
|
|
109
|
+
return this.client;
|
|
110
|
+
}
|
|
111
|
+
close() {
|
|
112
|
+
if (!this.connection) {
|
|
113
|
+
return Promise.resolve();
|
|
114
|
+
}
|
|
115
|
+
const thriftConnection = this.connection.getConnection();
|
|
116
|
+
if (typeof thriftConnection.end === 'function') {
|
|
117
|
+
this.connection.getConnection().end();
|
|
90
118
|
}
|
|
91
|
-
return
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
return this.client.listenerCount(type);
|
|
95
|
-
};
|
|
96
|
-
DBSQLClient.prototype.prependListener = function (event, listener) {
|
|
97
|
-
this.client.prependListener(event, listener);
|
|
98
|
-
return this;
|
|
99
|
-
};
|
|
100
|
-
DBSQLClient.prototype.prependOnceListener = function (event, listener) {
|
|
101
|
-
this.client.prependOnceListener(event, listener);
|
|
102
|
-
return this;
|
|
103
|
-
};
|
|
104
|
-
DBSQLClient.prototype.eventNames = function () {
|
|
105
|
-
return this.client.eventNames();
|
|
106
|
-
};
|
|
107
|
-
DBSQLClient.utils = new HiveUtils_1.default(TCLIService_types);
|
|
108
|
-
return DBSQLClient;
|
|
109
|
-
}());
|
|
119
|
+
return Promise.resolve();
|
|
120
|
+
}
|
|
121
|
+
}
|
|
110
122
|
exports.default = DBSQLClient;
|
|
111
123
|
//# sourceMappingURL=DBSQLClient.js.map
|
package/dist/DBSQLClient.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DBSQLClient.js","sourceRoot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MAAM,GAAG,IAAI,oBAAU,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC;QAEhD,IAAI,CAAC,OAAO,EAAE;YACZ,OAAO,GAAG;gBACR,eAAe,EAAE,2BAAiB,CAAC,gBAAgB,CAAC,6BAA6B;aAClF,CAAC;SACH;QAED,OAAO,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE;YACnD,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;YAE3C,MAAM,OAAO,GAAG,IAAI,sBAAY,CAAC,MAAM,EAAE,IAAA,sBAAc,EAAC,QAAQ,CAAC,aAAa,CAAC,CAAC,CAAC;YAEjF,OAAO,OAAO,CAAC;QACjB,CAAC,CAAC,CAAC;IACL,CAAC;IAED,SAAS;QACP,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;YAChB,MAAM,IAAI,yBAAe,CAAC,wCAAwC,CAAC,CAAC;SACrE;QAED,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED,KAAK;QACH,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE;YACpB,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;SAC1B;QAED,MAAM,gBAAgB,GAAG,IAAI,CAAC,UAAU,CAAC,aAAa,EAAE,CAAC;QAEzD,IAAI,OAAO,gBAAgB,CAAC,GAAG,KAAK,UAAU,EAAE;YAC9C,IAAI,CAAC,UAAU,CAAC,aAAa,EAAE,CAAC,GAAG,EAAE,CAAC;SACvC;QAED,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC3B,CAAC;CACF;AAnHD,8BAmHC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { TOperationHandle, TCloseOperationResp } from '../../thrift/TCLIService_types';
|
|
2
|
+
import HiveDriver from '../hive/HiveDriver';
|
|
3
|
+
import Status from '../dto/Status';
|
|
4
|
+
export default class CompleteOperationHelper {
|
|
5
|
+
private driver;
|
|
6
|
+
private operationHandle;
|
|
7
|
+
private statusFactory;
|
|
8
|
+
closed: boolean;
|
|
9
|
+
cancelled: boolean;
|
|
10
|
+
constructor(driver: HiveDriver, operationHandle: TOperationHandle, closeOperation?: TCloseOperationResp);
|
|
11
|
+
cancel(): Promise<Status>;
|
|
12
|
+
close(): Promise<Status>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const TCLIService_types_1 = require("../../thrift/TCLIService_types");
|
|
16
|
+
const StatusFactory_1 = __importDefault(require("../factory/StatusFactory"));
|
|
17
|
+
class CompleteOperationHelper {
|
|
18
|
+
constructor(driver, operationHandle, closeOperation) {
|
|
19
|
+
this.statusFactory = new StatusFactory_1.default();
|
|
20
|
+
this.closed = false;
|
|
21
|
+
this.cancelled = false;
|
|
22
|
+
this.driver = driver;
|
|
23
|
+
this.operationHandle = operationHandle;
|
|
24
|
+
if (closeOperation) {
|
|
25
|
+
this.statusFactory.create(closeOperation.status);
|
|
26
|
+
this.closed = true;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
cancel() {
|
|
30
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
31
|
+
if (this.cancelled) {
|
|
32
|
+
return this.statusFactory.create({
|
|
33
|
+
statusCode: TCLIService_types_1.TStatusCode.SUCCESS_STATUS,
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
const response = yield this.driver.cancelOperation({
|
|
37
|
+
operationHandle: this.operationHandle,
|
|
38
|
+
});
|
|
39
|
+
const status = this.statusFactory.create(response.status);
|
|
40
|
+
this.cancelled = true;
|
|
41
|
+
return status;
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
close() {
|
|
45
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
46
|
+
if (this.closed) {
|
|
47
|
+
return this.statusFactory.create({
|
|
48
|
+
statusCode: TCLIService_types_1.TStatusCode.SUCCESS_STATUS,
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
const response = yield this.driver.closeOperation({
|
|
52
|
+
operationHandle: this.operationHandle,
|
|
53
|
+
});
|
|
54
|
+
const status = this.statusFactory.create(response.status);
|
|
55
|
+
this.closed = true;
|
|
56
|
+
return status;
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
exports.default = CompleteOperationHelper;
|
|
61
|
+
//# sourceMappingURL=CompleteOperationHelper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CompleteOperationHelper.js","sourceRoot":"","sources":["../../lib/DBSQLOperation/CompleteOperationHelper.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,sEAAoG;AAEpG,6EAAqD;AAGrD,MAAqB,uBAAuB;IAW1C,YAAY,MAAkB,EAAE,eAAiC,EAAE,cAAoC;QAN/F,kBAAa,GAAG,IAAI,uBAAa,EAAE,CAAC;QAE5C,WAAM,GAAY,KAAK,CAAC;QAExB,cAAS,GAAY,KAAK,CAAC;QAGzB,IAAI,CAAC,MAAM,GAAG,M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LIService_types';
|
|
2
|
+
import HiveDriver from '../hive/HiveDriver';
|
|
3
|
+
export default class FetchResultsHelper {
|
|
4
|
+
private driver;
|
|
5
|
+
private operationHandle;
|
|
6
|
+
private fetchOrientation;
|
|
7
|
+
private statusFactory;
|
|
8
|
+
private prefetchedResults;
|
|
9
|
+
hasMoreRows: boolean;
|
|
10
|
+
constructor(driver: HiveDriver, operationHandle: TOperationHandle, prefetchedResults?: Array<TFetchResultsResp | undefined>);
|
|
11
|
+
private assertStatus;
|
|
12
|
+
private processFetchResponse;
|
|
13
|
+
fetch(maxRows: number): Promise<TRowSet | undefined>;
|
|
14
|
+
}
|