@databricks/sql 0.1.8-beta.1
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/.gitattributes +32 -0
- package/CHANGELOG.md +1 -0
- package/CONTRIBUTING.md +55 -0
- package/LICENSE +201 -0
- package/README.md +78 -0
- package/dist/DBSQLClient.d.ts +42 -0
- package/dist/DBSQLClient.js +111 -0
- package/dist/DBSQLClient.js.map +1 -0
- package/dist/HiveClient.d.ts +35 -0
- package/dist/HiveClient.js +156 -0
- package/dist/HiveClient.js.map +1 -0
- package/dist/HiveOperation.d.ts +65 -0
- package/dist/HiveOperation.js +190 -0
- package/dist/HiveOperation.js.map +1 -0
- package/dist/HiveSession.d.ts +30 -0
- package/dist/HiveSession.js +197 -0
- package/dist/HiveSession.js.map +1 -0
- package/dist/connection/auth/NoSaslAuthentication.d.ts +5 -0
- package/dist/connection/auth/NoSaslAuthentication.js +15 -0
- package/dist/connection/auth/NoSaslAuthentication.js.map +1 -0
- package/dist/connection/auth/PlainHttpAuthentication.d.ts +15 -0
- package/dist/connection/auth/PlainHttpAuthentication.js +30 -0
- package/dist/connection/auth/PlainHttpAuthentication.js.map +1 -0
- package/dist/connection/auth/helpers/SaslPackageFactory.d.ts +11 -0
- package/dist/connection/auth/helpers/SaslPackageFactory.js +24 -0
- package/dist/connection/auth/helpers/SaslPackageFactory.js.map +1 -0
- package/dist/connection/connections/HttpConnection.d.ts +13 -0
- package/dist/connection/connections/HttpConnection.js +77 -0
- package/dist/connection/connections/HttpConnection.js.map +1 -0
- package/dist/connection/contracts/IAuthentication.d.ts +4 -0
- package/dist/connection/contracts/IAuthentication.js +3 -0
- package/dist/connection/contracts/IAuthentication.js.map +1 -0
- package/dist/connection/contracts/IConnectionOptions.d.ts +23 -0
- package/dist/connection/contracts/IConnectionOptions.js +3 -0
- package/dist/connection/contracts/IConnectionOptions.js.map +1 -0
- package/dist/connection/contracts/IConnectionProvider.d.ts +6 -0
- package/dist/connection/contracts/IConnectionProvider.js +3 -0
- package/dist/connection/contracts/IConnectionProvider.js.map +1 -0
- package/dist/connection/contracts/IThriftConnection.d.ts +4 -0
- package/dist/connection/contracts/IThriftConnection.js +3 -0
- package/dist/connection/contracts/IThriftConnection.js.map +1 -0
- package/dist/connection/contracts/ITransport.d.ts +13 -0
- package/dist/connection/contracts/ITransport.js +3 -0
- package/dist/connection/contracts/ITransport.js.map +1 -0
- package/dist/connection/transports/HttpTransport.d.ts +14 -0
- package/dist/connection/transports/HttpTransport.js +39 -0
- package/dist/connection/transports/HttpTransport.js.map +1 -0
- package/dist/connection/types/AuthOptions.d.ts +4 -0
- package/dist/connection/types/AuthOptions.js +3 -0
- package/dist/connection/types/AuthOptions.js.map +1 -0
- package/dist/contracts/IHiveClient.d.ts +10 -0
- package/dist/contracts/IHiveClient.js +3 -0
- package/dist/contracts/IHiveClient.js.map +1 -0
- package/dist/contracts/IHiveSession.d.ts +126 -0
- package/dist/contracts/IHiveSession.js +3 -0
- package/dist/contracts/IHiveSession.js.map +1 -0
- package/dist/contracts/IOperation.d.ts +47 -0
- package/dist/contracts/IOperation.js +3 -0
- package/dist/contracts/IOperation.js.map +1 -0
- package/dist/dto/InfoValue.d.ts +9 -0
- package/dist/dto/InfoValue.js +31 -0
- package/dist/dto/InfoValue.js.map +1 -0
- package/dist/dto/Status.d.ts +15 -0
- package/dist/dto/Status.js +21 -0
- package/dist/dto/Status.js.map +1 -0
- package/dist/errors/AuthenticationError.d.ts +3 -0
- package/dist/errors/AuthenticationError.js +30 -0
- package/dist/errors/AuthenticationError.js.map +1 -0
- package/dist/errors/HiveDriverError.d.ts +2 -0
- package/dist/errors/HiveDriverError.js +26 -0
- package/dist/errors/HiveDriverError.js.map +1 -0
- package/dist/errors/OperationStateError.d.ts +6 -0
- package/dist/errors/OperationStateError.js +32 -0
- package/dist/errors/OperationStateError.js.map +1 -0
- package/dist/errors/StatusError.d.ts +8 -0
- package/dist/errors/StatusError.js +15 -0
- package/dist/errors/StatusError.js.map +1 -0
- package/dist/factory/StatusFactory.d.ts +14 -0
- package/dist/factory/StatusFactory.js +40 -0
- package/dist/factory/StatusFactory.js.map +1 -0
- package/dist/hive/Commands/BaseCommand.d.ts +7 -0
- package/dist/hive/Commands/BaseCommand.js +36 -0
- package/dist/hive/Commands/BaseCommand.js.map +1 -0
- package/dist/hive/Commands/CancelDelegationTokenCommand.d.ts +12 -0
- package/dist/hive/Commands/CancelDelegationTokenCommand.js +34 -0
- package/dist/hive/Commands/CancelDelegationTokenCommand.js.map +1 -0
- package/dist/hive/Commands/CancelOperationCommand.d.ts +11 -0
- package/dist/hive/Commands/CancelOperationCommand.js +34 -0
- package/dist/hive/Commands/CancelOperationCommand.js.map +1 -0
- package/dist/hive/Commands/CloseOperationCommand.d.ts +11 -0
- package/dist/hive/Commands/CloseOperationCommand.js +34 -0
- package/dist/hive/Commands/CloseOperationCommand.js.map +1 -0
- package/dist/hive/Commands/CloseSessionCommand.d.ts +11 -0
- package/dist/hive/Commands/CloseSessionCommand.js +34 -0
- package/dist/hive/Commands/CloseSessionCommand.js.map +1 -0
- package/dist/hive/Commands/ExecuteStatementCommand.d.ts +17 -0
- package/dist/hive/Commands/ExecuteStatementCommand.js +34 -0
- package/dist/hive/Commands/ExecuteStatementCommand.js.map +1 -0
- package/dist/hive/Commands/FetchResultsCommand.d.ts +20 -0
- package/dist/hive/Commands/FetchResultsCommand.js +34 -0
- package/dist/hive/Commands/FetchResultsCommand.js.map +1 -0
- package/dist/hive/Commands/GetCatalogsCommand.d.ts +12 -0
- package/dist/hive/Commands/GetCatalogsCommand.js +34 -0
- package/dist/hive/Commands/GetCatalogsCommand.js.map +1 -0
- package/dist/hive/Commands/GetColumnsCommand.d.ts +16 -0
- package/dist/hive/Commands/GetColumnsCommand.js +34 -0
- package/dist/hive/Commands/GetColumnsCommand.js.map +1 -0
- package/dist/hive/Commands/GetCrossReferenceCommand.d.ts +18 -0
- package/dist/hive/Commands/GetCrossReferenceCommand.js +34 -0
- package/dist/hive/Commands/GetCrossReferenceCommand.js.map +1 -0
- package/dist/hive/Commands/GetDelegationTokenCommand.d.ts +14 -0
- package/dist/hive/Commands/GetDelegationTokenCommand.js +34 -0
- package/dist/hive/Commands/GetDelegationTokenCommand.js.map +1 -0
- package/dist/hive/Commands/GetFunctionsCommand.d.ts +15 -0
- package/dist/hive/Commands/GetFunctionsCommand.js +34 -0
- package/dist/hive/Commands/GetFunctionsCommand.js.map +1 -0
- package/dist/hive/Commands/GetInfoCommand.d.ts +16 -0
- package/dist/hive/Commands/GetInfoCommand.js +34 -0
- package/dist/hive/Commands/GetInfoCommand.js.map +1 -0
- package/dist/hive/Commands/GetOperationStatusCommand.d.ts +23 -0
- package/dist/hive/Commands/GetOperationStatusCommand.js +34 -0
- package/dist/hive/Commands/GetOperationStatusCommand.js.map +1 -0
- package/dist/hive/Commands/GetPrimaryKeysCommand.d.ts +15 -0
- package/dist/hive/Commands/GetPrimaryKeysCommand.js +34 -0
- package/dist/hive/Commands/GetPrimaryKeysCommand.js.map +1 -0
- package/dist/hive/Commands/GetQueryIdCommand.d.ts +11 -0
- package/dist/hive/Commands/GetQueryIdCommand.js +34 -0
- package/dist/hive/Commands/GetQueryIdCommand.js.map +1 -0
- package/dist/hive/Commands/GetResultSetMetadataCommand.d.ts +12 -0
- package/dist/hive/Commands/GetResultSetMetadataCommand.js +34 -0
- package/dist/hive/Commands/GetResultSetMetadataCommand.js.map +1 -0
- package/dist/hive/Commands/GetSchemasCommand.d.ts +14 -0
- package/dist/hive/Commands/GetSchemasCommand.js +34 -0
- package/dist/hive/Commands/GetSchemasCommand.js.map +1 -0
- package/dist/hive/Commands/GetTableTypesCommand.d.ts +12 -0
- package/dist/hive/Commands/GetTableTypesCommand.js +34 -0
- package/dist/hive/Commands/GetTableTypesCommand.js.map +1 -0
- package/dist/hive/Commands/GetTablesCommand.d.ts +16 -0
- package/dist/hive/Commands/GetTablesCommand.js +34 -0
- package/dist/hive/Commands/GetTablesCommand.js.map +1 -0
- package/dist/hive/Commands/GetTypeInfoCommand.d.ts +12 -0
- package/dist/hive/Commands/GetTypeInfoCommand.js +34 -0
- package/dist/hive/Commands/GetTypeInfoCommand.js.map +1 -0
- package/dist/hive/Commands/OpenSessionCommand.d.ts +33 -0
- package/dist/hive/Commands/OpenSessionCommand.js +34 -0
- package/dist/hive/Commands/OpenSessionCommand.js.map +1 -0
- package/dist/hive/Commands/RenewDelegationTokenCommand.d.ts +12 -0
- package/dist/hive/Commands/RenewDelegationTokenCommand.js +34 -0
- package/dist/hive/Commands/RenewDelegationTokenCommand.js.map +1 -0
- package/dist/hive/Commands/SetClientInfoCommand.d.ts +12 -0
- package/dist/hive/Commands/SetClientInfoCommand.js +34 -0
- package/dist/hive/Commands/SetClientInfoCommand.js.map +1 -0
- package/dist/hive/HiveDriver.d.ts +52 -0
- package/dist/hive/HiveDriver.js +129 -0
- package/dist/hive/HiveDriver.js.map +1 -0
- package/dist/hive/Types/index.d.ts +229 -0
- package/dist/hive/Types/index.js +16 -0
- package/dist/hive/Types/index.js.map +1 -0
- package/dist/index.d.ts +25 -0
- package/dist/index.js +67 -0
- package/dist/index.js.map +1 -0
- package/dist/result/IOperationResult.d.ts +5 -0
- package/dist/result/IOperationResult.js +3 -0
- package/dist/result/IOperationResult.js.map +1 -0
- package/dist/result/JsonResult.d.ts +20 -0
- package/dist/result/JsonResult.js +137 -0
- package/dist/result/JsonResult.js.map +1 -0
- package/dist/result/NullResult.d.ts +6 -0
- package/dist/result/NullResult.js +13 -0
- package/dist/result/NullResult.js.map +1 -0
- package/dist/utils/GetResult.d.ts +16 -0
- package/dist/utils/GetResult.js +38 -0
- package/dist/utils/GetResult.js.map +1 -0
- package/dist/utils/HiveUtils.d.ts +11 -0
- package/dist/utils/HiveUtils.js +39 -0
- package/dist/utils/HiveUtils.js.map +1 -0
- package/dist/utils/ProgressUpdateTransformer.d.ts +8 -0
- package/dist/utils/ProgressUpdateTransformer.js +33 -0
- package/dist/utils/ProgressUpdateTransformer.js.map +1 -0
- package/dist/utils/WaitUntilReady.d.ts +16 -0
- package/dist/utils/WaitUntilReady.js +120 -0
- package/dist/utils/WaitUntilReady.js.map +1 -0
- package/docs/readme.md +227 -0
- package/docs/troubleshooting.md +84 -0
- package/examples/data_types.js +173 -0
- package/examples/repl +106 -0
- package/examples/session.js +55 -0
- package/examples/usage.js +18 -0
- package/nyc.config.js +8 -0
- package/package.json +56 -0
- package/tests/e2e/data_types.test.js +353 -0
- package/tests/e2e/utils/config.js +20 -0
- package/tests/e2e/utils/logger.js +22 -0
- package/tests/unit/HiveClient.test.js +153 -0
- package/tests/unit/HiveOperation.test.js +340 -0
- package/tests/unit/HiveSession.test.js +146 -0
- package/tests/unit/connection/auth/PlainHttpAuthentication.test.js +44 -0
- package/tests/unit/connection/connections/HttpConnection.test.js +141 -0
- package/tests/unit/dto/InfoValue.test.js +50 -0
- package/tests/unit/factory/StatusFactory.test.js +62 -0
- package/tests/unit/hive/HiveDriver.test.js +115 -0
- package/tests/unit/hive/commands/CancelDelegationTokenCommand.test.js +43 -0
- package/tests/unit/hive/commands/CancelOperationCommand.test.js +45 -0
- package/tests/unit/hive/commands/CloseOperationCommand.test.js +45 -0
- package/tests/unit/hive/commands/CloseSessionCommand.test.js +38 -0
- package/tests/unit/hive/commands/ExecuteStatementCommand.test.js +54 -0
- package/tests/unit/hive/commands/FetchResultsCommand.test.js +59 -0
- package/tests/unit/hive/commands/GetCatalogsCommand.test.js +50 -0
- package/tests/unit/hive/commands/GetColumnsCommand.test.js +50 -0
- package/tests/unit/hive/commands/GetCrossReferenceCommand.test.js +56 -0
- package/tests/unit/hive/commands/GetDelegationTokenCommand.test.js +45 -0
- package/tests/unit/hive/commands/GetFunctionsCommand.test.js +50 -0
- package/tests/unit/hive/commands/GetInfoCommand.test.js +51 -0
- package/tests/unit/hive/commands/GetOperationStatusCommand.test.js +63 -0
- package/tests/unit/hive/commands/GetPrimaryKeysCommand.test.js +50 -0
- package/tests/unit/hive/commands/GetQueryIdCommand.test.js +42 -0
- package/tests/unit/hive/commands/GetResultSetMetadataCommand.test.js +54 -0
- package/tests/unit/hive/commands/GetSchemasCommand.test.js +52 -0
- package/tests/unit/hive/commands/GetTableTypesCommand.test.js +50 -0
- package/tests/unit/hive/commands/GetTablesCommand.test.js +54 -0
- package/tests/unit/hive/commands/GetTypeInfoCommand.test.js +50 -0
- package/tests/unit/hive/commands/OpenSessionCommand.test.js +43 -0
- package/tests/unit/hive/commands/RenewDelegationTokenCommand.test.js +43 -0
- package/tests/unit/hive/commands/SetClientInfoCommand.test.js +45 -0
- package/tests/unit/result/JsonResult.test.js +295 -0
- package/tests/unit/utils/GetResult.test.js +30 -0
- package/tests/unit/utils/HiveUtils.test.js +60 -0
- package/tests/unit/utils/ProgressUpdateTransformer.test.js +28 -0
- package/tests/unit/utils/WaitUntilReady.test.js +105 -0
- package/thrift/TCLIService.thrift +1299 -0
- package/thrift/gen-nodejs/TCLIService.js +4596 -0
- package/thrift/gen-nodejs/TCLIService_types.js +6794 -0
- package/tsconfig.json +13 -0
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
const { expect } = require('chai');
|
|
2
|
+
const { TCLIService_types } = require('../../../').thrift;
|
|
3
|
+
const WaitUntilReady = require('../../../dist/utils/WaitUntilReady').default;
|
|
4
|
+
|
|
5
|
+
const operation = (state) => ({
|
|
6
|
+
state,
|
|
7
|
+
status() {
|
|
8
|
+
return Promise.resolve({
|
|
9
|
+
type: 'GetOperationStatusResponse',
|
|
10
|
+
operationState: this.state
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
describe('WaitUntilReady', () => {
|
|
16
|
+
it('should return operation when state is finished', (cb) => {
|
|
17
|
+
const op = operation(TCLIService_types.TOperationState.FINISHED_STATE);
|
|
18
|
+
const waitUntilReady = new WaitUntilReady(op, TCLIService_types);
|
|
19
|
+
|
|
20
|
+
waitUntilReady.execute().then(() => {
|
|
21
|
+
expect(op).to.be.eq(op);
|
|
22
|
+
cb();
|
|
23
|
+
}).catch(cb)
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it('should call callback until state is not finished', (cb) => {
|
|
27
|
+
const op = operation(TCLIService_types.TOperationState.INITIALIZED_STATE);
|
|
28
|
+
const waitUntilReady = new WaitUntilReady(op, TCLIService_types);
|
|
29
|
+
let states = [
|
|
30
|
+
TCLIService_types.TOperationState.INITIALIZED_STATE,
|
|
31
|
+
TCLIService_types.TOperationState.RUNNING_STATE,
|
|
32
|
+
TCLIService_types.TOperationState.FINISHED_STATE,
|
|
33
|
+
];
|
|
34
|
+
let i = 0;
|
|
35
|
+
|
|
36
|
+
waitUntilReady.execute(false, (response) => {
|
|
37
|
+
expect(response.operationState).to.be.eq(states[i]);
|
|
38
|
+
op.state = states[++i];
|
|
39
|
+
}).then(() => {
|
|
40
|
+
cb();
|
|
41
|
+
}).catch(cb)
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it('should throw error if state is invalid', () => {
|
|
45
|
+
const execute = (state) => {
|
|
46
|
+
const waitUntilReady = new WaitUntilReady(operation(state), TCLIService_types);
|
|
47
|
+
return waitUntilReady.execute();
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
return Promise.all([
|
|
51
|
+
execute(TCLIService_types.TOperationState.CANCELED_STATE).catch(error => {
|
|
52
|
+
expect(error.message).to.be.eq('The operation was canceled by a client');
|
|
53
|
+
expect(error.response.type).to.be.eq('GetOperationStatusResponse');
|
|
54
|
+
}),
|
|
55
|
+
execute(TCLIService_types.TOperationState.CLOSED_STATE).catch(error => {
|
|
56
|
+
expect(error.message).to.be.eq('The operation was closed by a client');
|
|
57
|
+
expect(error.response.type).to.be.eq('GetOperationStatusResponse');
|
|
58
|
+
}),
|
|
59
|
+
execute(TCLIService_types.TOperationState.ERROR_STATE).catch(error => {
|
|
60
|
+
expect(error.message).to.be.eq('The operation failed due to an error');
|
|
61
|
+
expect(error.response.type).to.be.eq('GetOperationStatusResponse');
|
|
62
|
+
}),
|
|
63
|
+
execute(TCLIService_types.TOperationState.PENDING_STATE).catch(error => {
|
|
64
|
+
expect(error.message).to.be.eq('The operation is in a pending state');
|
|
65
|
+
expect(error.response.type).to.be.eq('GetOperationStatusResponse');
|
|
66
|
+
}),
|
|
67
|
+
execute(TCLIService_types.TOperationState.TIMEDOUT_STATE).catch(error => {
|
|
68
|
+
expect(error.message).to.be.eq('The operation is in a timedout state');
|
|
69
|
+
expect(error.response.type).to.be.eq('GetOperationStatusResponse');
|
|
70
|
+
}),
|
|
71
|
+
execute(TCLIService_types.TOperationState.UKNOWN_STATE).catch(error => {
|
|
72
|
+
expect(error.message).to.be.eq('The operation is in an unrecognized state');
|
|
73
|
+
expect(error.response.type).to.be.eq('GetOperationStatusResponse');
|
|
74
|
+
}),
|
|
75
|
+
]);
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
it('should wait untill callback will be finished', () => {
|
|
79
|
+
const op = operation(TCLIService_types.TOperationState.INITIALIZED_STATE);
|
|
80
|
+
const waitUntilReady = new WaitUntilReady(op, TCLIService_types);
|
|
81
|
+
let i = 0;
|
|
82
|
+
|
|
83
|
+
return waitUntilReady.execute(false, (response) => {
|
|
84
|
+
op.state = TCLIService_types.TOperationState.FINISHED_STATE;
|
|
85
|
+
|
|
86
|
+
return Promise.resolve()
|
|
87
|
+
.then(() => new Promise((resolve) => {
|
|
88
|
+
setTimeout(() => {
|
|
89
|
+
expect(i == 0 || i === 2).to.be.true;
|
|
90
|
+
i++;
|
|
91
|
+
resolve();
|
|
92
|
+
}, 10);
|
|
93
|
+
}))
|
|
94
|
+
.then(() => new Promise((resolve) => {
|
|
95
|
+
setTimeout(() => {
|
|
96
|
+
expect(i == 1 || i === 3).to.be.true;
|
|
97
|
+
i++;
|
|
98
|
+
resolve();
|
|
99
|
+
}, 30);
|
|
100
|
+
}));
|
|
101
|
+
}).then(() => {
|
|
102
|
+
expect(i).to.be.eq(4);
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
});
|