@databricks/sql 1.5.0 → 1.6.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/dist/DBSQLClient.d.ts +17 -8
- package/dist/DBSQLClient.js +82 -82
- package/dist/DBSQLClient.js.map +1 -1
- package/dist/DBSQLOperation/FetchResultsHelper.d.ts +3 -3
- package/dist/DBSQLOperation/FetchResultsHelper.js +4 -3
- package/dist/DBSQLOperation/FetchResultsHelper.js.map +1 -1
- package/dist/DBSQLOperation/index.d.ts +10 -7
- package/dist/DBSQLOperation/index.js +110 -41
- package/dist/DBSQLOperation/index.js.map +1 -1
- package/dist/DBSQLParameter.d.ts +6 -2
- package/dist/DBSQLParameter.js +15 -1
- package/dist/DBSQLParameter.js.map +1 -1
- package/dist/DBSQLSession.d.ts +5 -6
- package/dist/DBSQLSession.js +66 -36
- package/dist/DBSQLSession.js.map +1 -1
- package/dist/connection/auth/DatabricksOAuth/AuthorizationCode.d.ts +3 -3
- package/dist/connection/auth/DatabricksOAuth/AuthorizationCode.js +3 -4
- package/dist/connection/auth/DatabricksOAuth/AuthorizationCode.js.map +1 -1
- package/dist/connection/auth/DatabricksOAuth/OAuthManager.d.ts +6 -3
- package/dist/connection/auth/DatabricksOAuth/OAuthManager.js +27 -8
- package/dist/connection/auth/DatabricksOAuth/OAuthManager.js.map +1 -1
- package/dist/connection/auth/DatabricksOAuth/index.d.ts +4 -6
- package/dist/connection/auth/DatabricksOAuth/index.js +1 -1
- package/dist/connection/auth/DatabricksOAuth/index.js.map +1 -1
- package/dist/connection/auth/PlainHttpAuthentication.d.ts +6 -3
- package/dist/connection/auth/PlainHttpAuthentication.js +1 -0
- package/dist/connection/auth/PlainHttpAuthentication.js.map +1 -1
- package/dist/connection/connections/HttpConnection.d.ts +16 -9
- package/dist/connection/connections/HttpConnection.js +60 -51
- package/dist/connection/connections/HttpConnection.js.map +1 -1
- package/dist/connection/connections/ThriftHttpConnection.d.ts +38 -0
- package/dist/connection/connections/ThriftHttpConnection.js +134 -0
- package/dist/connection/connections/ThriftHttpConnection.js.map +1 -0
- package/dist/connection/contracts/IAuthentication.d.ts +2 -2
- package/dist/connection/contracts/IConnectionOptions.d.ts +17 -19
- package/dist/connection/contracts/IConnectionProvider.d.ts +6 -3
- package/dist/contracts/IClientContext.d.ts +10 -0
- package/dist/{connection/contracts/IThriftConnection.js → contracts/IClientContext.js} +1 -1
- package/dist/contracts/IClientContext.js.map +1 -0
- package/dist/contracts/IDBSQLClient.d.ts +2 -0
- package/dist/contracts/IDBSQLSession.d.ts +1 -0
- package/dist/contracts/IDriver.d.ts +24 -0
- package/dist/contracts/IDriver.js +3 -0
- package/dist/contracts/IDriver.js.map +1 -0
- package/dist/errors/ParameterError.d.ts +2 -0
- package/dist/errors/ParameterError.js +6 -0
- package/dist/errors/ParameterError.js.map +1 -0
- package/dist/hive/HiveDriver.d.ts +8 -5
- package/dist/hive/HiveDriver.js +23 -23
- package/dist/hive/HiveDriver.js.map +1 -1
- package/dist/result/ArrowResult.d.ts +3 -1
- package/dist/result/ArrowResult.js +4 -2
- package/dist/result/ArrowResult.js.map +1 -1
- package/dist/result/CloudFetchResult.d.ts +2 -1
- package/dist/result/CloudFetchResult.js +5 -3
- package/dist/result/CloudFetchResult.js.map +1 -1
- package/dist/result/JsonResult.d.ts +3 -1
- package/dist/result/JsonResult.js +2 -1
- package/dist/result/JsonResult.js.map +1 -1
- package/dist/utils/index.d.ts +1 -2
- package/dist/utils/index.js +1 -3
- package/dist/utils/index.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +2 -4
- package/dist/DBSQLOperation/OperationStatusHelper.d.ts +0 -16
- package/dist/DBSQLOperation/OperationStatusHelper.js +0 -138
- package/dist/DBSQLOperation/OperationStatusHelper.js.map +0 -1
- package/dist/connection/contracts/IThriftConnection.d.ts +0 -4
- package/dist/connection/contracts/IThriftConnection.js.map +0 -1
- package/dist/node_modules/thrift/LICENSE +0 -306
- package/dist/node_modules/thrift/README.md +0 -210
- package/dist/node_modules/thrift/lib/nodejs/README.md +0 -142
- package/dist/node_modules/thrift/lib/nodejs/lib/thrift/binary.js +0 -168
- package/dist/node_modules/thrift/lib/nodejs/lib/thrift/binary_protocol.js +0 -367
- package/dist/node_modules/thrift/lib/nodejs/lib/thrift/browser.js +0 -49
- package/dist/node_modules/thrift/lib/nodejs/lib/thrift/buffered_transport.js +0 -186
- package/dist/node_modules/thrift/lib/nodejs/lib/thrift/compact_protocol.js +0 -915
- package/dist/node_modules/thrift/lib/nodejs/lib/thrift/connection.js +0 -396
- package/dist/node_modules/thrift/lib/nodejs/lib/thrift/create_client.js +0 -54
- package/dist/node_modules/thrift/lib/nodejs/lib/thrift/framed_transport.js +0 -185
- package/dist/node_modules/thrift/lib/nodejs/lib/thrift/header_protocol.js +0 -258
- package/dist/node_modules/thrift/lib/nodejs/lib/thrift/header_transport.js +0 -341
- package/dist/node_modules/thrift/lib/nodejs/lib/thrift/http_connection.js +0 -292
- package/dist/node_modules/thrift/lib/nodejs/lib/thrift/index.js +0 -76
- package/dist/node_modules/thrift/lib/nodejs/lib/thrift/input_buffer_underrun_error.js +0 -32
- package/dist/node_modules/thrift/lib/nodejs/lib/thrift/int64_util.js +0 -91
- package/dist/node_modules/thrift/lib/nodejs/lib/thrift/json_parse.js +0 -299
- package/dist/node_modules/thrift/lib/nodejs/lib/thrift/json_protocol.js +0 -799
- package/dist/node_modules/thrift/lib/nodejs/lib/thrift/log.js +0 -87
- package/dist/node_modules/thrift/lib/nodejs/lib/thrift/multiplexed_processor.js +0 -63
- package/dist/node_modules/thrift/lib/nodejs/lib/thrift/multiplexed_protocol.js +0 -73
- package/dist/node_modules/thrift/lib/nodejs/lib/thrift/protocol.js +0 -22
- package/dist/node_modules/thrift/lib/nodejs/lib/thrift/server.js +0 -123
- package/dist/node_modules/thrift/lib/nodejs/lib/thrift/thrift.js +0 -241
- package/dist/node_modules/thrift/lib/nodejs/lib/thrift/transport.js +0 -22
- package/dist/node_modules/thrift/lib/nodejs/lib/thrift/web_server.js +0 -567
- package/dist/node_modules/thrift/lib/nodejs/lib/thrift/ws_connection.js +0 -286
- package/dist/node_modules/thrift/lib/nodejs/lib/thrift/ws_transport.js +0 -206
- package/dist/node_modules/thrift/lib/nodejs/lib/thrift/xhr_connection.js +0 -280
- package/dist/node_modules/thrift/package.json +0 -72
- package/dist/utils/areHeadersEqual.d.ts +0 -2
- package/dist/utils/areHeadersEqual.js +0 -49
- package/dist/utils/areHeadersEqual.js.map +0 -1
package/dist/DBSQLClient.d.ts
CHANGED
|
@@ -1,19 +1,26 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { EventEmitter } from 'events';
|
|
3
|
+
import TCLIService from '../thrift/TCLIService';
|
|
3
4
|
import IDBSQLClient, { ClientOptions, ConnectionOptions, OpenSessionRequest } from './contracts/IDBSQLClient';
|
|
5
|
+
import IDriver from './contracts/IDriver';
|
|
6
|
+
import IClientContext from './contracts/IClientContext';
|
|
4
7
|
import IDBSQLSession from './contracts/IDBSQLSession';
|
|
5
8
|
import IAuthentication from './connection/contracts/IAuthentication';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
private
|
|
10
|
-
private
|
|
9
|
+
import IDBSQLLogger from './contracts/IDBSQLLogger';
|
|
10
|
+
import IConnectionProvider from './connection/contracts/IConnectionProvider';
|
|
11
|
+
export default class DBSQLClient extends EventEmitter implements IDBSQLClient, IClientContext {
|
|
12
|
+
private static defaultLogger?;
|
|
13
|
+
private connectionProvider?;
|
|
14
|
+
private authProvider?;
|
|
15
|
+
private client?;
|
|
16
|
+
private readonly driver;
|
|
11
17
|
private readonly logger;
|
|
12
18
|
private readonly thrift;
|
|
13
19
|
private sessions;
|
|
20
|
+
private static getDefaultLogger;
|
|
14
21
|
constructor(options?: ClientOptions);
|
|
15
22
|
private getConnectionOptions;
|
|
16
|
-
private
|
|
23
|
+
private initAuthProvider;
|
|
17
24
|
/**
|
|
18
25
|
* Connects DBSQLClient to endpoint
|
|
19
26
|
* @public
|
|
@@ -34,7 +41,9 @@ export default class DBSQLClient extends EventEmitter implements IDBSQLClient {
|
|
|
34
41
|
* const session = await client.openSession();
|
|
35
42
|
*/
|
|
36
43
|
openSession(request?: OpenSessionRequest): Promise<IDBSQLSession>;
|
|
37
|
-
private getClient;
|
|
38
|
-
private createConnection;
|
|
39
44
|
close(): Promise<void>;
|
|
45
|
+
getLogger(): IDBSQLLogger;
|
|
46
|
+
getConnectionProvider(): Promise<IConnectionProvider>;
|
|
47
|
+
getClient(): Promise<TCLIService.Client>;
|
|
48
|
+
getDriver(): Promise<IDriver>;
|
|
40
49
|
}
|
package/dist/DBSQLClient.js
CHANGED
|
@@ -8,17 +8,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
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]];
|
|
19
|
-
}
|
|
20
|
-
return t;
|
|
21
|
-
};
|
|
22
11
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
23
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
24
13
|
};
|
|
@@ -57,32 +46,37 @@ function getInitialNamespaceOptions(catalogName, schemaName) {
|
|
|
57
46
|
};
|
|
58
47
|
}
|
|
59
48
|
class DBSQLClient extends events_1.EventEmitter {
|
|
49
|
+
static getDefaultLogger() {
|
|
50
|
+
if (!this.defaultLogger) {
|
|
51
|
+
this.defaultLogger = new DBSQLLogger_1.default();
|
|
52
|
+
}
|
|
53
|
+
return this.defaultLogger;
|
|
54
|
+
}
|
|
60
55
|
constructor(options) {
|
|
56
|
+
var _a;
|
|
61
57
|
super();
|
|
62
|
-
this.
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
this.additionalHeaders = {};
|
|
58
|
+
this.driver = new HiveDriver_1.default({
|
|
59
|
+
context: this,
|
|
60
|
+
});
|
|
66
61
|
this.thrift = thrift_1.default;
|
|
67
62
|
this.sessions = new CloseableCollection_1.default();
|
|
68
|
-
this.logger = (options === null || options === void 0 ? void 0 : options.logger)
|
|
63
|
+
this.logger = (_a = options === null || options === void 0 ? void 0 : options.logger) !== null && _a !== void 0 ? _a : DBSQLClient.getDefaultLogger();
|
|
69
64
|
this.logger.log(IDBSQLLogger_1.LogLevel.info, 'Created DBSQLClient');
|
|
70
65
|
}
|
|
71
|
-
getConnectionOptions(options
|
|
72
|
-
const { host, port, path, clientId, authType,
|
|
73
|
-
// @ts-expect-error TS2339: Property 'token' does not exist on type 'ConnectionOptions'
|
|
74
|
-
token,
|
|
75
|
-
// @ts-expect-error TS2339: Property 'persistence' does not exist on type 'ConnectionOptions'
|
|
76
|
-
persistence,
|
|
77
|
-
// @ts-expect-error TS2339: Property 'provider' does not exist on type 'ConnectionOptions'
|
|
78
|
-
provider } = options, otherOptions = __rest(options, ["host", "port", "path", "clientId", "authType", "token", "persistence", "provider"]);
|
|
66
|
+
getConnectionOptions(options) {
|
|
79
67
|
return {
|
|
80
|
-
host,
|
|
81
|
-
port: port || 443,
|
|
82
|
-
|
|
68
|
+
host: options.host,
|
|
69
|
+
port: options.port || 443,
|
|
70
|
+
path: prependSlash(options.path),
|
|
71
|
+
https: true,
|
|
72
|
+
socketTimeout: options.socketTimeout,
|
|
73
|
+
proxy: options.proxy,
|
|
74
|
+
headers: {
|
|
75
|
+
'User-Agent': (0, utils_1.buildUserAgentString)(options.clientId),
|
|
76
|
+
},
|
|
83
77
|
};
|
|
84
78
|
}
|
|
85
|
-
|
|
79
|
+
initAuthProvider(options, authProvider) {
|
|
86
80
|
if (authProvider) {
|
|
87
81
|
return authProvider;
|
|
88
82
|
}
|
|
@@ -92,15 +86,16 @@ class DBSQLClient extends events_1.EventEmitter {
|
|
|
92
86
|
return new PlainHttpAuthentication_1.default({
|
|
93
87
|
username: 'token',
|
|
94
88
|
password: options.token,
|
|
89
|
+
context: this,
|
|
95
90
|
});
|
|
96
91
|
case 'databricks-oauth':
|
|
97
92
|
return new DatabricksOAuth_1.default({
|
|
98
93
|
host: options.host,
|
|
99
|
-
logger: this.logger,
|
|
100
94
|
persistence: options.persistence,
|
|
101
95
|
azureTenantId: options.azureTenantId,
|
|
102
96
|
clientId: options.oauthClientId,
|
|
103
97
|
clientSecret: options.oauthClientSecret,
|
|
98
|
+
context: this,
|
|
104
99
|
});
|
|
105
100
|
case 'custom':
|
|
106
101
|
return options.provider;
|
|
@@ -118,55 +113,9 @@ class DBSQLClient extends events_1.EventEmitter {
|
|
|
118
113
|
*/
|
|
119
114
|
connect(options, authProvider) {
|
|
120
115
|
return __awaiter(this, void 0, void 0, function* () {
|
|
121
|
-
this.authProvider = this.
|
|
122
|
-
this.
|
|
123
|
-
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
/**
|
|
127
|
-
* Starts new session
|
|
128
|
-
* @public
|
|
129
|
-
* @param request - Can be instantiated with initialSchema, empty by default
|
|
130
|
-
* @returns Session object that can be used to execute statements
|
|
131
|
-
* @throws {StatusError}
|
|
132
|
-
* @example
|
|
133
|
-
* const session = await client.openSession();
|
|
134
|
-
*/
|
|
135
|
-
openSession(request = {}) {
|
|
136
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
137
|
-
const driver = new HiveDriver_1.default(() => this.getClient());
|
|
138
|
-
const response = yield driver.openSession(Object.assign({ client_protocol_i64: new Types_1.Int64(TCLIService_types_1.TProtocolVersion.SPARK_CLI_SERVICE_PROTOCOL_V8) }, getInitialNamespaceOptions(request.initialCatalog, request.initialSchema)));
|
|
139
|
-
Status_1.default.assert(response.status);
|
|
140
|
-
const session = new DBSQLSession_1.default(driver, (0, utils_1.definedOrError)(response.sessionHandle), {
|
|
141
|
-
logger: this.logger,
|
|
142
|
-
});
|
|
143
|
-
this.sessions.add(session);
|
|
144
|
-
return session;
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
getClient() {
|
|
148
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
149
|
-
if (!this.connectionOptions || !this.authProvider) {
|
|
150
|
-
throw new HiveDriverError_1.default('DBSQLClient: not connected');
|
|
151
|
-
}
|
|
152
|
-
const authHeaders = yield this.authProvider.authenticate();
|
|
153
|
-
// When auth headers change - recreate client. Thrift library does not provide API for updating
|
|
154
|
-
// changed options, therefore we have to recreate both connection and client to apply new headers
|
|
155
|
-
if (!this.client || !(0, utils_1.areHeadersEqual)(this.additionalHeaders, authHeaders)) {
|
|
156
|
-
this.logger.log(IDBSQLLogger_1.LogLevel.info, 'DBSQLClient: initializing thrift client');
|
|
157
|
-
this.additionalHeaders = authHeaders;
|
|
158
|
-
const connectionOptions = this.getConnectionOptions(this.connectionOptions, this.additionalHeaders);
|
|
159
|
-
const connection = yield this.createConnection(connectionOptions);
|
|
160
|
-
this.client = this.thrift.createClient(TCLIService_1.default, connection.getConnection());
|
|
161
|
-
}
|
|
162
|
-
return this.client;
|
|
163
|
-
});
|
|
164
|
-
}
|
|
165
|
-
createConnection(options) {
|
|
166
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
167
|
-
const connectionProvider = new HttpConnection_1.default();
|
|
168
|
-
const connection = yield connectionProvider.connect(options);
|
|
169
|
-
const thriftConnection = connection.getConnection();
|
|
116
|
+
this.authProvider = this.initAuthProvider(options, authProvider);
|
|
117
|
+
this.connectionProvider = new HttpConnection_1.default(this.getConnectionOptions(options));
|
|
118
|
+
const thriftConnection = yield this.connectionProvider.getThriftConnection();
|
|
170
119
|
thriftConnection.on('error', (error) => {
|
|
171
120
|
// Error.stack already contains error type and message, so log stack if available,
|
|
172
121
|
// otherwise fall back to just error type + message
|
|
@@ -191,15 +140,66 @@ class DBSQLClient extends events_1.EventEmitter {
|
|
|
191
140
|
this.logger.log(IDBSQLLogger_1.LogLevel.debug, 'Connection timed out.');
|
|
192
141
|
this.emit('timeout');
|
|
193
142
|
});
|
|
194
|
-
return
|
|
143
|
+
return this;
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Starts new session
|
|
148
|
+
* @public
|
|
149
|
+
* @param request - Can be instantiated with initialSchema, empty by default
|
|
150
|
+
* @returns Session object that can be used to execute statements
|
|
151
|
+
* @throws {StatusError}
|
|
152
|
+
* @example
|
|
153
|
+
* const session = await client.openSession();
|
|
154
|
+
*/
|
|
155
|
+
openSession(request = {}) {
|
|
156
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
157
|
+
const response = yield this.driver.openSession(Object.assign(Object.assign({ client_protocol_i64: new Types_1.Int64(TCLIService_types_1.TProtocolVersion.SPARK_CLI_SERVICE_PROTOCOL_V8) }, getInitialNamespaceOptions(request.initialCatalog, request.initialSchema)), { canUseMultipleCatalogs: true }));
|
|
158
|
+
Status_1.default.assert(response.status);
|
|
159
|
+
const session = new DBSQLSession_1.default({
|
|
160
|
+
handle: (0, utils_1.definedOrError)(response.sessionHandle),
|
|
161
|
+
context: this,
|
|
162
|
+
});
|
|
163
|
+
this.sessions.add(session);
|
|
164
|
+
return session;
|
|
195
165
|
});
|
|
196
166
|
}
|
|
197
167
|
close() {
|
|
198
168
|
return __awaiter(this, void 0, void 0, function* () {
|
|
199
169
|
yield this.sessions.closeAll();
|
|
200
|
-
this.client =
|
|
201
|
-
this.
|
|
202
|
-
this.
|
|
170
|
+
this.client = undefined;
|
|
171
|
+
this.connectionProvider = undefined;
|
|
172
|
+
this.authProvider = undefined;
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
getLogger() {
|
|
176
|
+
return this.logger;
|
|
177
|
+
}
|
|
178
|
+
getConnectionProvider() {
|
|
179
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
180
|
+
if (!this.connectionProvider) {
|
|
181
|
+
throw new HiveDriverError_1.default('DBSQLClient: not connected');
|
|
182
|
+
}
|
|
183
|
+
return this.connectionProvider;
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
getClient() {
|
|
187
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
188
|
+
const connectionProvider = yield this.getConnectionProvider();
|
|
189
|
+
if (!this.client) {
|
|
190
|
+
this.logger.log(IDBSQLLogger_1.LogLevel.info, 'DBSQLClient: initializing thrift client');
|
|
191
|
+
this.client = this.thrift.createClient(TCLIService_1.default, yield connectionProvider.getThriftConnection());
|
|
192
|
+
}
|
|
193
|
+
if (this.authProvider) {
|
|
194
|
+
const authHeaders = yield this.authProvider.authenticate();
|
|
195
|
+
connectionProvider.setHeaders(authHeaders);
|
|
196
|
+
}
|
|
197
|
+
return this.client;
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
getDriver() {
|
|
201
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
202
|
+
return this.driver;
|
|
203
203
|
});
|
|
204
204
|
}
|
|
205
205
|
}
|
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;AAI/D,mEAA2C;AAC3C,wCAAqC;AACrC,kEAA0C;AAG1C,6FAAqE;AAErE,0DAAkC;AAClC,+EAAuD;AACvD,mCAA+D;AAC/D,wGAAgF;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AAG,CAAC,uBAAQ,CAAC,IAAI,EAAE,yCAAyC,CAAC,CAAC;gBAC1E,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,qBAAW,EAAE,MAAM,kBAAkB,CAAC,mBAAmB,EAAE,CAAC,CAAC;aACrG;YAED,IAAI,IAAI,CAAC,YAAY,EAAE;gBACrB,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,YAAY,EAAE,CAAC;gBAC3D,kBAAkB,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;aAC5C;YAED,OAAO,IAAI,CAAC,MAAM,CAAC;QACrB,CAAC;KAAA;IAEY,SAAS;;YACpB,OAAO,IAAI,CAAC,MAAM,CAAC;QACrB,CAAC;KAAA;CACF;AAxLD,8BAwLC"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { TFetchResultsResp, TOperationHandle, TRowSet } from '../../thrift/TCLIService_types';
|
|
2
|
-
import
|
|
2
|
+
import IClientContext from '../contracts/IClientContext';
|
|
3
3
|
export default class FetchResultsHelper {
|
|
4
|
-
private readonly
|
|
4
|
+
private readonly context;
|
|
5
5
|
private readonly operationHandle;
|
|
6
6
|
private fetchOrientation;
|
|
7
7
|
private prefetchedResults;
|
|
8
8
|
private readonly returnOnlyPrefetchedResults;
|
|
9
9
|
hasMoreRows: boolean;
|
|
10
|
-
constructor(
|
|
10
|
+
constructor(context: IClientContext, operationHandle: TOperationHandle, prefetchedResults: Array<TFetchResultsResp | undefined>, returnOnlyPrefetchedResults: boolean);
|
|
11
11
|
private processFetchResponse;
|
|
12
12
|
fetch(maxRows: number): Promise<TRowSet | undefined>;
|
|
13
13
|
}
|
|
@@ -36,11 +36,11 @@ function checkIfOperationHasMoreRows(response) {
|
|
|
36
36
|
return (((_b = columnValue === null || columnValue === void 0 ? void 0 : columnValue.values) === null || _b === void 0 ? void 0 : _b.length) || 0) > 0;
|
|
37
37
|
}
|
|
38
38
|
class FetchResultsHelper {
|
|
39
|
-
constructor(
|
|
39
|
+
constructor(context, operationHandle, prefetchedResults, returnOnlyPrefetchedResults) {
|
|
40
40
|
this.fetchOrientation = TCLIService_types_1.TFetchOrientation.FETCH_FIRST;
|
|
41
41
|
this.prefetchedResults = [];
|
|
42
42
|
this.hasMoreRows = false;
|
|
43
|
-
this.
|
|
43
|
+
this.context = context;
|
|
44
44
|
this.operationHandle = operationHandle;
|
|
45
45
|
prefetchedResults.forEach((item) => {
|
|
46
46
|
if (item) {
|
|
@@ -69,7 +69,8 @@ class FetchResultsHelper {
|
|
|
69
69
|
if (prefetchedResponse) {
|
|
70
70
|
return this.processFetchResponse(prefetchedResponse);
|
|
71
71
|
}
|
|
72
|
-
const
|
|
72
|
+
const driver = yield this.context.getDriver();
|
|
73
|
+
const response = yield driver.fetchResults({
|
|
73
74
|
operationHandle: this.operationHandle,
|
|
74
75
|
orientation: this.fetchOrientation,
|
|
75
76
|
maxRows: new Types_1.Int64(maxRows),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FetchResultsHelper.js","sourceRoot":"","sources":["../../lib/DBSQLOperation/FetchResultsHelper.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,sEAMwC;AACxC,yCAA6D;
|
|
1
|
+
{"version":3,"file":"FetchResultsHelper.js","sourceRoot":"","sources":["../../lib/DBSQLOperation/FetchResultsHelper.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,sEAMwC;AACxC,yCAA6D;AAC7D,2DAAmC;AAGnC,SAAS,2BAA2B,CAAC,QAA2B;;IAC9D,IAAI,QAAQ,CAAC,WAAW,EAAE;QACxB,OAAO,IAAI,CAAC;KACb;IAED,MAAM,OAAO,GAAG,CAAA,MAAA,QAAQ,CAAC,OAAO,0CAAE,OAAO,KAAI,EAAE,CAAC;IAEhD,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE;QACxB,OAAO,KAAK,CAAC;KACd;IAED,MAAM,MAAM,GAAY,OAAO,CAA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C,MAAM,GAAG,CAAC,EAAE;YACrC,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;SACzB;aAAM,IAAI,IAAI,CAAC,2BAA2B,EAAE;YAC3C,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC;SAC1B;aAAM;YACL,IAAI,CAAC,WAAW,GAAG,2BAA2B,CAAC,QAAQ,CAAC,CAAC;SAC1D;QAED,OAAO,QAAQ,CAAC,OAAO,CAAC;IAC1B,CAAC;IAEY,KAAK,CAAC,OAAe;;YAChC,MAAM,kBAAkB,GAAG,IAAI,CAAC,iBAAiB,CAAC,KAAK,EAAE,CAAC;YAC1D,IAAI,kBAAkB,EAAE;gBACtB,OAAO,IAAI,CAAC,oBAAoB,CAAC,kBAAkB,CAAC,CAAC;aACtD;YAED,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC;YAC9C,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,YAAY,CAAC;gBACzC,eAAe,EAAE,IAAI,CAAC,eAAe;gBACrC,WAAW,EAAE,IAAI,CAAC,gBAAgB;gBAClC,OAAO,EAAE,IAAI,aAAK,CAAC,OAAO,CAAC;gBAC3B,SAAS,EAAE,iBAAS,CAAC,IAAI;aAC1B,CAAC,CAAC;YAEH,OAAO,IAAI,CAAC,oBAAoB,CAAC,QAAQ,CAAC,CAAC;QAC7C,CAAC;KAAA;CACF;AA5DD,qCA4DC"}
|
|
@@ -1,24 +1,26 @@
|
|
|
1
1
|
import IOperation, { FetchOptions, FinishedOptions, GetSchemaOptions } from '../contracts/IOperation';
|
|
2
|
-
import HiveDriver from '../hive/HiveDriver';
|
|
3
2
|
import { TGetOperationStatusResp, TOperationHandle, TTableSchema, TSparkDirectResults, TGetResultSetMetadataResp } from '../../thrift/TCLIService_types';
|
|
4
3
|
import Status from '../dto/Status';
|
|
5
|
-
import
|
|
4
|
+
import IClientContext from '../contracts/IClientContext';
|
|
6
5
|
interface DBSQLOperationConstructorOptions {
|
|
7
|
-
|
|
6
|
+
handle: TOperationHandle;
|
|
7
|
+
directResults?: TSparkDirectResults;
|
|
8
|
+
context: IClientContext;
|
|
8
9
|
}
|
|
9
10
|
export default class DBSQLOperation implements IOperation {
|
|
10
|
-
private readonly
|
|
11
|
+
private readonly context;
|
|
11
12
|
private readonly operationHandle;
|
|
12
|
-
private readonly logger;
|
|
13
13
|
onClose?: () => void;
|
|
14
|
-
private readonly _status;
|
|
15
14
|
private readonly _data;
|
|
16
15
|
private readonly closeOperation?;
|
|
17
16
|
private closed;
|
|
18
17
|
private cancelled;
|
|
19
18
|
private metadata?;
|
|
19
|
+
private state;
|
|
20
|
+
private operationStatus?;
|
|
21
|
+
private hasResultSet;
|
|
20
22
|
private resultHandler?;
|
|
21
|
-
constructor(
|
|
23
|
+
constructor({ handle, directResults, context }: DBSQLOperationConstructorOptions);
|
|
22
24
|
getId(): string;
|
|
23
25
|
/**
|
|
24
26
|
* Fetches all data
|
|
@@ -64,5 +66,6 @@ export default class DBSQLOperation implements IOperation {
|
|
|
64
66
|
private waitUntilReady;
|
|
65
67
|
private fetchMetadata;
|
|
66
68
|
private getResultHandler;
|
|
69
|
+
private processOperationStatusResponse;
|
|
67
70
|
}
|
|
68
71
|
export {};
|