@databricks/sql 1.3.0 → 1.4.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/dist/DBSQLClient.d.ts +1 -0
- package/dist/DBSQLClient.js +8 -1
- package/dist/DBSQLClient.js.map +1 -1
- package/dist/DBSQLOperation/OperationStatusHelper.d.ts +1 -1
- package/dist/DBSQLOperation/OperationStatusHelper.js +29 -6
- package/dist/DBSQLOperation/OperationStatusHelper.js.map +1 -1
- package/dist/DBSQLOperation/SchemaHelper.d.ts +1 -0
- package/dist/DBSQLOperation/SchemaHelper.js +20 -7
- package/dist/DBSQLOperation/SchemaHelper.js.map +1 -1
- package/dist/DBSQLOperation/index.d.ts +9 -2
- package/dist/DBSQLOperation/index.js +86 -10
- package/dist/DBSQLOperation/index.js.map +1 -1
- package/dist/DBSQLSession.d.ts +10 -1
- package/dist/DBSQLSession.js +72 -14
- package/dist/DBSQLSession.js.map +1 -1
- package/dist/contracts/IDBSQLSession.d.ts +1 -0
- package/dist/errors/OperationStateError.d.ts +10 -2
- package/dist/errors/OperationStateError.js +19 -2
- package/dist/errors/OperationStateError.js.map +1 -1
- package/dist/globalConfig.d.ts +2 -0
- package/dist/globalConfig.js +2 -0
- package/dist/globalConfig.js.map +1 -1
- package/dist/result/ArrowResult.d.ts +3 -2
- package/dist/result/ArrowResult.js +35 -17
- package/dist/result/ArrowResult.js.map +1 -1
- package/dist/result/CloudFetchResult.d.ts +13 -0
- package/dist/result/CloudFetchResult.js +69 -0
- package/dist/result/CloudFetchResult.js.map +1 -0
- package/dist/result/IOperationResult.d.ts +2 -1
- package/dist/result/JsonResult.d.ts +2 -1
- package/dist/result/JsonResult.js +24 -8
- package/dist/result/JsonResult.js.map +1 -1
- package/dist/utils/CloseableCollection.d.ts +10 -0
- package/dist/utils/CloseableCollection.js +40 -0
- package/dist/utils/CloseableCollection.js.map +1 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +3 -1
- package/thrift/TCLIService.d.ts +43 -0
- package/thrift/TCLIService_types.d.ts +26 -6
- package/thrift/TCLIService_types.js +593 -284
package/dist/DBSQLClient.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ export default class DBSQLClient extends EventEmitter implements IDBSQLClient {
|
|
|
10
10
|
private additionalHeaders;
|
|
11
11
|
private readonly logger;
|
|
12
12
|
private readonly thrift;
|
|
13
|
+
private sessions;
|
|
13
14
|
constructor(options?: ClientOptions);
|
|
14
15
|
private getConnectionOptions;
|
|
15
16
|
private getAuthProvider;
|
package/dist/DBSQLClient.js
CHANGED
|
@@ -38,6 +38,7 @@ const PlainHttpAuthentication_1 = __importDefault(require("./connection/auth/Pla
|
|
|
38
38
|
const DatabricksOAuth_1 = __importDefault(require("./connection/auth/DatabricksOAuth"));
|
|
39
39
|
const IDBSQLLogger_1 = require("./contracts/IDBSQLLogger");
|
|
40
40
|
const DBSQLLogger_1 = __importDefault(require("./DBSQLLogger"));
|
|
41
|
+
const CloseableCollection_1 = __importDefault(require("./utils/CloseableCollection"));
|
|
41
42
|
function prependSlash(str) {
|
|
42
43
|
if (str.length > 0 && str.charAt(0) !== '/') {
|
|
43
44
|
return `/${str}`;
|
|
@@ -63,6 +64,7 @@ class DBSQLClient extends events_1.EventEmitter {
|
|
|
63
64
|
this.connectionOptions = null;
|
|
64
65
|
this.additionalHeaders = {};
|
|
65
66
|
this.thrift = thrift_1.default;
|
|
67
|
+
this.sessions = new CloseableCollection_1.default();
|
|
66
68
|
this.logger = (options === null || options === void 0 ? void 0 : options.logger) || new DBSQLLogger_1.default();
|
|
67
69
|
this.logger.log(IDBSQLLogger_1.LogLevel.info, 'Created DBSQLClient');
|
|
68
70
|
}
|
|
@@ -133,7 +135,11 @@ class DBSQLClient extends events_1.EventEmitter {
|
|
|
133
135
|
const driver = new HiveDriver_1.default(() => this.getClient());
|
|
134
136
|
const response = yield driver.openSession(Object.assign({ client_protocol_i64: new Types_1.Int64(TCLIService_types_1.TProtocolVersion.SPARK_CLI_SERVICE_PROTOCOL_V6) }, getInitialNamespaceOptions(request.initialCatalog, request.initialSchema)));
|
|
135
137
|
Status_1.default.assert(response.status);
|
|
136
|
-
|
|
138
|
+
const session = new DBSQLSession_1.default(driver, (0, utils_1.definedOrError)(response.sessionHandle), {
|
|
139
|
+
logger: this.logger,
|
|
140
|
+
});
|
|
141
|
+
this.sessions.add(session);
|
|
142
|
+
return session;
|
|
137
143
|
});
|
|
138
144
|
}
|
|
139
145
|
getClient() {
|
|
@@ -188,6 +194,7 @@ class DBSQLClient extends events_1.EventEmitter {
|
|
|
188
194
|
}
|
|
189
195
|
close() {
|
|
190
196
|
return __awaiter(this, void 0, void 0, function* () {
|
|
197
|
+
yield this.sessions.closeAll();
|
|
191
198
|
this.client = null;
|
|
192
199
|
this.authProvider = null;
|
|
193
200
|
this.connectionOptions = null;
|
package/dist/DBSQLClient.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DBSQLClient.js","sourceRoot":"","sources":["../lib/DBSQLClient.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oDAA6C;AAE7C,mCAAsC;AACtC,wEAAgD;AAChD,mEAA+D;AAE/D,mEAA2C;AAC3C,wCAAqC;AACrC,kEAA0C;AAG1C,6FAAqE;AAErE,0DAAkC;AAClC,+EAAuD;AACvD,mCAAgF;AAChF,wGAAgF;AAChF,wFAAgE;AAChE,2DAAkE;AAClE,gEAAwC;
|
|
1
|
+
{"version":3,"file":"DBSQLClient.js","sourceRoot":"","sources":["../lib/DBSQLClient.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oDAA6C;AAE7C,mCAAsC;AACtC,wEAAgD;AAChD,mEAA+D;AAE/D,mEAA2C;AAC3C,wCAAqC;AACrC,kEAA0C;AAG1C,6FAAqE;AAErE,0DAAkC;AAClC,+EAAuD;AACvD,mCAAgF;AAChF,wGAAgF;AAChF,wFAAgE;AAChE,2D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IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YACrB,CAAC,CAAC,CAAC;YAEH,gBAAgB,CAAC,EAAE,CAAC,SAAS,EAAE,GAAG,EAAE;gBAClC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,uBAAQ,CAAC,KAAK,EAAE,uBAAuB,CAAC,CAAC;gBACzD,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;YACvB,CAAC,CAAC,CAAC;YAEH,OAAO,UAAU,CAAC;QACpB,CAAC;KAAA;IAEY,KAAK;;YAChB,MAAM,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC;YAE/B,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;YACnB,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC;YACzB,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC;QAChC,CAAC;KAAA;CACF;AAnLD,8BAmLC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TGetOperationStatusResp, TOperationHandle } from '../../thrift/TCLIService_types';
|
|
2
2
|
import HiveDriver from '../hive/HiveDriver';
|
|
3
3
|
import { WaitUntilReadyOptions } from '../contracts/IOperation';
|
|
4
4
|
export default class OperationStatusHelper {
|
|
@@ -1,4 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
26
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
27
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -14,7 +37,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
38
|
const TCLIService_types_1 = require("../../thrift/TCLIService_types");
|
|
16
39
|
const Status_1 = __importDefault(require("../dto/Status"));
|
|
17
|
-
const OperationStateError_1 =
|
|
40
|
+
const OperationStateError_1 = __importStar(require("../errors/OperationStateError"));
|
|
18
41
|
function delay(ms) {
|
|
19
42
|
return __awaiter(this, void 0, void 0, function* () {
|
|
20
43
|
return new Promise((resolve) => {
|
|
@@ -85,16 +108,16 @@ class OperationStatusHelper {
|
|
|
85
108
|
case TCLIService_types_1.TOperationState.FINISHED_STATE:
|
|
86
109
|
return true;
|
|
87
110
|
case TCLIService_types_1.TOperationState.CANCELED_STATE:
|
|
88
|
-
throw new OperationStateError_1.default(
|
|
111
|
+
throw new OperationStateError_1.default(OperationStateError_1.OperationStateErrorCode.Canceled, response);
|
|
89
112
|
case TCLIService_types_1.TOperationState.CLOSED_STATE:
|
|
90
|
-
throw new OperationStateError_1.default(
|
|
113
|
+
throw new OperationStateError_1.default(OperationStateError_1.OperationStateErrorCode.Closed, response);
|
|
91
114
|
case TCLIService_types_1.TOperationState.ERROR_STATE:
|
|
92
|
-
throw new OperationStateError_1.default(
|
|
115
|
+
throw new OperationStateError_1.default(OperationStateError_1.OperationStateErrorCode.Error, response);
|
|
93
116
|
case TCLIService_types_1.TOperationState.TIMEDOUT_STATE:
|
|
94
|
-
throw new OperationStateError_1.default(
|
|
117
|
+
throw new OperationStateError_1.default(OperationStateError_1.OperationStateErrorCode.Timeout, response);
|
|
95
118
|
case TCLIService_types_1.TOperationState.UKNOWN_STATE:
|
|
96
119
|
default:
|
|
97
|
-
throw new OperationStateError_1.default(
|
|
120
|
+
throw new OperationStateError_1.default(OperationStateError_1.OperationStateErrorCode.Unknown, response);
|
|
98
121
|
}
|
|
99
122
|
});
|
|
100
123
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OperationStatusHelper.js","sourceRoot":"","sources":["../../lib/DBSQLOperation/OperationStatusHelper.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"OperationStatusHelper.js","sourceRoot":"","sources":["../../lib/DBSQLOperation/OperationStatusHelper.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,sEAA4G;AAE5G,2DAAmC;AAEnC,qFAA6F;AAE7F,SAAe,KAAK,CAAC,EAAW;;QAC9B,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;YAC7B,UAAU,CAAC,GAAG,EAAE;gBACd,OAAO,EAAE,CAAC;YACZ,CAAC,EAAE,EAAE,CAAC,CAAC;QACT,CAAC,CAAC,CAAC;IACL,CAAC;CAAA;AAED,MAAqB,qBAAqB;IAaxC,YAAY,MAAkB,EAAE,eAAiC,EAAE,eAAyC;QARpG,UAAK,GAAW,mCAAe,CAAC,iBAAiB,CAAC;QAMnD,iBAAY,GAAY,KAAK,CAAC;QAGnC,IAAI,CAAC,MAAM,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AC,KAAK,KAAK,mCAAe,CAAC,cAAc,EAAE;gBACjD,OAAO;aACR;YACD,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;YAC5C,IAAI,CAAC,OAAO,EAAE;gBACZ,MAAM,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,yCAAyC;gBAC3D,OAAO,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;aACrC;QACH,CAAC;KAAA;CACF;AAvGD,wCAuGC"}
|
|
@@ -5,6 +5,7 @@ export default class SchemaHelper {
|
|
|
5
5
|
private readonly driver;
|
|
6
6
|
private readonly operationHandle;
|
|
7
7
|
private metadata?;
|
|
8
|
+
private resultHandler?;
|
|
8
9
|
constructor(driver: HiveDriver, operationHandle: TOperationHandle, metadata?: TGetResultSetMetadataResp);
|
|
9
10
|
private fetchMetadata;
|
|
10
11
|
fetch(): Promise<import("../../thrift/TCLIService_types").TTableSchema>;
|
|
@@ -16,6 +16,7 @@ const TCLIService_types_1 = require("../../thrift/TCLIService_types");
|
|
|
16
16
|
const Status_1 = __importDefault(require("../dto/Status"));
|
|
17
17
|
const JsonResult_1 = __importDefault(require("../result/JsonResult"));
|
|
18
18
|
const ArrowResult_1 = __importDefault(require("../result/ArrowResult"));
|
|
19
|
+
const CloudFetchResult_1 = __importDefault(require("../result/CloudFetchResult"));
|
|
19
20
|
const HiveDriverError_1 = __importDefault(require("../errors/HiveDriverError"));
|
|
20
21
|
const utils_1 = require("../utils");
|
|
21
22
|
class SchemaHelper {
|
|
@@ -46,14 +47,26 @@ class SchemaHelper {
|
|
|
46
47
|
return __awaiter(this, void 0, void 0, function* () {
|
|
47
48
|
const metadata = yield this.fetchMetadata();
|
|
48
49
|
const resultFormat = (0, utils_1.definedOrError)(metadata.resultFormat);
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
50
|
+
if (!this.resultHandler) {
|
|
51
|
+
switch (resultFormat) {
|
|
52
|
+
case TCLIService_types_1.TSparkRowSetType.COLUMN_BASED_SET:
|
|
53
|
+
this.resultHandler = new JsonResult_1.default(metadata.schema);
|
|
54
|
+
break;
|
|
55
|
+
case TCLIService_types_1.TSparkRowSetType.ARROW_BASED_SET:
|
|
56
|
+
this.resultHandler = new ArrowResult_1.default(metadata.schema, metadata.arrowSchema);
|
|
57
|
+
break;
|
|
58
|
+
case TCLIService_types_1.TSparkRowSetType.URL_BASED_SET:
|
|
59
|
+
this.resultHandler = new CloudFetchResult_1.default(metadata.schema);
|
|
60
|
+
break;
|
|
61
|
+
default:
|
|
62
|
+
this.resultHandler = undefined;
|
|
63
|
+
break;
|
|
64
|
+
}
|
|
56
65
|
}
|
|
66
|
+
if (!this.resultHandler) {
|
|
67
|
+
throw new HiveDriverError_1.default(`Unsupported result format: ${TCLIService_types_1.TSparkRowSetType[resultFormat]}`);
|
|
68
|
+
}
|
|
69
|
+
return this.resultHandler;
|
|
57
70
|
});
|
|
58
71
|
}
|
|
59
72
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaHelper.js","sourceRoot":"","sources":["../../lib/DBSQLOperation/SchemaHelper.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,sEAA+G;AAE/G,2DAAmC;AAEnC,sEAA8C;AAC9C,wEAAgD;AAChD,gFAAwD;AACxD,oCAA0C;AAE1C,MAAqB,YAAY;
|
|
1
|
+
{"version":3,"file":"SchemaHelper.js","sourceRoot":"","sources":["../../lib/DBSQLOperation/SchemaHelper.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,sEAA+G;AAE/G,2DAAmC;AAEnC,sEAA8C;AAC9C,wEAAgD;AAChD,kFAA0D;AAC1D,gFAAwD;AACxD,oCAA0C;AAE1C,MAAqB,YAAY;IAS/B,YAAY,MAAkB,EAAE,eAAiC,EAAE,QAAoC;QACrG,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;Q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C;wBAC3D,MAAM;oBACR;wBACE,IAAI,CAAC,aAAa,GAAG,SAAS,CAAC;wBAC/B,MAAM;iBACT;aACF;YAED,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE;gBACvB,MAAM,IAAI,yBAAe,CAAC,8BAA8B,oCAAgB,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC;aAC3F;YAED,OAAO,IAAI,CAAC,aAAa,CAAC;QAC5B,CAAC;KAAA;CACF;AA3DD,+BA2DC"}
|
|
@@ -1,17 +1,21 @@
|
|
|
1
|
-
import IOperation, { FetchOptions,
|
|
1
|
+
import IOperation, { FetchOptions, FinishedOptions, GetSchemaOptions } from '../contracts/IOperation';
|
|
2
2
|
import HiveDriver from '../hive/HiveDriver';
|
|
3
3
|
import { TGetOperationStatusResp, TOperationHandle, TTableSchema, TSparkDirectResults } from '../../thrift/TCLIService_types';
|
|
4
4
|
import Status from '../dto/Status';
|
|
5
5
|
import IDBSQLLogger from '../contracts/IDBSQLLogger';
|
|
6
|
+
interface DBSQLOperationConstructorOptions {
|
|
7
|
+
logger: IDBSQLLogger;
|
|
8
|
+
}
|
|
6
9
|
export default class DBSQLOperation implements IOperation {
|
|
7
10
|
private readonly driver;
|
|
8
11
|
private readonly operationHandle;
|
|
9
12
|
private readonly logger;
|
|
13
|
+
onClose?: () => void;
|
|
10
14
|
private readonly _status;
|
|
11
15
|
private readonly _schema;
|
|
12
16
|
private readonly _data;
|
|
13
17
|
private readonly _completeOperation;
|
|
14
|
-
constructor(driver: HiveDriver, operationHandle: TOperationHandle, logger:
|
|
18
|
+
constructor(driver: HiveDriver, operationHandle: TOperationHandle, { logger }: DBSQLOperationConstructorOptions, directResults?: TSparkDirectResults);
|
|
15
19
|
getId(): string;
|
|
16
20
|
/**
|
|
17
21
|
* Fetches all data
|
|
@@ -52,4 +56,7 @@ export default class DBSQLOperation implements IOperation {
|
|
|
52
56
|
finished(options?: FinishedOptions): Promise<void>;
|
|
53
57
|
hasMoreRows(): Promise<boolean>;
|
|
54
58
|
getSchema(options?: GetSchemaOptions): Promise<TTableSchema | null>;
|
|
59
|
+
private failIfClosed;
|
|
60
|
+
private waitUntilReady;
|
|
55
61
|
}
|
|
62
|
+
export {};
|
|
@@ -1,4 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
26
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
27
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -13,14 +36,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
36
|
};
|
|
14
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
38
|
const uuid_1 = require("uuid");
|
|
39
|
+
const Status_1 = __importDefault(require("../dto/Status"));
|
|
16
40
|
const OperationStatusHelper_1 = __importDefault(require("./OperationStatusHelper"));
|
|
17
41
|
const SchemaHelper_1 = __importDefault(require("./SchemaHelper"));
|
|
18
42
|
const FetchResultsHelper_1 = __importDefault(require("./FetchResultsHelper"));
|
|
19
43
|
const CompleteOperationHelper_1 = __importDefault(require("./CompleteOperationHelper"));
|
|
20
44
|
const IDBSQLLogger_1 = require("../contracts/IDBSQLLogger");
|
|
45
|
+
const OperationStateError_1 = __importStar(require("../errors/OperationStateError"));
|
|
21
46
|
const defaultMaxRows = 100000;
|
|
22
47
|
class DBSQLOperation {
|
|
23
|
-
constructor(driver, operationHandle, logger, directResults) {
|
|
48
|
+
constructor(driver, operationHandle, { logger }, directResults) {
|
|
24
49
|
this.driver = driver;
|
|
25
50
|
this.operationHandle = operationHandle;
|
|
26
51
|
this.logger = logger;
|
|
@@ -69,15 +94,17 @@ class DBSQLOperation {
|
|
|
69
94
|
fetchChunk(options) {
|
|
70
95
|
var _a;
|
|
71
96
|
return __awaiter(this, void 0, void 0, function* () {
|
|
97
|
+
yield this.failIfClosed();
|
|
72
98
|
if (!this._status.hasResultSet) {
|
|
73
99
|
return [];
|
|
74
100
|
}
|
|
75
|
-
yield this.
|
|
101
|
+
yield this.waitUntilReady(options);
|
|
76
102
|
const [resultHandler, data] = yield Promise.all([
|
|
77
103
|
this._schema.getResultHandler(),
|
|
78
104
|
this._data.fetch((options === null || options === void 0 ? void 0 : options.maxRows) || defaultMaxRows),
|
|
79
105
|
]);
|
|
80
|
-
|
|
106
|
+
yield this.failIfClosed();
|
|
107
|
+
const result = yield resultHandler.getValue(data ? [data] : []);
|
|
81
108
|
(_a = this.logger) === null || _a === void 0 ? void 0 : _a.log(IDBSQLLogger_1.LogLevel.debug, `Fetched chunk of size: ${(options === null || options === void 0 ? void 0 : options.maxRows) || defaultMaxRows} from operation with id: ${this.getId()}`);
|
|
82
109
|
return result;
|
|
83
110
|
});
|
|
@@ -90,6 +117,7 @@ class DBSQLOperation {
|
|
|
90
117
|
status(progress = false) {
|
|
91
118
|
var _a;
|
|
92
119
|
return __awaiter(this, void 0, void 0, function* () {
|
|
120
|
+
yield this.failIfClosed();
|
|
93
121
|
(_a = this.logger) === null || _a === void 0 ? void 0 : _a.log(IDBSQLLogger_1.LogLevel.debug, `Fetching status for operation with id: ${this.getId()}`);
|
|
94
122
|
return this._status.status(progress);
|
|
95
123
|
});
|
|
@@ -99,10 +127,16 @@ class DBSQLOperation {
|
|
|
99
127
|
* @throws {StatusError}
|
|
100
128
|
*/
|
|
101
129
|
cancel() {
|
|
102
|
-
var _a;
|
|
130
|
+
var _a, _b;
|
|
103
131
|
return __awaiter(this, void 0, void 0, function* () {
|
|
132
|
+
if (this._completeOperation.closed || this._completeOperation.cancelled) {
|
|
133
|
+
return Status_1.default.success();
|
|
134
|
+
}
|
|
104
135
|
(_a = this.logger) === null || _a === void 0 ? void 0 : _a.log(IDBSQLLogger_1.LogLevel.debug, `Cancelling operation with id: ${this.getId()}`);
|
|
105
|
-
|
|
136
|
+
const result = this._completeOperation.cancel();
|
|
137
|
+
// Cancelled operation becomes unusable, similarly to being closed
|
|
138
|
+
(_b = this.onClose) === null || _b === void 0 ? void 0 : _b.call(this);
|
|
139
|
+
return result;
|
|
106
140
|
});
|
|
107
141
|
}
|
|
108
142
|
/**
|
|
@@ -110,36 +144,78 @@ class DBSQLOperation {
|
|
|
110
144
|
* @throws {StatusError}
|
|
111
145
|
*/
|
|
112
146
|
close() {
|
|
113
|
-
var _a;
|
|
147
|
+
var _a, _b;
|
|
114
148
|
return __awaiter(this, void 0, void 0, function* () {
|
|
149
|
+
if (this._completeOperation.closed || this._completeOperation.cancelled) {
|
|
150
|
+
return Status_1.default.success();
|
|
151
|
+
}
|
|
115
152
|
(_a = this.logger) === null || _a === void 0 ? void 0 : _a.log(IDBSQLLogger_1.LogLevel.debug, `Closing operation with id: ${this.getId()}`);
|
|
116
|
-
|
|
153
|
+
const result = yield this._completeOperation.close();
|
|
154
|
+
(_b = this.onClose) === null || _b === void 0 ? void 0 : _b.call(this);
|
|
155
|
+
return result;
|
|
117
156
|
});
|
|
118
157
|
}
|
|
119
158
|
finished(options) {
|
|
120
159
|
return __awaiter(this, void 0, void 0, function* () {
|
|
121
|
-
yield this.
|
|
160
|
+
yield this.failIfClosed();
|
|
161
|
+
yield this.waitUntilReady(options);
|
|
122
162
|
});
|
|
123
163
|
}
|
|
124
164
|
hasMoreRows() {
|
|
125
165
|
return __awaiter(this, void 0, void 0, function* () {
|
|
166
|
+
// If operation is closed or cancelled - we should not try to get data from it
|
|
126
167
|
if (this._completeOperation.closed || this._completeOperation.cancelled) {
|
|
127
168
|
return false;
|
|
128
169
|
}
|
|
129
|
-
|
|
170
|
+
// Return early if there are still data available for fetching
|
|
171
|
+
if (this._data.hasMoreRows) {
|
|
172
|
+
return true;
|
|
173
|
+
}
|
|
174
|
+
// If we fetched all the data from server - check if there's anything buffered in result handler
|
|
175
|
+
const resultHandler = yield this._schema.getResultHandler();
|
|
176
|
+
return resultHandler.hasPendingData();
|
|
130
177
|
});
|
|
131
178
|
}
|
|
132
179
|
getSchema(options) {
|
|
133
180
|
var _a;
|
|
134
181
|
return __awaiter(this, void 0, void 0, function* () {
|
|
182
|
+
yield this.failIfClosed();
|
|
135
183
|
if (!this._status.hasResultSet) {
|
|
136
184
|
return null;
|
|
137
185
|
}
|
|
138
|
-
yield this.
|
|
186
|
+
yield this.waitUntilReady(options);
|
|
139
187
|
(_a = this.logger) === null || _a === void 0 ? void 0 : _a.log(IDBSQLLogger_1.LogLevel.debug, `Fetching schema for operation with id: ${this.getId()}`);
|
|
140
188
|
return this._schema.fetch();
|
|
141
189
|
});
|
|
142
190
|
}
|
|
191
|
+
failIfClosed() {
|
|
192
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
193
|
+
if (this._completeOperation.closed) {
|
|
194
|
+
throw new OperationStateError_1.default(OperationStateError_1.OperationStateErrorCode.Closed);
|
|
195
|
+
}
|
|
196
|
+
if (this._completeOperation.cancelled) {
|
|
197
|
+
throw new OperationStateError_1.default(OperationStateError_1.OperationStateErrorCode.Canceled);
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
waitUntilReady(options) {
|
|
202
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
203
|
+
try {
|
|
204
|
+
yield this._status.waitUntilReady(options);
|
|
205
|
+
}
|
|
206
|
+
catch (error) {
|
|
207
|
+
if (error instanceof OperationStateError_1.default) {
|
|
208
|
+
if (error.errorCode === OperationStateError_1.OperationStateErrorCode.Canceled) {
|
|
209
|
+
this._completeOperation.cancelled = true;
|
|
210
|
+
}
|
|
211
|
+
if (error.errorCode === OperationStateError_1.OperationStateErrorCode.Closed) {
|
|
212
|
+
this._completeOperation.closed = true;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
throw error;
|
|
216
|
+
}
|
|
217
|
+
});
|
|
218
|
+
}
|
|
143
219
|
}
|
|
144
220
|
exports.default = DBSQLOperation;
|
|
145
221
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../lib/DBSQLOperation/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../lib/DBSQLOperation/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+BAA6C;AAc7C,2DAAmC;AACnC,oFAA4D;AAC5D,kEAA0C;AAC1C,8EAAsD;AACtD,wFAAgE;AAChE,4DAAmE;AACnE,qFAA6F;AAE7F,MAAM,cAAc,GAAG,MAAM,CAAC;AAM9B,MAAqB,cAAc;IAiBjC,YACE,MAAkB,EAClB,eAAiC,EACjC,EAAE,MAAM,EAAoC,EAC5C,aAAmC;QAEnC,IAAI,CAA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A+B;;YAC1D,IAAI;gBACF,MAAM,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;aAC5C;YAAC,OAAO,KAAK,EAAE;gBACd,IAAI,KAAK,YAAY,6BAAmB,EAAE;oBACxC,IAAI,KAAK,CAAC,SAAS,KAAK,6CAAuB,CAAC,QAAQ,EAAE;wBACxD,IAAI,CAAC,kBAAkB,CAAC,SAAS,GAAG,IAAI,CAAC;qBAC1C;oBACD,IAAI,KAAK,CAAC,SAAS,KAAK,6CAAuB,CAAC,MAAM,EAAE;wBACtD,IAAI,CAAC,kBAAkB,CAAC,MAAM,GAAG,IAAI,CAAC;qBACvC;iBACF;gBACD,MAAM,KAAK,CAAC;aACb;QACH,CAAC;KAAA;CACF;AA7MD,iCA6MC"}
|
package/dist/DBSQLSession.d.ts
CHANGED
|
@@ -5,11 +5,17 @@ import IOperation from './contracts/IOperation';
|
|
|
5
5
|
import Status from './dto/Status';
|
|
6
6
|
import InfoValue from './dto/InfoValue';
|
|
7
7
|
import IDBSQLLogger from './contracts/IDBSQLLogger';
|
|
8
|
+
interface DBSQLSessionConstructorOptions {
|
|
9
|
+
logger: IDBSQLLogger;
|
|
10
|
+
}
|
|
8
11
|
export default class DBSQLSession implements IDBSQLSession {
|
|
9
12
|
private readonly driver;
|
|
10
13
|
private readonly sessionHandle;
|
|
11
14
|
private readonly logger;
|
|
12
|
-
|
|
15
|
+
private isOpen;
|
|
16
|
+
onClose?: () => void;
|
|
17
|
+
private operations;
|
|
18
|
+
constructor(driver: HiveDriver, sessionHandle: TSessionHandle, { logger }: DBSQLSessionConstructorOptions);
|
|
13
19
|
getId(): string;
|
|
14
20
|
/**
|
|
15
21
|
* Fetches info
|
|
@@ -94,4 +100,7 @@ export default class DBSQLSession implements IDBSQLSession {
|
|
|
94
100
|
*/
|
|
95
101
|
close(): Promise<Status>;
|
|
96
102
|
private createOperation;
|
|
103
|
+
private failIfClosed;
|
|
104
|
+
private handleResponse;
|
|
97
105
|
}
|
|
106
|
+
export {};
|