@databricks/sql 1.4.0 → 1.5.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/README.md +1 -1
- package/dist/DBSQLClient.js +3 -1
- package/dist/DBSQLClient.js.map +1 -1
- package/dist/DBSQLOperation/index.d.ts +9 -3
- package/dist/DBSQLOperation/index.js +81 -19
- package/dist/DBSQLOperation/index.js.map +1 -1
- package/dist/DBSQLParameter.d.ts +29 -0
- package/dist/DBSQLParameter.js +73 -0
- package/dist/DBSQLParameter.js.map +1 -0
- package/dist/DBSQLSession.d.ts +5 -1
- package/dist/DBSQLSession.js +147 -12
- package/dist/DBSQLSession.js.map +1 -1
- package/dist/connection/auth/DatabricksOAuth/OAuthManager.d.ts +5 -0
- package/dist/connection/auth/DatabricksOAuth/OAuthManager.js +52 -17
- package/dist/connection/auth/DatabricksOAuth/OAuthManager.js.map +1 -1
- package/dist/contracts/IDBSQLClient.d.ts +2 -0
- package/dist/contracts/IDBSQLSession.d.ts +33 -0
- package/dist/errors/OperationStateError.js +2 -1
- package/dist/errors/OperationStateError.js.map +1 -1
- package/dist/errors/StagingError.d.ts +2 -0
- package/dist/errors/StagingError.js +6 -0
- package/dist/errors/StagingError.js.map +1 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/result/ArrowResult.js +2 -2
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +2 -2
- package/thrift/TCLIService.d.ts +2 -1
- package/thrift/TCLIService.js +1 -1
- package/thrift/TCLIService_types.d.ts +11 -3
- package/thrift/TCLIService_types.js +41 -4
- package/dist/DBSQLOperation/CompleteOperationHelper.d.ts +0 -13
- package/dist/DBSQLOperation/CompleteOperationHelper.js +0 -56
- package/dist/DBSQLOperation/CompleteOperationHelper.js.map +0 -1
- package/dist/DBSQLOperation/SchemaHelper.d.ts +0 -13
- package/dist/DBSQLOperation/SchemaHelper.js +0 -74
- package/dist/DBSQLOperation/SchemaHelper.js.map +0 -1
|
@@ -12,7 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
const buffer_1 = require("buffer");
|
|
13
13
|
const apache_arrow_1 = require("apache-arrow");
|
|
14
14
|
const utils_1 = require("./utils");
|
|
15
|
-
const { isArrowBigNumSymbol,
|
|
15
|
+
const { isArrowBigNumSymbol, bigNumToBigInt } = apache_arrow_1.util;
|
|
16
16
|
class ArrowResult {
|
|
17
17
|
constructor(schema, arrowSchema) {
|
|
18
18
|
this.schema = (0, utils_1.getSchemaColumns)(schema);
|
|
@@ -98,7 +98,7 @@ class ArrowResult {
|
|
|
98
98
|
// Convert big number values to BigInt
|
|
99
99
|
// Decimals are also represented as big numbers in Arrow, so additionally process them (convert to float)
|
|
100
100
|
if (value instanceof Object && value[isArrowBigNumSymbol]) {
|
|
101
|
-
const result =
|
|
101
|
+
const result = bigNumToBigInt(value);
|
|
102
102
|
if (apache_arrow_1.DataType.isDecimal(valueType)) {
|
|
103
103
|
return Number(result) / Math.pow(10, valueType.scale);
|
|
104
104
|
}
|
package/dist/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: "1.
|
|
1
|
+
declare const _default: "1.5.0";
|
|
2
2
|
export default _default;
|
package/dist/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@databricks/sql",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"description": "Driver for connection to Databricks SQL via Thrift API.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
"typescript": "^4.9.3"
|
|
73
73
|
},
|
|
74
74
|
"dependencies": {
|
|
75
|
-
"apache-arrow": "^
|
|
75
|
+
"apache-arrow": "^13.0.0",
|
|
76
76
|
"commander": "^9.3.0",
|
|
77
77
|
"node-fetch": "^2.6.12",
|
|
78
78
|
"node-int64": "^0.4.0",
|
package/thrift/TCLIService.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//
|
|
2
|
-
// Autogenerated by Thrift Compiler (0.
|
|
2
|
+
// Autogenerated by Thrift Compiler (0.19.0)
|
|
3
3
|
//
|
|
4
4
|
// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
|
|
5
5
|
//
|
|
@@ -22,6 +22,7 @@ import TOperationState = ttypes.TOperationState
|
|
|
22
22
|
import TOperationType = ttypes.TOperationType
|
|
23
23
|
import TGetInfoType = ttypes.TGetInfoType
|
|
24
24
|
import TResultPersistenceMode = ttypes.TResultPersistenceMode
|
|
25
|
+
import TDBSqlCloseOperationReason = ttypes.TDBSqlCloseOperationReason
|
|
25
26
|
import TCacheLookupResult = ttypes.TCacheLookupResult
|
|
26
27
|
import TCloudFetchDisabledReason = ttypes.TCloudFetchDisabledReason
|
|
27
28
|
import TDBSqlManifestFileFormat = ttypes.TDBSqlManifestFileFormat
|
package/thrift/TCLIService.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//
|
|
2
|
-
// Autogenerated by Thrift Compiler (0.
|
|
2
|
+
// Autogenerated by Thrift Compiler (0.19.0)
|
|
3
3
|
//
|
|
4
4
|
// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
|
|
5
5
|
//
|
|
@@ -29,6 +29,7 @@ declare enum TProtocolVersion {
|
|
|
29
29
|
SPARK_CLI_SERVICE_PROTOCOL_V5 = 42245,
|
|
30
30
|
SPARK_CLI_SERVICE_PROTOCOL_V6 = 42246,
|
|
31
31
|
SPARK_CLI_SERVICE_PROTOCOL_V7 = 42247,
|
|
32
|
+
SPARK_CLI_SERVICE_PROTOCOL_V8 = 42248,
|
|
32
33
|
}
|
|
33
34
|
|
|
34
35
|
declare enum TTypeId {
|
|
@@ -173,6 +174,11 @@ declare enum TResultPersistenceMode {
|
|
|
173
174
|
ALL_RESULTS = 2,
|
|
174
175
|
}
|
|
175
176
|
|
|
177
|
+
declare enum TDBSqlCloseOperationReason {
|
|
178
|
+
NONE = 0,
|
|
179
|
+
COMMAND_INACTIVITY_TIMEOUT = 1,
|
|
180
|
+
}
|
|
181
|
+
|
|
176
182
|
declare enum TCacheLookupResult {
|
|
177
183
|
CACHE_INELIGIBLE = 0,
|
|
178
184
|
LOCAL_CACHE_HIT = 1,
|
|
@@ -721,8 +727,9 @@ declare class TExecuteStatementReq {
|
|
|
721
727
|
public preferDriverOnlyUpload?: boolean;
|
|
722
728
|
public enforceEmbeddedSchemaCorrectness?: boolean;
|
|
723
729
|
public idempotencyToken?: string;
|
|
730
|
+
public throwErrorOnByteLimitTruncation?: boolean;
|
|
724
731
|
|
|
725
|
-
constructor(args?: { sessionHandle: TSessionHandle; statement: string; confOverlay?: { [k: string]: string; }; runAsync?: boolean; getDirectResults?: TSparkGetDirectResults; queryTimeout?: Int64; canReadArrowResult?: boolean; canDownloadResult?: boolean; canDecompressLZ4Result?: boolean; maxBytesPerFile?: Int64; useArrowNativeTypes?: TSparkArrowTypes; resultRowLimit?: Int64; parameters?: TSparkParameter[]; maxBytesPerBatch?: Int64; statementConf?: TStatementConf; operationId?: THandleIdentifier; sessionConf?: TDBSqlSessionConf; rejectHighCostQueries?: boolean; estimatedCost?: number; executionVersion?: number; requestValidation?: Buffer; resultPersistenceMode?: TResultPersistenceMode; trimArrowBatchesToLimit?: boolean; fetchDisposition?: TDBSqlFetchDisposition; enforceResultPersistenceMode?: boolean; statementList?: TDBSqlStatement[]; persistResultManifest?: boolean; resultRetentionSeconds?: Int64; resultByteLimit?: Int64; resultDataFormat?: TDBSqlResultFormat; originatingClientIdentity?: string; preferSingleFileResult?: boolean; preferDriverOnlyUpload?: boolean; enforceEmbeddedSchemaCorrectness?: boolean; idempotencyToken?: string; });
|
|
732
|
+
constructor(args?: { sessionHandle: TSessionHandle; statement: string; confOverlay?: { [k: string]: string; }; runAsync?: boolean; getDirectResults?: TSparkGetDirectResults; queryTimeout?: Int64; canReadArrowResult?: boolean; canDownloadResult?: boolean; canDecompressLZ4Result?: boolean; maxBytesPerFile?: Int64; useArrowNativeTypes?: TSparkArrowTypes; resultRowLimit?: Int64; parameters?: TSparkParameter[]; maxBytesPerBatch?: Int64; statementConf?: TStatementConf; operationId?: THandleIdentifier; sessionConf?: TDBSqlSessionConf; rejectHighCostQueries?: boolean; estimatedCost?: number; executionVersion?: number; requestValidation?: Buffer; resultPersistenceMode?: TResultPersistenceMode; trimArrowBatchesToLimit?: boolean; fetchDisposition?: TDBSqlFetchDisposition; enforceResultPersistenceMode?: boolean; statementList?: TDBSqlStatement[]; persistResultManifest?: boolean; resultRetentionSeconds?: Int64; resultByteLimit?: Int64; resultDataFormat?: TDBSqlResultFormat; originatingClientIdentity?: string; preferSingleFileResult?: boolean; preferDriverOnlyUpload?: boolean; enforceEmbeddedSchemaCorrectness?: boolean; idempotencyToken?: string; throwErrorOnByteLimitTruncation?: boolean; });
|
|
726
733
|
}
|
|
727
734
|
|
|
728
735
|
declare class TDBSqlStatement {
|
|
@@ -1004,8 +1011,9 @@ declare class TCancelOperationResp {
|
|
|
1004
1011
|
|
|
1005
1012
|
declare class TCloseOperationReq {
|
|
1006
1013
|
public operationHandle: TOperationHandle;
|
|
1014
|
+
public closeReason?: TDBSqlCloseOperationReason;
|
|
1007
1015
|
|
|
1008
|
-
constructor(args?: { operationHandle: TOperationHandle; });
|
|
1016
|
+
constructor(args?: { operationHandle: TOperationHandle; closeReason?: TDBSqlCloseOperationReason; });
|
|
1009
1017
|
}
|
|
1010
1018
|
|
|
1011
1019
|
declare class TCloseOperationResp {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//
|
|
2
|
-
// Autogenerated by Thrift Compiler (0.
|
|
2
|
+
// Autogenerated by Thrift Compiler (0.19.0)
|
|
3
3
|
//
|
|
4
4
|
// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
|
|
5
5
|
//
|
|
@@ -50,7 +50,9 @@ ttypes.TProtocolVersion = {
|
|
|
50
50
|
'42246' : 'SPARK_CLI_SERVICE_PROTOCOL_V6',
|
|
51
51
|
'SPARK_CLI_SERVICE_PROTOCOL_V6' : 42246,
|
|
52
52
|
'42247' : 'SPARK_CLI_SERVICE_PROTOCOL_V7',
|
|
53
|
-
'SPARK_CLI_SERVICE_PROTOCOL_V7' : 42247
|
|
53
|
+
'SPARK_CLI_SERVICE_PROTOCOL_V7' : 42247,
|
|
54
|
+
'42248' : 'SPARK_CLI_SERVICE_PROTOCOL_V8',
|
|
55
|
+
'SPARK_CLI_SERVICE_PROTOCOL_V8' : 42248
|
|
54
56
|
};
|
|
55
57
|
ttypes.TTypeId = {
|
|
56
58
|
'0' : 'BOOLEAN_TYPE',
|
|
@@ -292,6 +294,12 @@ ttypes.TResultPersistenceMode = {
|
|
|
292
294
|
'2' : 'ALL_RESULTS',
|
|
293
295
|
'ALL_RESULTS' : 2
|
|
294
296
|
};
|
|
297
|
+
ttypes.TDBSqlCloseOperationReason = {
|
|
298
|
+
'0' : 'NONE',
|
|
299
|
+
'NONE' : 0,
|
|
300
|
+
'1' : 'COMMAND_INACTIVITY_TIMEOUT',
|
|
301
|
+
'COMMAND_INACTIVITY_TIMEOUT' : 1
|
|
302
|
+
};
|
|
295
303
|
ttypes.TCacheLookupResult = {
|
|
296
304
|
'0' : 'CACHE_INELIGIBLE',
|
|
297
305
|
'CACHE_INELIGIBLE' : 0,
|
|
@@ -5781,6 +5789,7 @@ var TExecuteStatementReq = module.exports.TExecuteStatementReq = function(args)
|
|
|
5781
5789
|
this.preferDriverOnlyUpload = null;
|
|
5782
5790
|
this.enforceEmbeddedSchemaCorrectness = false;
|
|
5783
5791
|
this.idempotencyToken = null;
|
|
5792
|
+
this.throwErrorOnByteLimitTruncation = null;
|
|
5784
5793
|
if (args) {
|
|
5785
5794
|
if (args.sessionHandle !== undefined && args.sessionHandle !== null) {
|
|
5786
5795
|
this.sessionHandle = new ttypes.TSessionHandle(args.sessionHandle);
|
|
@@ -5891,6 +5900,9 @@ var TExecuteStatementReq = module.exports.TExecuteStatementReq = function(args)
|
|
|
5891
5900
|
if (args.idempotencyToken !== undefined && args.idempotencyToken !== null) {
|
|
5892
5901
|
this.idempotencyToken = args.idempotencyToken;
|
|
5893
5902
|
}
|
|
5903
|
+
if (args.throwErrorOnByteLimitTruncation !== undefined && args.throwErrorOnByteLimitTruncation !== null) {
|
|
5904
|
+
this.throwErrorOnByteLimitTruncation = args.throwErrorOnByteLimitTruncation;
|
|
5905
|
+
}
|
|
5894
5906
|
}
|
|
5895
5907
|
};
|
|
5896
5908
|
TExecuteStatementReq.prototype = {};
|
|
@@ -6184,6 +6196,13 @@ TExecuteStatementReq.prototype.read = function(input) {
|
|
|
6184
6196
|
input.skip(ftype);
|
|
6185
6197
|
}
|
|
6186
6198
|
break;
|
|
6199
|
+
case 3361:
|
|
6200
|
+
if (ftype == Thrift.Type.BOOL) {
|
|
6201
|
+
this.throwErrorOnByteLimitTruncation = input.readBool();
|
|
6202
|
+
} else {
|
|
6203
|
+
input.skip(ftype);
|
|
6204
|
+
}
|
|
6205
|
+
break;
|
|
6187
6206
|
default:
|
|
6188
6207
|
input.skip(ftype);
|
|
6189
6208
|
}
|
|
@@ -6392,6 +6411,11 @@ TExecuteStatementReq.prototype.write = function(output) {
|
|
|
6392
6411
|
output.writeString(this.idempotencyToken);
|
|
6393
6412
|
output.writeFieldEnd();
|
|
6394
6413
|
}
|
|
6414
|
+
if (this.throwErrorOnByteLimitTruncation !== null && this.throwErrorOnByteLimitTruncation !== undefined) {
|
|
6415
|
+
output.writeFieldBegin('throwErrorOnByteLimitTruncation', Thrift.Type.BOOL, 3361);
|
|
6416
|
+
output.writeBool(this.throwErrorOnByteLimitTruncation);
|
|
6417
|
+
output.writeFieldEnd();
|
|
6418
|
+
}
|
|
6395
6419
|
output.writeFieldStop();
|
|
6396
6420
|
output.writeStructEnd();
|
|
6397
6421
|
return;
|
|
@@ -9667,12 +9691,16 @@ TCancelOperationResp.prototype.write = function(output) {
|
|
|
9667
9691
|
|
|
9668
9692
|
var TCloseOperationReq = module.exports.TCloseOperationReq = function(args) {
|
|
9669
9693
|
this.operationHandle = null;
|
|
9694
|
+
this.closeReason = 0;
|
|
9670
9695
|
if (args) {
|
|
9671
9696
|
if (args.operationHandle !== undefined && args.operationHandle !== null) {
|
|
9672
9697
|
this.operationHandle = new ttypes.TOperationHandle(args.operationHandle);
|
|
9673
9698
|
} else {
|
|
9674
9699
|
throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.UNKNOWN, 'Required field operationHandle is unset!');
|
|
9675
9700
|
}
|
|
9701
|
+
if (args.closeReason !== undefined && args.closeReason !== null) {
|
|
9702
|
+
this.closeReason = args.closeReason;
|
|
9703
|
+
}
|
|
9676
9704
|
}
|
|
9677
9705
|
};
|
|
9678
9706
|
TCloseOperationReq.prototype = {};
|
|
@@ -9694,9 +9722,13 @@ TCloseOperationReq.prototype.read = function(input) {
|
|
|
9694
9722
|
input.skip(ftype);
|
|
9695
9723
|
}
|
|
9696
9724
|
break;
|
|
9697
|
-
case
|
|
9725
|
+
case 3329:
|
|
9726
|
+
if (ftype == Thrift.Type.I32) {
|
|
9727
|
+
this.closeReason = input.readI32();
|
|
9728
|
+
} else {
|
|
9698
9729
|
input.skip(ftype);
|
|
9699
|
-
|
|
9730
|
+
}
|
|
9731
|
+
break;
|
|
9700
9732
|
default:
|
|
9701
9733
|
input.skip(ftype);
|
|
9702
9734
|
}
|
|
@@ -9713,6 +9745,11 @@ TCloseOperationReq.prototype.write = function(output) {
|
|
|
9713
9745
|
this.operationHandle.write(output);
|
|
9714
9746
|
output.writeFieldEnd();
|
|
9715
9747
|
}
|
|
9748
|
+
if (this.closeReason !== null && this.closeReason !== undefined) {
|
|
9749
|
+
output.writeFieldBegin('closeReason', Thrift.Type.I32, 3329);
|
|
9750
|
+
output.writeI32(this.closeReason);
|
|
9751
|
+
output.writeFieldEnd();
|
|
9752
|
+
}
|
|
9716
9753
|
output.writeFieldStop();
|
|
9717
9754
|
output.writeStructEnd();
|
|
9718
9755
|
return;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { TOperationHandle, TCloseOperationResp } from '../../thrift/TCLIService_types';
|
|
2
|
-
import HiveDriver from '../hive/HiveDriver';
|
|
3
|
-
import Status from '../dto/Status';
|
|
4
|
-
export default class CompleteOperationHelper {
|
|
5
|
-
private readonly driver;
|
|
6
|
-
private readonly operationHandle;
|
|
7
|
-
private closeOperation?;
|
|
8
|
-
closed: boolean;
|
|
9
|
-
cancelled: boolean;
|
|
10
|
-
constructor(driver: HiveDriver, operationHandle: TOperationHandle, closeOperation?: TCloseOperationResp);
|
|
11
|
-
cancel(): Promise<Status>;
|
|
12
|
-
close(): Promise<Status>;
|
|
13
|
-
}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
const Status_1 = __importDefault(require("../dto/Status"));
|
|
16
|
-
class CompleteOperationHelper {
|
|
17
|
-
constructor(driver, operationHandle, closeOperation) {
|
|
18
|
-
this.closed = false;
|
|
19
|
-
this.cancelled = false;
|
|
20
|
-
this.driver = driver;
|
|
21
|
-
this.operationHandle = operationHandle;
|
|
22
|
-
this.closeOperation = closeOperation;
|
|
23
|
-
}
|
|
24
|
-
cancel() {
|
|
25
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
26
|
-
if (this.cancelled) {
|
|
27
|
-
return Status_1.default.success();
|
|
28
|
-
}
|
|
29
|
-
const response = yield this.driver.cancelOperation({
|
|
30
|
-
operationHandle: this.operationHandle,
|
|
31
|
-
});
|
|
32
|
-
Status_1.default.assert(response.status);
|
|
33
|
-
this.cancelled = true;
|
|
34
|
-
return new Status_1.default(response.status);
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
close() {
|
|
38
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
39
|
-
if (!this.closed && this.closeOperation) {
|
|
40
|
-
Status_1.default.assert(this.closeOperation.status);
|
|
41
|
-
this.closed = true;
|
|
42
|
-
}
|
|
43
|
-
if (this.closed) {
|
|
44
|
-
return Status_1.default.success();
|
|
45
|
-
}
|
|
46
|
-
const response = yield this.driver.closeOperation({
|
|
47
|
-
operationHandle: this.operationHandle,
|
|
48
|
-
});
|
|
49
|
-
Status_1.default.assert(response.status);
|
|
50
|
-
this.closed = true;
|
|
51
|
-
return new Status_1.default(response.status);
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
exports.default = CompleteOperationHelper;
|
|
56
|
-
//# sourceMappingURL=CompleteOperationHelper.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CompleteOperationHelper.js","sourceRoot":"","sources":["../../lib/DBSQLOperation/CompleteOperationHelper.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAEA,2DAAmC;AAEnC,MAAqB,uBAAuB;IAW1C,YAAY,MAAkB,EAAE,eAAiC,EAAE,cAAoC;QAJhG,WAAM,GA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@
|
|
|
1
|
-
import { TGetResultSetMetadataResp, TOperationHandle } from '../../thrift/TCLIService_types';
|
|
2
|
-
import HiveDriver from '../hive/HiveDriver';
|
|
3
|
-
import IOperationResult from '../result/IOperationResult';
|
|
4
|
-
export default class SchemaHelper {
|
|
5
|
-
private readonly driver;
|
|
6
|
-
private readonly operationHandle;
|
|
7
|
-
private metadata?;
|
|
8
|
-
private resultHandler?;
|
|
9
|
-
constructor(driver: HiveDriver, operationHandle: TOperationHandle, metadata?: TGetResultSetMetadataResp);
|
|
10
|
-
private fetchMetadata;
|
|
11
|
-
fetch(): Promise<import("../../thrift/TCLIService_types").TTableSchema>;
|
|
12
|
-
getResultHandler(): Promise<IOperationResult>;
|
|
13
|
-
}
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
const TCLIService_types_1 = require("../../thrift/TCLIService_types");
|
|
16
|
-
const Status_1 = __importDefault(require("../dto/Status"));
|
|
17
|
-
const JsonResult_1 = __importDefault(require("../result/JsonResult"));
|
|
18
|
-
const ArrowResult_1 = __importDefault(require("../result/ArrowResult"));
|
|
19
|
-
const CloudFetchResult_1 = __importDefault(require("../result/CloudFetchResult"));
|
|
20
|
-
const HiveDriverError_1 = __importDefault(require("../errors/HiveDriverError"));
|
|
21
|
-
const utils_1 = require("../utils");
|
|
22
|
-
class SchemaHelper {
|
|
23
|
-
constructor(driver, operationHandle, metadata) {
|
|
24
|
-
this.driver = driver;
|
|
25
|
-
this.operationHandle = operationHandle;
|
|
26
|
-
this.metadata = metadata;
|
|
27
|
-
}
|
|
28
|
-
fetchMetadata() {
|
|
29
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
30
|
-
if (!this.metadata) {
|
|
31
|
-
const metadata = yield this.driver.getResultSetMetadata({
|
|
32
|
-
operationHandle: this.operationHandle,
|
|
33
|
-
});
|
|
34
|
-
Status_1.default.assert(metadata.status);
|
|
35
|
-
this.metadata = metadata;
|
|
36
|
-
}
|
|
37
|
-
return this.metadata;
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
fetch() {
|
|
41
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
42
|
-
const metadata = yield this.fetchMetadata();
|
|
43
|
-
return (0, utils_1.definedOrError)(metadata.schema);
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
getResultHandler() {
|
|
47
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
48
|
-
const metadata = yield this.fetchMetadata();
|
|
49
|
-
const resultFormat = (0, utils_1.definedOrError)(metadata.resultFormat);
|
|
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
|
-
}
|
|
65
|
-
}
|
|
66
|
-
if (!this.resultHandler) {
|
|
67
|
-
throw new HiveDriverError_1.default(`Unsupported result format: ${TCLIService_types_1.TSparkRowSetType[resultFormat]}`);
|
|
68
|
-
}
|
|
69
|
-
return this.resultHandler;
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
exports.default = SchemaHelper;
|
|
74
|
-
//# sourceMappingURL=SchemaHelper.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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;QACrB,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;QACvC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;IAEa,aAAa;;YACzB,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE;gBAClB,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,oBAAoB,CAAC;oBACtD,eAAe,EAAE,IAAI,CAAC,eAAe;iBACtC,CAAC,CAAC;gBACH,gBAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;gBAC/B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;aAC1B;YAED,OAAO,IAAI,CAAC,QAAQ,CAAC;QACvB,CAAC;KAAA;IAEY,KAAK;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