@databricks/sql 0.1.8-beta.1 → 1.0.0
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 +45 -1
- package/NOTICE +35 -0
- package/README.md +41 -20
- package/dist/DBSQLClient.d.ts +34 -39
- package/dist/DBSQLClient.js +137 -98
- package/dist/DBSQLClient.js.map +1 -1
- package/dist/DBSQLLogger.d.ts +12 -0
- package/dist/DBSQLLogger.js +43 -0
- package/dist/DBSQLLogger.js.map +1 -0
- 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 +55 -0
- package/dist/DBSQLOperation/index.js +139 -0
- package/dist/DBSQLOperation/index.js.map +1 -0
- package/dist/DBSQLSession.d.ts +99 -0
- package/dist/DBSQLSession.js +187 -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 +42 -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 +21 -0
- package/dist/contracts/{IHiveClient.js → IDBSQLClient.js} +1 -1
- package/dist/contracts/IDBSQLClient.js.map +1 -0
- package/dist/contracts/IDBSQLLogger.d.ts +13 -0
- package/dist/contracts/IDBSQLLogger.js +11 -0
- package/dist/contracts/IDBSQLLogger.js.map +1 -0
- package/dist/contracts/{IHiveSession.d.ts → IDBSQLSession.d.ts} +59 -45
- package/dist/contracts/{IHiveSession.js → IDBSQLSession.js} +1 -1
- package/dist/contracts/IDBSQLSession.js.map +1 -0
- package/dist/contracts/IOperation.d.ts +26 -23
- 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 +16 -16
- package/dist/index.js +19 -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 +28 -7
- 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.d.ts +0 -30
- 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,45 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Release History
|
|
2
|
+
|
|
3
|
+
## 1.0.0 (Unreleased)
|
|
4
|
+
|
|
5
|
+
- `DBSQLClient.openSession` now takes a limited set of options (`OpenSessionRequest` instead of Thrift's `TOpenSessionReq`)
|
|
6
|
+
- `DBSQLClient.openSession` now uses the latest protocol version by default
|
|
7
|
+
- Direct results feature is now available for all IOperation methods which support it. To enable direct results feature,
|
|
8
|
+
`maxRows` option should be used
|
|
9
|
+
- Direct results became enabled by default. If `maxRows` is omitted - it will default to `100000`. To disable direct
|
|
10
|
+
results, set `maxRows` to `null`
|
|
11
|
+
- `FunctionNameRequest` type renamed to `FunctionsRequest`
|
|
12
|
+
- `IDBSQLConnectionOptions` type renamed to `ConnectionOptions`
|
|
13
|
+
- `IFetchOptions` renamed to `FetchOptions`
|
|
14
|
+
- `DBSQLOperation.getSchema` will wait for operation completion, like `DBSQLOperation.fetchChunk`/`DBSQLOperation.fetchAll`.
|
|
15
|
+
It also supports the same progress reporting options
|
|
16
|
+
- `runAsync` option is now available for all operations that support it
|
|
17
|
+
- Added logging functionality for logging on client side and added new optional logger param for DBSQLClient constructor
|
|
18
|
+
- Turned on Direct results feature by default
|
|
19
|
+
- Removed legacy Kerberos auth APIs
|
|
20
|
+
|
|
21
|
+
## 0.1.8-beta.2 (2022-09-08)
|
|
22
|
+
|
|
23
|
+
- Operations will wait for cluster to start instead of failing
|
|
24
|
+
- Added support for DirectResults, which speeds up data fetches by reducing the number of server roundtrips when possible
|
|
25
|
+
- `DBSQLOperation` interface simplified: `HiveUtils` were removed and replaced with new methods
|
|
26
|
+
`DBSQLOperation.fetchChunk`/`DBSQLOperation.fetchAll`. New API implements all necessary waiting
|
|
27
|
+
and data conversion routines internally
|
|
28
|
+
- Better TypeScript support
|
|
29
|
+
- Thrift definitions updated to support additional Databricks features
|
|
30
|
+
- User-agent string updated; a part of user-agent string is configurable through `DBSQLClient`'s `clientId` option
|
|
31
|
+
- Connection now uses keep-alive (not configurable at this moment)
|
|
32
|
+
- `DBSQLClient` now prepends slash to path when needed
|
|
33
|
+
- `DBSQLOperation`: default chunk size for data fetching increased from 100 to 100.000
|
|
34
|
+
|
|
35
|
+
### Upgrading
|
|
36
|
+
|
|
37
|
+
`DBSQLClient.utils` was permanently removed. Code which used `utils.waitUntilReady`, `utils.fetchAll`
|
|
38
|
+
and `utils.getResult` to get data should now be replaced with the single `DBSQLOperation.fetchAll` method.
|
|
39
|
+
Progress reporting, previously supported by `utils.waitUntilReady`, is now configurable via
|
|
40
|
+
`DBSQLOperation.fetchChunk`/`DBSQLOperation.fetchAll` options. `DBSQLOperation.setMaxRows` also became
|
|
41
|
+
an option of methods mentioned above.
|
|
42
|
+
|
|
43
|
+
## 0.1.8-beta.1 (2022-06-24)
|
|
44
|
+
|
|
45
|
+
- 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,10 +1,17 @@
|
|
|
1
|
-
# Databricks SQL
|
|
1
|
+
# Databricks SQL Driver for NodeJS
|
|
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.
|
|
11
|
+
|
|
12
|
+
## Documentation
|
|
6
13
|
|
|
7
|
-
|
|
14
|
+
For detailed documentation and usage examples, read the [Getting Started](docs/readme.md) guide.
|
|
8
15
|
|
|
9
16
|
## Requirements
|
|
10
17
|
|
|
@@ -19,60 +26,74 @@ npm i @databricks/sql
|
|
|
19
26
|
## Usage
|
|
20
27
|
|
|
21
28
|
[examples/usage.js](examples/usage.js)
|
|
29
|
+
|
|
22
30
|
```javascript
|
|
23
31
|
const { DBSQLClient } = require('@databricks/sql');
|
|
24
32
|
|
|
25
33
|
const client = new DBSQLClient();
|
|
26
|
-
const utils = DBSQLClient.utils;
|
|
27
34
|
|
|
28
|
-
client
|
|
35
|
+
client
|
|
36
|
+
.connect({
|
|
29
37
|
host: '********.databricks.com',
|
|
30
38
|
path: '/sql/1.0/endpoints/****************',
|
|
31
39
|
token: 'dapi********************************',
|
|
32
|
-
})
|
|
40
|
+
})
|
|
41
|
+
.then(async (client) => {
|
|
33
42
|
const session = await client.openSession();
|
|
34
43
|
|
|
35
44
|
const queryOperation = await session.executeStatement('SELECT "Hello, World!"', { runAsync: true });
|
|
36
|
-
await
|
|
37
|
-
await utils.fetchAll(queryOperation);
|
|
45
|
+
const result = await queryOperation.fetchAll();
|
|
38
46
|
await queryOperation.close();
|
|
39
47
|
|
|
40
|
-
const result = utils.getResult(queryOperation).getValue();
|
|
41
48
|
console.table(result);
|
|
42
49
|
|
|
43
50
|
await session.close();
|
|
44
51
|
await client.close();
|
|
45
|
-
})
|
|
52
|
+
})
|
|
53
|
+
.catch((error) => {
|
|
46
54
|
console.log(error);
|
|
47
|
-
});
|
|
55
|
+
});
|
|
48
56
|
```
|
|
49
57
|
|
|
50
|
-
|
|
58
|
+
## Run Tests
|
|
51
59
|
|
|
52
|
-
|
|
60
|
+
### Unit tests
|
|
53
61
|
|
|
54
|
-
|
|
62
|
+
You can run all unit tests, or specify a specific test to run:
|
|
55
63
|
|
|
56
64
|
```bash
|
|
57
|
-
npm
|
|
65
|
+
npm test
|
|
66
|
+
npm test <path/to/file.test.js>
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### e2e tests
|
|
70
|
+
|
|
71
|
+
Before running end-to-end tests, create a file named `tests/e2e/utils/config.local.js` and set the Databricks SQL connection info:
|
|
72
|
+
|
|
73
|
+
```javascript
|
|
74
|
+
{
|
|
75
|
+
host: '***.databricks.com',
|
|
76
|
+
path: '/sql/1.0/endpoints/***',
|
|
77
|
+
token: 'dapi***',
|
|
78
|
+
database: ['catalog', 'database'],
|
|
79
|
+
}
|
|
58
80
|
```
|
|
59
81
|
|
|
60
|
-
|
|
82
|
+
Then run
|
|
61
83
|
|
|
62
84
|
```bash
|
|
63
85
|
npm run e2e
|
|
86
|
+
npm run e2e <path/to/file.test.js>
|
|
64
87
|
```
|
|
65
88
|
|
|
66
|
-
Before running e2e tests, create local [configuration file](tests/e2e/utils/config.js)
|
|
67
|
-
|
|
68
89
|
## Contributing
|
|
69
90
|
|
|
70
91
|
See [CONTRIBUTING.md](CONTRIBUTING.md)
|
|
71
92
|
|
|
72
93
|
## Issues
|
|
73
94
|
|
|
74
|
-
If you find
|
|
95
|
+
If you find any issues, feel free to create an issue or send a pull request directly.
|
|
75
96
|
|
|
76
97
|
## License
|
|
77
|
-
|
|
98
|
+
|
|
78
99
|
[Apache License 2.0](LICENSE)
|
package/dist/DBSQLClient.d.ts
CHANGED
|
@@ -1,42 +1,37 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
host: string;
|
|
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 IDBSQLClient, { ConnectionOptions, OpenSessionRequest, ClientOptions } from './contracts/IDBSQLClient';
|
|
5
|
+
import IDBSQLSession from './contracts/IDBSQLSession';
|
|
6
|
+
export default class DBSQLClient extends EventEmitter implements IDBSQLClient {
|
|
22
7
|
private client;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
8
|
+
private connection;
|
|
9
|
+
private statusFactory;
|
|
10
|
+
private connectionProvider;
|
|
11
|
+
private authProvider;
|
|
12
|
+
private logger;
|
|
13
|
+
private thrift;
|
|
14
|
+
constructor(options: ClientOptions);
|
|
15
|
+
private getConnectionOptions;
|
|
16
|
+
/**
|
|
17
|
+
* Connects DBSQLClient to endpoint
|
|
18
|
+
* @public
|
|
19
|
+
* @param options - host, path, and token are required
|
|
20
|
+
* @returns Session object that can be used to execute statements
|
|
21
|
+
* @example
|
|
22
|
+
* const session = client.connect({host, path, token});
|
|
23
|
+
*/
|
|
24
|
+
connect(options: ConnectionOptions): Promise<IDBSQLClient>;
|
|
25
|
+
/**
|
|
26
|
+
* Starts new session
|
|
27
|
+
* @public
|
|
28
|
+
* @param request - Can be instantiated with initialSchema, empty by default
|
|
29
|
+
* @returns Session object that can be used to execute statements
|
|
30
|
+
* @throws {StatusError}
|
|
31
|
+
* @example
|
|
32
|
+
* const session = await client.openSession();
|
|
33
|
+
*/
|
|
34
|
+
openSession(request?: OpenSessionRequest): Promise<IDBSQLSession>;
|
|
35
|
+
getClient(): TCLIService.Client;
|
|
36
|
+
close(): Promise<void>;
|
|
41
37
|
}
|
|
42
|
-
export {};
|
package/dist/DBSQLClient.js
CHANGED
|
@@ -1,111 +1,150 @@
|
|
|
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 = require("../thrift/TCLIService_types");
|
|
30
|
+
const HiveDriver_1 = __importDefault(require("./hive/HiveDriver"));
|
|
31
|
+
const Types_1 = require("./hive/Types");
|
|
32
|
+
const DBSQLSession_1 = __importDefault(require("./DBSQLSession"));
|
|
33
|
+
const NoSaslAuthentication_1 = __importDefault(require("./connection/auth/NoSaslAuthentication"));
|
|
34
|
+
const HttpConnection_1 = __importDefault(require("./connection/connections/HttpConnection"));
|
|
35
|
+
const StatusFactory_1 = __importDefault(require("./factory/StatusFactory"));
|
|
36
|
+
const HiveDriverError_1 = __importDefault(require("./errors/HiveDriverError"));
|
|
37
|
+
const utils_1 = require("./utils");
|
|
38
|
+
const PlainHttpAuthentication_1 = __importDefault(require("./connection/auth/PlainHttpAuthentication"));
|
|
39
|
+
const IDBSQLLogger_1 = require("./contracts/IDBSQLLogger");
|
|
40
|
+
const DBSQLLogger_1 = __importDefault(require("./DBSQLLogger"));
|
|
41
|
+
function getInitialNamespaceOptions(catalogName, schemaName) {
|
|
42
|
+
if (!catalogName && !schemaName) {
|
|
43
|
+
return {};
|
|
24
44
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
45
|
+
return {
|
|
46
|
+
initialNamespace: {
|
|
47
|
+
catalogName,
|
|
48
|
+
schemaName,
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
class DBSQLClient extends events_1.EventEmitter {
|
|
53
|
+
constructor(options) {
|
|
54
|
+
super();
|
|
55
|
+
this.thrift = thrift_1.default;
|
|
56
|
+
this.connectionProvider = new HttpConnection_1.default();
|
|
57
|
+
this.authProvider = new NoSaslAuthentication_1.default();
|
|
58
|
+
this.statusFactory = new StatusFactory_1.default();
|
|
59
|
+
this.logger = (options === null || options === void 0 ? void 0 : options.logger) || new DBSQLLogger_1.default();
|
|
60
|
+
this.client = null;
|
|
61
|
+
this.connection = null;
|
|
62
|
+
this.logger.log(IDBSQLLogger_1.LogLevel.info, 'Created DBSQLClient');
|
|
63
|
+
}
|
|
64
|
+
getConnectionOptions(options) {
|
|
65
|
+
const { host, port, token, clientId } = options, otherOptions = __rest(options, ["host", "port", "token", "clientId"]);
|
|
66
|
+
return {
|
|
67
|
+
host,
|
|
68
|
+
port: port || 443,
|
|
69
|
+
options: Object.assign({ https: true }, otherOptions),
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Connects DBSQLClient to endpoint
|
|
74
|
+
* @public
|
|
75
|
+
* @param options - host, path, and token are required
|
|
76
|
+
* @returns Session object that can be used to execute statements
|
|
77
|
+
* @example
|
|
78
|
+
* const session = client.connect({host, path, token});
|
|
79
|
+
*/
|
|
80
|
+
connect(options) {
|
|
81
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
82
|
+
this.authProvider = new PlainHttpAuthentication_1.default({
|
|
83
|
+
username: 'token',
|
|
84
|
+
password: options.token,
|
|
85
|
+
headers: {
|
|
86
|
+
'User-Agent': (0, utils_1.buildUserAgentString)(options.clientId),
|
|
87
|
+
},
|
|
88
|
+
});
|
|
89
|
+
this.connection = yield this.connectionProvider.connect(this.getConnectionOptions(options), this.authProvider);
|
|
90
|
+
this.client = this.thrift.createClient(TCLIService_1.default, this.connection.getConnection());
|
|
91
|
+
this.connection.getConnection().on('error', (error) => {
|
|
92
|
+
this.logger.log(IDBSQLLogger_1.LogLevel.error, JSON.stringify(error));
|
|
93
|
+
this.emit('error', error);
|
|
94
|
+
});
|
|
95
|
+
this.connection.getConnection().on('reconnecting', (params) => {
|
|
96
|
+
this.logger.log(IDBSQLLogger_1.LogLevel.debug, `Reconnecting, params: ${JSON.stringify(params)}`);
|
|
97
|
+
this.emit('reconnecting', params);
|
|
98
|
+
});
|
|
99
|
+
this.connection.getConnection().on('close', () => {
|
|
100
|
+
this.logger.log(IDBSQLLogger_1.LogLevel.debug, 'Closing connection.');
|
|
101
|
+
this.emit('close');
|
|
102
|
+
});
|
|
103
|
+
this.connection.getConnection().on('timeout', () => {
|
|
104
|
+
this.logger.log(IDBSQLLogger_1.LogLevel.debug, 'Connection timed out.');
|
|
105
|
+
this.emit('timeout');
|
|
106
|
+
});
|
|
107
|
+
return this;
|
|
42
108
|
});
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
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) {
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Starts new session
|
|
112
|
+
* @public
|
|
113
|
+
* @param request - Can be instantiated with initialSchema, empty by default
|
|
114
|
+
* @returns Session object that can be used to execute statements
|
|
115
|
+
* @throws {StatusError}
|
|
116
|
+
* @example
|
|
117
|
+
* const session = await client.openSession();
|
|
118
|
+
*/
|
|
119
|
+
openSession(request = {}) {
|
|
86
120
|
var _a;
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
args[_i - 1] = arguments[_i];
|
|
121
|
+
if (!((_a = this.connection) === null || _a === void 0 ? void 0 : _a.isConnected())) {
|
|
122
|
+
return Promise.reject(new HiveDriverError_1.default('DBSQLClient: connection is lost'));
|
|
90
123
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
124
|
+
const driver = new HiveDriver_1.default(this.getClient());
|
|
125
|
+
return driver
|
|
126
|
+
.openSession(Object.assign({ client_protocol_i64: new Types_1.Int64(TCLIService_types_1.TProtocolVersion.SPARK_CLI_SERVICE_PROTOCOL_V6) }, getInitialNamespaceOptions(request.initialCatalog, request.initialSchema)))
|
|
127
|
+
.then((response) => {
|
|
128
|
+
this.statusFactory.create(response.status);
|
|
129
|
+
return new DBSQLSession_1.default(driver, (0, utils_1.definedOrError)(response.sessionHandle), this.logger);
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
getClient() {
|
|
133
|
+
if (!this.client) {
|
|
134
|
+
throw new HiveDriverError_1.default('DBSQLClient: client is not initialized');
|
|
135
|
+
}
|
|
136
|
+
return this.client;
|
|
137
|
+
}
|
|
138
|
+
close() {
|
|
139
|
+
if (!this.connection) {
|
|
140
|
+
return Promise.resolve();
|
|
141
|
+
}
|
|
142
|
+
const thriftConnection = this.connection.getConnection();
|
|
143
|
+
if (typeof thriftConnection.end === 'function') {
|
|
144
|
+
this.connection.getConnection().end();
|
|
145
|
+
}
|
|
146
|
+
return Promise.resolve();
|
|
147
|
+
}
|
|
148
|
+
}
|
|
110
149
|
exports.default = DBSQLClient;
|
|
111
150
|
//# sourceMappingURL=DBSQLClient.js.map
|
package/dist/DBSQLClient.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DBSQLClient.js","sourceRoot":"","sources":["../lib/DBSQLClient.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"DBSQLClient.js","sourceRoot":"","sources":["../lib/DBSQLClient.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oDAA4B;AAE5B,mCAAsC;AACtC,wEAAgD;AAChD,mEAA+D;AAE/D,mEAA2C;AAC3C,wCAAqC;AACrC,kEAA0C;AAK1C,kGAA0E;AAC1E,6FAAqE;AAErE,4EAAoD;AACpD,+EAAuD;AACvD,mCAA+D;AAC/D,wGAAgF;AAChF,2DAAkE;AAClE,gEAAwC;AAExC,SAAS,0BAA0B,CAAC,WAAoB,EAAE,UAAmB;IAC3E,IAAI,CAAC,WAAW,IAAI,CAAC,UAAU,EAAE;QAC/B,OAAO,EAAE,CAAC;KACX;IAED,OAAO;QACL,gBAAgB,EAAE;YAChB,WAAW;YACX,UAAU;SACX;KACF,CAAC;AACJ,CAAC;AAED,MAAqB,WAAY,SAAQ,qBAAY;IAenD,YAAY,OAAsB;QAChC,KAAK,EAAE,CAAC;QAHF,WAAM,G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,CAAC,OAAO,EAAE,CAAC;IAC3B,CAAC;CACF;AAlID,8BAkIC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import winston, { Logger } from 'winston';
|
|
2
|
+
import IDBSQLLogger, { LoggerOptions, LogLevel } from './contracts/IDBSQLLogger';
|
|
3
|
+
export default class DBSQLLogger implements IDBSQLLogger {
|
|
4
|
+
logger: Logger;
|
|
5
|
+
transports: {
|
|
6
|
+
console: winston.transports.ConsoleTransportInstance;
|
|
7
|
+
file?: winston.transports.FileTransportInstance;
|
|
8
|
+
};
|
|
9
|
+
constructor({ level, filepath }?: LoggerOptions);
|
|
10
|
+
log(level: LogLevel, message: string): Promise<void>;
|
|
11
|
+
setLevel(level: LogLevel): void;
|
|
12
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
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 winston_1 = __importDefault(require("winston"));
|
|
16
|
+
const IDBSQLLogger_1 = require("./contracts/IDBSQLLogger");
|
|
17
|
+
class DBSQLLogger {
|
|
18
|
+
constructor({ level = IDBSQLLogger_1.LogLevel.info, filepath } = {}) {
|
|
19
|
+
this.transports = {
|
|
20
|
+
console: new winston_1.default.transports.Console({ handleExceptions: true, level }),
|
|
21
|
+
};
|
|
22
|
+
this.logger = winston_1.default.createLogger({
|
|
23
|
+
transports: [this.transports.console],
|
|
24
|
+
});
|
|
25
|
+
if (filepath) {
|
|
26
|
+
this.transports.file = new winston_1.default.transports.File({ filename: filepath, handleExceptions: true, level });
|
|
27
|
+
this.logger.add(this.transports.file);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
log(level, message) {
|
|
31
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
32
|
+
this.logger.log({ level, message });
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
setLevel(level) {
|
|
36
|
+
this.transports.console.level = level;
|
|
37
|
+
if (this.transports.file) {
|
|
38
|
+
this.transports.file.level = level;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
exports.default = DBSQLLogger;
|
|
43
|
+
//# sourceMappingURL=DBSQLLogger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DBSQLLogger.js","sourceRoot":"","sources":["../lib/DBSQLLogger.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,sDAA0C;AAC1C,2DAAiF;AAEjF,MAAqB,WAAW;IAQ9B,YAAY,EAAE,KAAK,GAAG,uBAAQ,CAAC,IAAI,EAAE,QAAQ,KAAoB,EAAE;QACjE,IAAI,CAAC,UAAU,GAAG;YAChB,OAAO,EAAE,IAAI,iBAAO,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,gBAAgB,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;SAC3E,CAAC;QACF,IAAI,CAAC,MAAM,GAAG,iBAAO,CAAC,YAAY,CAAC;YACjC,UAAU,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC;SACtC,CAAC,CAAC;QACH,IAAI,QAAQ,EAAE;YACZ,IAAI,CAAC,UAAU,CAAC,IAAI,GAAG,IAAI,iBAAO,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,gBAAgB,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;YAC1G,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;SACvC;IACH,CAAC;IAEK,GAAG,CAAC,KAAe,EAAE,OAAe;;YACxC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC;QACtC,CAAC;KAAA;IAED,QAAQ,CAAC,KAAe;QACtB,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,KAAK,GAAG,KAAK,CAAC;QACtC,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE;YACxB,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;SACpC;IACH,CAAC;CACF;AA/BD,8BA+BC"}
|
|
@@ -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
|
+
}
|