@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/docs/readme.md
DELETED
|
@@ -1,227 +0,0 @@
|
|
|
1
|
-
# Getting started
|
|
2
|
-
|
|
3
|
-
## Table of Contents
|
|
4
|
-
|
|
5
|
-
1. [Foreword](#foreword)
|
|
6
|
-
2. [Example](#example) \
|
|
7
|
-
2.1. [Error handling](#error-handling) \
|
|
8
|
-
2.2. [TCLIService and TCLIService_types](#tcliservice-and-tcliservice_types)
|
|
9
|
-
3. [HiveSession](#hivesession)
|
|
10
|
-
4. [HiveOperation](#hiveoperation) \
|
|
11
|
-
4.1. [HiveUtils](#hiveutils)
|
|
12
|
-
5. [Status](#status)
|
|
13
|
-
6. [Finalize](#finalize)
|
|
14
|
-
|
|
15
|
-
## Foreword
|
|
16
|
-
|
|
17
|
-
The library is written using TypeScript, so the best way to get to know how it works is to look through the code [lib/](/lib/), [tests/e2e](/tests/e2e/) and [examples](/examples).
|
|
18
|
-
|
|
19
|
-
If you find any mistakes, misleading or some confusion feel free to create an issue or send a pull request.
|
|
20
|
-
|
|
21
|
-
## Example
|
|
22
|
-
|
|
23
|
-
```javascript
|
|
24
|
-
const { DBSQLClient } = require('@databricks/sql');
|
|
25
|
-
|
|
26
|
-
const client = new DBSQLClient();
|
|
27
|
-
const utils = DBSQLClient.utils;
|
|
28
|
-
|
|
29
|
-
client.connect({
|
|
30
|
-
host: '...',
|
|
31
|
-
path: '/sql/1.0/endpoints/****************',
|
|
32
|
-
token: 'dapi********************************',
|
|
33
|
-
}).then(async client => {
|
|
34
|
-
const session = await client.openSession();
|
|
35
|
-
|
|
36
|
-
const createTableOperation = await session.executeStatement(
|
|
37
|
-
'CREATE TABLE IF NOT EXISTS pokes (foo INT, bar STRING)'
|
|
38
|
-
);
|
|
39
|
-
await utils.waitUntilReady(createTableOperation, false, () => {});
|
|
40
|
-
await createTableOperation.close();
|
|
41
|
-
|
|
42
|
-
const loadDataOperation = await session.executeStatement(
|
|
43
|
-
'INSERT INTO pokes VALUES(123, "Hello, world!"'
|
|
44
|
-
);
|
|
45
|
-
await utils.waitUntilReady(loadDataOperation, false, () => {});
|
|
46
|
-
await loadDataOperation.close();
|
|
47
|
-
|
|
48
|
-
const selectDataOperation = await session.executeStatement(
|
|
49
|
-
'SELECT * FROM pokes', { runAsync: true }
|
|
50
|
-
);
|
|
51
|
-
await utils.waitUntilReady(selectDataOperation, false, () => {});
|
|
52
|
-
await utils.fetchAll(selectDataOperation);
|
|
53
|
-
await selectDataOperation.close();
|
|
54
|
-
|
|
55
|
-
const result = utils.getResult(selectDataOperation).getValue();
|
|
56
|
-
|
|
57
|
-
console.log(JSON.stringify(result, null, '\t'));
|
|
58
|
-
|
|
59
|
-
await session.close();
|
|
60
|
-
await client.close();
|
|
61
|
-
})
|
|
62
|
-
.catch(error => {
|
|
63
|
-
console.error(error);
|
|
64
|
-
});
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
### Error handling
|
|
68
|
-
|
|
69
|
-
You may guess that some errors related to the network are thrown asynchronously and the driver does not maintain these cases, you should handle it on your own. The simplest way is to subscribe on "error" event:
|
|
70
|
-
|
|
71
|
-
```javascript
|
|
72
|
-
client.on('error', (error) => {
|
|
73
|
-
// ...
|
|
74
|
-
});
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
### TCLIService and TCLIService_types
|
|
78
|
-
|
|
79
|
-
TCLIService and TCLIService_types are generated from [TCLIService.thrift](https://github.com/apache/hive/blob/master/service-rpc/if/TCLIService.thrift).
|
|
80
|
-
|
|
81
|
-
You can use the ones are provided by the driver or you can compile it on your own and provide via constructor to DBSQLClient ([details](https://thrift.apache.org/tutorial/)).
|
|
82
|
-
|
|
83
|
-
```
|
|
84
|
-
thrift -r --gen js TCLIService.thrift
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
TCLIService_types contains a number of constants that API uses, you do not have to know all of them, but sometimes it is useful to refer to [TCLIService.thrift](/thrift/TCLIService.thrift). Also, you may notice that most of the internal structures repeat the structures from [TCLIService.thrift](/thrift/TCLIService.thrift).
|
|
88
|
-
|
|
89
|
-
## HiveSession
|
|
90
|
-
|
|
91
|
-
After you connect to the server you should open session to start working with Hive server.
|
|
92
|
-
|
|
93
|
-
```javascript
|
|
94
|
-
...
|
|
95
|
-
const session = await client.openSession();
|
|
96
|
-
```
|
|
97
|
-
|
|
98
|
-
To open session you must provide [OpenSessionRequest](/lib/hive/Commands/OpenSessionCommand.ts#L20) - the only required parameter is "client_protocol", which synchronizes the version of HiveServer2 API.
|
|
99
|
-
|
|
100
|
-
Into "configuration" you may set any of the configurations that required for the session of your Hive instance.
|
|
101
|
-
|
|
102
|
-
After the session is opened you will have the [HiveSession](/lib/HiveSession.ts) instance.
|
|
103
|
-
|
|
104
|
-
Class [HiveSession](/lib/HiveSession.ts) is a facade for API that works with [SessionHandle](/lib/hive/Types/index.ts#L77).
|
|
105
|
-
|
|
106
|
-
The method you will use the most is `executeStatement`
|
|
107
|
-
|
|
108
|
-
```javascript
|
|
109
|
-
...
|
|
110
|
-
const operation = await session.executeStatement(
|
|
111
|
-
'CREATE TABLE IF NOT EXISTS pokes (foo INT, bar STRING)',
|
|
112
|
-
{ runSync: true }
|
|
113
|
-
);
|
|
114
|
-
```
|
|
115
|
-
|
|
116
|
-
- "statement" is DDL/DML statement (CREATE TABLE, INSERT, UPDATE, SELECT, LOAD, etc.)
|
|
117
|
-
|
|
118
|
-
- [options](/lib/contracts/IHiveSession.ts#L14)
|
|
119
|
-
|
|
120
|
-
- runAsync allows executing operation asynchronously.
|
|
121
|
-
|
|
122
|
-
- confOverlay overrides session configuration properties.
|
|
123
|
-
|
|
124
|
-
- timeout is the maximum time to execute an operation. It has Buffer type because timestamp in Hive has capacity 64. So for such value, you should use [node-int64](https://www.npmjs.com/package/node-int64) npm module.
|
|
125
|
-
|
|
126
|
-
To know other methods see [IHiveSession](/lib/contracts/IHiveSession.ts) and [examples/session.js](/examples/session.js).
|
|
127
|
-
|
|
128
|
-
## HiveOperation
|
|
129
|
-
|
|
130
|
-
In most cases, HiveSession methods return [HiveOperation](/lib/HiveOperation.ts), which helps you to retrieve requested data.
|
|
131
|
-
|
|
132
|
-
After you fetch the result, the operation will have [TableSchema](/lib/hive/Types/index.ts#L143) and data (Array<[RowSet](/lib/hive/Types/index.ts#L218)>).
|
|
133
|
-
|
|
134
|
-
### HiveUtils
|
|
135
|
-
|
|
136
|
-
Operation is executed asynchrnously, so before retrieving the result, you have to wait until it has finished state.
|
|
137
|
-
|
|
138
|
-
```javascript
|
|
139
|
-
...
|
|
140
|
-
const response = await operation.status();
|
|
141
|
-
const isReady = response.operationState === TCLIService_types.TOperationState.FINISHED_STATE;
|
|
142
|
-
```
|
|
143
|
-
|
|
144
|
-
Also, the result is fetched by portitions, the size of a portion you can set by method [setMaxRows()](/lib/HiveOperation.ts#L115).
|
|
145
|
-
|
|
146
|
-
```javascript
|
|
147
|
-
...
|
|
148
|
-
operation.setMaxRows(500);
|
|
149
|
-
const status = await operation.fetch();
|
|
150
|
-
```
|
|
151
|
-
|
|
152
|
-
After you fetch all data and you have schema and set of data, you can transfrom data in readable format.
|
|
153
|
-
|
|
154
|
-
```javascript
|
|
155
|
-
...
|
|
156
|
-
const schema = operation.getSchema();
|
|
157
|
-
const data = operation.getData();
|
|
158
|
-
```
|
|
159
|
-
|
|
160
|
-
To simplify this process, you may use [HiveUtils](/lib/utils/HiveUtils.ts).
|
|
161
|
-
|
|
162
|
-
```typescript
|
|
163
|
-
/**
|
|
164
|
-
* Executes until operation has status finished or has one of the invalid states
|
|
165
|
-
*
|
|
166
|
-
* @param operation
|
|
167
|
-
* @param progress flag for operation status command. If it sets true, response will include progressUpdateResponse with progress information
|
|
168
|
-
* @param callback if callback specified it will be called each time the operation status response received and it will be passed as first parameter
|
|
169
|
-
*/
|
|
170
|
-
waitUntilReady(
|
|
171
|
-
operation: IOperation,
|
|
172
|
-
progress?: boolean,
|
|
173
|
-
callback?: Function
|
|
174
|
-
): Promise<IOperation>
|
|
175
|
-
|
|
176
|
-
/**
|
|
177
|
-
* Fetch data until operation hasMoreRows
|
|
178
|
-
*
|
|
179
|
-
* @param operation
|
|
180
|
-
*/
|
|
181
|
-
fetchAll(operation: IOperation): Promise<IOperation>
|
|
182
|
-
|
|
183
|
-
/**
|
|
184
|
-
* Transforms operation result
|
|
185
|
-
*
|
|
186
|
-
* @param operation
|
|
187
|
-
* @param resultHandler - you may specify your own handler. If not specified the result is transformed to JSON
|
|
188
|
-
*/
|
|
189
|
-
getResult(
|
|
190
|
-
operation: IOperation,
|
|
191
|
-
resultHandler?: IOperationResult
|
|
192
|
-
): IOperationResult
|
|
193
|
-
```
|
|
194
|
-
|
|
195
|
-
*NOTICE*
|
|
196
|
-
|
|
197
|
-
- [node-int64](https://www.npmjs.com/package/node-int64) is used for types with capacity 64
|
|
198
|
-
|
|
199
|
-
- to know how data is presented in JSON you may look at [JsonResult.test.js](/tests/unit/result/JsonResult.test.js)
|
|
200
|
-
|
|
201
|
-
For more details see [IOperation](/lib/contracts/IOperation.ts).
|
|
202
|
-
|
|
203
|
-
### Example
|
|
204
|
-
|
|
205
|
-
```javascript
|
|
206
|
-
const { DBSQLClient } = require('@databricks/sql');
|
|
207
|
-
const utils = DBSQLClient.utils;
|
|
208
|
-
...
|
|
209
|
-
await utils.waitUntilReady(
|
|
210
|
-
operation,
|
|
211
|
-
true,
|
|
212
|
-
(stateResponse) => {
|
|
213
|
-
console.log(stateResponse.taskStatus);
|
|
214
|
-
}
|
|
215
|
-
);
|
|
216
|
-
await utils.fetchAll(operation);
|
|
217
|
-
|
|
218
|
-
const result = utils.getResult(operation).getValue();
|
|
219
|
-
```
|
|
220
|
-
|
|
221
|
-
## Status
|
|
222
|
-
|
|
223
|
-
You may notice, that most of the operations return [Status](/lib/dto/Status.ts) that helps you to determine the state of an operation. Also, status contains the error.
|
|
224
|
-
|
|
225
|
-
## Finalize
|
|
226
|
-
|
|
227
|
-
After you finish working with the operation, session or client it is better to close it, each of them has a respective method (`close()`).
|
package/docs/troubleshooting.md
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
# Troubleshooting
|
|
2
|
-
|
|
3
|
-
This section contains recipies for common errors.
|
|
4
|
-
|
|
5
|
-
- [413 FULL head](#413-full-head)
|
|
6
|
-
|
|
7
|
-
## 413 FULL head
|
|
8
|
-
|
|
9
|
-
Related to issue [HIVE-11720](https://issues.apache.org/jira/browse/HIVE-11720)
|
|
10
|
-
|
|
11
|
-
Workaround:
|
|
12
|
-
|
|
13
|
-
increase the properties
|
|
14
|
-
|
|
15
|
-
hive-site.xml
|
|
16
|
-
```xml
|
|
17
|
-
<property>
|
|
18
|
-
<name>hive.server2.thrift.http.response.header.size</name>
|
|
19
|
-
<value>32768</value>
|
|
20
|
-
</property>
|
|
21
|
-
<property>
|
|
22
|
-
<name>hive.server2.thrift.http.request.header.size</name>
|
|
23
|
-
<value>32768</value>
|
|
24
|
-
</property>
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
## Lost connection
|
|
28
|
-
|
|
29
|
-
In this case DBSQLClient you have to reconnect.
|
|
30
|
-
|
|
31
|
-
To define if the connection lost, you should subscribe on event "close":
|
|
32
|
-
|
|
33
|
-
```javascript
|
|
34
|
-
client.on('close', () => {
|
|
35
|
-
// do reconnect
|
|
36
|
-
});
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
Here is an example how you can manage reconnection:
|
|
40
|
-
|
|
41
|
-
```javascript
|
|
42
|
-
const { DBSQLClient } = require('@databricks/sql');
|
|
43
|
-
|
|
44
|
-
const RECONNECT_ATTEMPTS = 50;
|
|
45
|
-
const RECONNECT_TIMEOUT = 3000; // millisecond
|
|
46
|
-
|
|
47
|
-
const client = new DBSQLClient();
|
|
48
|
-
|
|
49
|
-
client.on('close', () => {
|
|
50
|
-
console.error('[Connection Lost]');
|
|
51
|
-
|
|
52
|
-
connect(RECONNECT_ATTEMPTS).catch(error => {
|
|
53
|
-
console.error('[Connection Failed]', error);
|
|
54
|
-
});
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
connect(RECONNECT_ATTEMPTS).then(async client => {
|
|
58
|
-
// work with client
|
|
59
|
-
}, (error) => {
|
|
60
|
-
console.error('[Connection Failed]', error);
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
const connect = (attempts) => new Promise((resolve, reject) => {
|
|
64
|
-
setTimeout(() => {
|
|
65
|
-
client.connect(...).then((client) => {
|
|
66
|
-
console.log('Connected successfully!');
|
|
67
|
-
|
|
68
|
-
resolve(client);
|
|
69
|
-
}, (error) => {
|
|
70
|
-
console.error('[Connection Failed] attempt:' + attempts, error.message);
|
|
71
|
-
|
|
72
|
-
if (!attempts) {
|
|
73
|
-
reject(error);
|
|
74
|
-
} else {
|
|
75
|
-
connect(attempts - 1).then(resolve, reject);
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
}, RECONNECT_TIMEOUT);
|
|
79
|
-
});
|
|
80
|
-
```
|
|
81
|
-
|
|
82
|
-
Please, notice, that you do not have to re-create client and pass it to your services,
|
|
83
|
-
after re-connection the old client instance works just fine,
|
|
84
|
-
and you should be able to open session and work as you did before.
|
package/examples/data_types.js
DELETED
|
@@ -1,173 +0,0 @@
|
|
|
1
|
-
const { DBSQLClient } = require('../');
|
|
2
|
-
|
|
3
|
-
const client = new DBSQLClient();
|
|
4
|
-
|
|
5
|
-
const utils = DBSQLClient.utils;
|
|
6
|
-
|
|
7
|
-
const [host, path, token] = process.argv.slice(2);
|
|
8
|
-
|
|
9
|
-
client.connect({ host, path, token }).then(async client => {
|
|
10
|
-
try {
|
|
11
|
-
client.on('error', (error) => {
|
|
12
|
-
console.error(error);
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
const session = await client.openSession();
|
|
16
|
-
|
|
17
|
-
await testPrimitiveTypes(session);
|
|
18
|
-
await testComplexTypes(session);
|
|
19
|
-
await testIntervals(session);
|
|
20
|
-
|
|
21
|
-
const status = await session.close();
|
|
22
|
-
console.log(status.success());
|
|
23
|
-
await client.close();
|
|
24
|
-
} catch (error) {
|
|
25
|
-
console.error(error);
|
|
26
|
-
await client.close();
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
const testPrimitiveTypes = async (session) => {
|
|
31
|
-
try {
|
|
32
|
-
console.log('[info] create primitiveTypes');
|
|
33
|
-
await execute(session, `
|
|
34
|
-
CREATE TABLE IF NOT EXISTS primitiveTypes (
|
|
35
|
-
bool boolean,
|
|
36
|
-
tiny_int tinyint,
|
|
37
|
-
small_int smallint,
|
|
38
|
-
int_type int,
|
|
39
|
-
big_int bigint,
|
|
40
|
-
flt float,
|
|
41
|
-
dbl double,
|
|
42
|
-
dec decimal(3,2),
|
|
43
|
-
str string,
|
|
44
|
-
ts timestamp,
|
|
45
|
-
bin binary,
|
|
46
|
-
chr char(10),
|
|
47
|
-
vchr varchar(10),
|
|
48
|
-
dat date
|
|
49
|
-
)`
|
|
50
|
-
);
|
|
51
|
-
console.log('[info] insert into primitiveTypes');
|
|
52
|
-
await execute(session, `insert into primitiveTypes (
|
|
53
|
-
bool,
|
|
54
|
-
tiny_int,
|
|
55
|
-
small_int,
|
|
56
|
-
int_type,
|
|
57
|
-
big_int,
|
|
58
|
-
flt,
|
|
59
|
-
dbl,
|
|
60
|
-
dec,
|
|
61
|
-
str,
|
|
62
|
-
ts,
|
|
63
|
-
bin,
|
|
64
|
-
chr,
|
|
65
|
-
vchr,
|
|
66
|
-
dat
|
|
67
|
-
) values (
|
|
68
|
-
true,
|
|
69
|
-
127,
|
|
70
|
-
32000,
|
|
71
|
-
4000000,
|
|
72
|
-
372036854775807,
|
|
73
|
-
1.2,
|
|
74
|
-
2.2,
|
|
75
|
-
3.2,
|
|
76
|
-
'data',
|
|
77
|
-
'2014-01-17 00:17:13',
|
|
78
|
-
'data',
|
|
79
|
-
'a',
|
|
80
|
-
'b',
|
|
81
|
-
'2014-01-17'
|
|
82
|
-
)`);
|
|
83
|
-
console.log('[info] fetch primitiveTypes');
|
|
84
|
-
const result = await execute(session, 'select * from primitiveTypes');
|
|
85
|
-
|
|
86
|
-
console.log(result);
|
|
87
|
-
} finally {
|
|
88
|
-
await execute(session, 'drop table primitiveTypes');
|
|
89
|
-
}
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
const testIntervals = async (session) => {
|
|
93
|
-
try {
|
|
94
|
-
console.log('[info] create intervalTypes');
|
|
95
|
-
await execute(session, `
|
|
96
|
-
CREATE TABLE IF NOT EXISTS intervalTypes AS
|
|
97
|
-
SELECT INTERVAL '1' day AS day_interval,
|
|
98
|
-
INTERVAL '1' month AS month_interval
|
|
99
|
-
`);
|
|
100
|
-
console.log('[info] describe intervalTypes');
|
|
101
|
-
console.log(await execute(session, `desc intervalTypes`));
|
|
102
|
-
console.log('[info] fetch intervalTypes');
|
|
103
|
-
console.log(await execute(session, 'select * from intervalTypes'));
|
|
104
|
-
} finally {
|
|
105
|
-
await execute(session, 'drop table intervalTypes');
|
|
106
|
-
}
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
const testComplexTypes = async (session) => {
|
|
110
|
-
try {
|
|
111
|
-
console.log('[info] create dummy');
|
|
112
|
-
await execute(session, `drop table if exists dummy`)
|
|
113
|
-
await execute(session, `create table dummy( id string )`)
|
|
114
|
-
console.log('[info] insert dummy value');
|
|
115
|
-
await execute(session, `insert into dummy (id) values (1)`);
|
|
116
|
-
console.log('[info] create complexTypes');
|
|
117
|
-
await execute(session, `
|
|
118
|
-
CREATE TABLE complexTypes (
|
|
119
|
-
arr_type array<string>,
|
|
120
|
-
map_type map<string, int>,
|
|
121
|
-
struct_type struct<city:string,State:string>
|
|
122
|
-
)
|
|
123
|
-
`);
|
|
124
|
-
console.log('[info] 1. insert complexTypes');
|
|
125
|
-
await execute(session, `
|
|
126
|
-
INSERT INTO table complexTypes SELECT
|
|
127
|
-
array('a', 'b') as arr_type,
|
|
128
|
-
map('key', 12) as map_type,
|
|
129
|
-
named_struct('city','Tampa','State','FL') as struct_type
|
|
130
|
-
FROM dummy
|
|
131
|
-
`);
|
|
132
|
-
console.log('[info] 2. insert complexTypes');
|
|
133
|
-
await execute(session, `
|
|
134
|
-
INSERT INTO table complexTypes SELECT
|
|
135
|
-
array('c', 'd') as arr_type,
|
|
136
|
-
map('key2', 12) as map_type,
|
|
137
|
-
named_struct('city','Albany','State','NY') as struct_type
|
|
138
|
-
FROM dummy
|
|
139
|
-
`);
|
|
140
|
-
console.log('[info] 3. insert complexTypes');
|
|
141
|
-
await execute(session, `
|
|
142
|
-
INSERT INTO table complexTypes SELECT
|
|
143
|
-
array('e', 'd') as arr_type,
|
|
144
|
-
map('key2', 13) as map_type,
|
|
145
|
-
named_struct('city','Los Angeles','State','CA') as struct_type
|
|
146
|
-
FROM dummy
|
|
147
|
-
`);
|
|
148
|
-
console.log('[info] fetch complexTypes');
|
|
149
|
-
console.log(await execute(session, 'select * from complexTypes'));
|
|
150
|
-
} finally {
|
|
151
|
-
await Promise.all([
|
|
152
|
-
execute(session, 'drop table dummy'),
|
|
153
|
-
execute(session, 'drop table complexTypes')
|
|
154
|
-
]);
|
|
155
|
-
}
|
|
156
|
-
};
|
|
157
|
-
|
|
158
|
-
const execute = async (session, statement) => {
|
|
159
|
-
const operation = await session.executeStatement(statement, { runAsync: true });
|
|
160
|
-
|
|
161
|
-
await utils.waitUntilReady(operation, true, (stateResponse) => {
|
|
162
|
-
return;
|
|
163
|
-
if (stateResponse.taskStatus) {
|
|
164
|
-
console.log(stateResponse.taskStatus);
|
|
165
|
-
} else {
|
|
166
|
-
console.log(utils.formatProgress(stateResponse.progressUpdateResponse));
|
|
167
|
-
}
|
|
168
|
-
});
|
|
169
|
-
await utils.fetchAll(operation);
|
|
170
|
-
await operation.close();
|
|
171
|
-
|
|
172
|
-
return utils.getResult(operation).getValue();
|
|
173
|
-
};
|
package/examples/repl
DELETED
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const { DBSQLClient } = require('..');
|
|
4
|
-
const repl = require('node:repl');
|
|
5
|
-
const { Console } = require('node:console');
|
|
6
|
-
const { Transform } = require('node:stream');
|
|
7
|
-
const { program } = require('commander');
|
|
8
|
-
|
|
9
|
-
const ts = new Transform({ transform(chunk, enc, cb) { cb(null, chunk) } })
|
|
10
|
-
const logger = new Console({ stdout: ts })
|
|
11
|
-
|
|
12
|
-
async function initClient({ host, endpointId, token }) {
|
|
13
|
-
const client = new DBSQLClient();
|
|
14
|
-
return client.connect({
|
|
15
|
-
host,
|
|
16
|
-
path: `/sql/1.0/endpoints/${endpointId}`,
|
|
17
|
-
token,
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
async function runQuery(session, query) {
|
|
22
|
-
const utils = DBSQLClient.utils;
|
|
23
|
-
|
|
24
|
-
const queryOperation = await session.executeStatement(query, { runAsync: true });
|
|
25
|
-
await utils.waitUntilReady(queryOperation, false, () => {});
|
|
26
|
-
await utils.fetchAll(queryOperation);
|
|
27
|
-
await queryOperation.close();
|
|
28
|
-
|
|
29
|
-
return utils.getResult(queryOperation).getValue();
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
const format = {
|
|
33
|
-
reset: '\x1b[0m',
|
|
34
|
-
bold: '\x1b[1m',
|
|
35
|
-
|
|
36
|
-
fg: {
|
|
37
|
-
black: '\x1b[30m',
|
|
38
|
-
red: '\x1b[31m',
|
|
39
|
-
green: '\x1b[32m',
|
|
40
|
-
yellow: '\x1b[33m',
|
|
41
|
-
blue: '\x1b[34m',
|
|
42
|
-
magenta: '\x1b[35m',
|
|
43
|
-
cyan: '\x1b[36m',
|
|
44
|
-
white: '\x1b[37m',
|
|
45
|
-
},
|
|
46
|
-
|
|
47
|
-
bg: {
|
|
48
|
-
black: '\x1b[40m',
|
|
49
|
-
red: '\x1b[41m',
|
|
50
|
-
green: '\x1b[42m',
|
|
51
|
-
yellow: '\x1b[43m',
|
|
52
|
-
blue: '\x1b[44m',
|
|
53
|
-
magenta: '\x1b[45m',
|
|
54
|
-
cyan: '\x1b[46m',
|
|
55
|
-
white: '\x1b[47m',
|
|
56
|
-
},
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
async function main(args) {
|
|
60
|
-
const client = await initClient(args);
|
|
61
|
-
const session = await client.openSession();
|
|
62
|
-
|
|
63
|
-
repl.start({
|
|
64
|
-
prompt: `${format.bold}dbsql > ${format.reset}`,
|
|
65
|
-
useColors: true,
|
|
66
|
-
eval: async (input, context, filename, callback) => {
|
|
67
|
-
try {
|
|
68
|
-
const result = await runQuery(session, input);
|
|
69
|
-
callback(null, result);
|
|
70
|
-
} catch (e) {
|
|
71
|
-
callback(null, e);
|
|
72
|
-
}
|
|
73
|
-
},
|
|
74
|
-
writer: (output) => {
|
|
75
|
-
if (output instanceof Error) {
|
|
76
|
-
const message = output?.response?.errorMessage || output.message;
|
|
77
|
-
return `${format.fg.red}Error: ${message}${format.reset}`;
|
|
78
|
-
} else {
|
|
79
|
-
if (!output?.length) {
|
|
80
|
-
return `${format.fg.cyan}Query executed successfully, but returned no results${format.reset}`;
|
|
81
|
-
}
|
|
82
|
-
logger.table(output)
|
|
83
|
-
return (ts.read() || '').toString();
|
|
84
|
-
}
|
|
85
|
-
},
|
|
86
|
-
}).on('exit', async () => {
|
|
87
|
-
await session.close();
|
|
88
|
-
await client.close();
|
|
89
|
-
|
|
90
|
-
process.exit();
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
program
|
|
95
|
-
.requiredOption('-h, --host <host>', 'Host (required)')
|
|
96
|
-
.requiredOption('-e, --endpoint <endpointId>', 'SQL endpoint ID (required)')
|
|
97
|
-
.requiredOption('-t, --token <token>', 'Personal access token (required)')
|
|
98
|
-
.showHelpAfterError();
|
|
99
|
-
|
|
100
|
-
program.parse(process.argv);
|
|
101
|
-
|
|
102
|
-
main({
|
|
103
|
-
host: program.opts().host,
|
|
104
|
-
endpointId: program.opts().endpoint,
|
|
105
|
-
token: program.opts().token,
|
|
106
|
-
});
|
package/examples/session.js
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
const { DBSQLClient } = require('../');
|
|
2
|
-
|
|
3
|
-
const client = new DBSQLClient();
|
|
4
|
-
|
|
5
|
-
const utils = DBSQLClient.utils;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const [host, path, token] = process.argv.slice(2);
|
|
9
|
-
|
|
10
|
-
client.connect({ host, path, token }).then(async client => {
|
|
11
|
-
const session = await client.openSession();
|
|
12
|
-
await createTables(session);
|
|
13
|
-
|
|
14
|
-
const typeInfo = await session.getTypeInfo().then(handleOperation);
|
|
15
|
-
console.log(typeInfo);
|
|
16
|
-
console.log();
|
|
17
|
-
|
|
18
|
-
const catalogs = await session.getCatalogs().then(handleOperation);
|
|
19
|
-
console.log(catalogs);
|
|
20
|
-
console.log();
|
|
21
|
-
|
|
22
|
-
const schemas = await session.getSchemas({}).then(handleOperation);
|
|
23
|
-
console.log(schemas);
|
|
24
|
-
console.log();
|
|
25
|
-
|
|
26
|
-
const tables = await session.getTables({}).then(handleOperation);
|
|
27
|
-
console.log(tables);
|
|
28
|
-
console.log();
|
|
29
|
-
|
|
30
|
-
const tableTypes = await session.getTableTypes({}).then(handleOperation);
|
|
31
|
-
console.log(tableTypes);
|
|
32
|
-
console.log();
|
|
33
|
-
|
|
34
|
-
const columns = await session.getColumns({}).then(handleOperation);
|
|
35
|
-
console.log(columns);
|
|
36
|
-
console.log();
|
|
37
|
-
|
|
38
|
-
await session.close();
|
|
39
|
-
}).catch(error => {
|
|
40
|
-
console.log(error);
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
async function handleOperation(operation) {
|
|
44
|
-
await utils.waitUntilReady(operation, true, (stateResponse) => {
|
|
45
|
-
console.log(stateResponse.taskStatus);
|
|
46
|
-
});
|
|
47
|
-
await utils.fetchAll(operation);
|
|
48
|
-
await operation.close();
|
|
49
|
-
return utils.getResult(operation).getValue();
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
const createTables = async (session) => {
|
|
53
|
-
await session.executeStatement('create table if not exists table1 ( id string, value integer )').then(handleOperation);
|
|
54
|
-
await session.executeStatement('create table if not exists table2 ( id string, table1_fk integer )').then(handleOperation);
|
|
55
|
-
};
|
package/examples/usage.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
const { DBSQLClient, thrift } = require('../');
|
|
2
|
-
|
|
3
|
-
const client = new DBSQLClient();
|
|
4
|
-
|
|
5
|
-
const [host, path, token] = process.argv.slice(2);
|
|
6
|
-
|
|
7
|
-
client.connect({ host, path, token }).then(async client => {
|
|
8
|
-
const session = await client.openSession();
|
|
9
|
-
const response = await session.getInfo(
|
|
10
|
-
thrift.TCLIService_types.TGetInfoType.CLI_DBMS_VER
|
|
11
|
-
);
|
|
12
|
-
|
|
13
|
-
console.log(response.getValue());
|
|
14
|
-
|
|
15
|
-
await session.close();
|
|
16
|
-
}).catch(error => {
|
|
17
|
-
console.log(error);
|
|
18
|
-
});
|