@databricks/sql 1.11.0 → 1.13.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 +5 -0
- package/dist/DBSQLClient.js +34 -0
- package/dist/DBSQLClient.js.map +1 -1
- package/dist/DBSQLOperation.d.ts +1 -0
- package/dist/DBSQLOperation.js +23 -2
- package/dist/DBSQLOperation.js.map +1 -1
- package/dist/DBSQLSession.js +1 -1
- package/dist/DBSQLSession.js.map +1 -1
- package/dist/connection/auth/tokenProvider/CachedTokenProvider.d.ts +37 -0
- package/dist/connection/auth/tokenProvider/CachedTokenProvider.js +79 -0
- package/dist/connection/auth/tokenProvider/CachedTokenProvider.js.map +1 -0
- package/dist/connection/auth/tokenProvider/ExternalTokenProvider.d.ts +28 -0
- package/dist/connection/auth/tokenProvider/ExternalTokenProvider.js +37 -0
- package/dist/connection/auth/tokenProvider/ExternalTokenProvider.js.map +1 -0
- package/dist/connection/auth/tokenProvider/FederationProvider.d.ts +57 -0
- package/dist/connection/auth/tokenProvider/FederationProvider.js +218 -0
- package/dist/connection/auth/tokenProvider/FederationProvider.js.map +1 -0
- package/dist/connection/auth/tokenProvider/ITokenProvider.d.ts +17 -0
- package/dist/connection/auth/tokenProvider/ITokenProvider.js +3 -0
- package/dist/connection/auth/tokenProvider/ITokenProvider.js.map +1 -0
- package/dist/connection/auth/tokenProvider/StaticTokenProvider.d.ts +24 -0
- package/dist/connection/auth/tokenProvider/StaticTokenProvider.js +43 -0
- package/dist/connection/auth/tokenProvider/StaticTokenProvider.js.map +1 -0
- package/dist/connection/auth/tokenProvider/Token.d.ts +75 -0
- package/dist/connection/auth/tokenProvider/Token.js +120 -0
- package/dist/connection/auth/tokenProvider/Token.js.map +1 -0
- package/dist/connection/auth/tokenProvider/TokenProviderAuthenticator.d.ts +21 -0
- package/dist/connection/auth/tokenProvider/TokenProviderAuthenticator.js +38 -0
- package/dist/connection/auth/tokenProvider/TokenProviderAuthenticator.js.map +1 -0
- package/dist/connection/auth/tokenProvider/index.d.ts +8 -0
- package/dist/connection/auth/tokenProvider/index.js +23 -0
- package/dist/connection/auth/tokenProvider/index.js.map +1 -0
- package/dist/connection/auth/tokenProvider/utils.d.ts +24 -0
- package/dist/connection/auth/tokenProvider/utils.js +83 -0
- package/dist/connection/auth/tokenProvider/utils.js.map +1 -0
- package/dist/contracts/IClientContext.d.ts +9 -0
- package/dist/contracts/IDBSQLClient.d.ts +21 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -1
- package/dist/result/ArrowResultHandler.js +2 -2
- package/dist/result/ArrowResultHandler.js.map +1 -1
- package/dist/result/CloudFetchResultHandler.d.ts +1 -0
- package/dist/result/CloudFetchResultHandler.js +19 -2
- package/dist/result/CloudFetchResultHandler.js.map +1 -1
- package/dist/telemetry/ExceptionClassifier.d.ts +48 -0
- package/dist/telemetry/ExceptionClassifier.js +100 -0
- package/dist/telemetry/ExceptionClassifier.js.map +1 -0
- package/dist/telemetry/types.d.ts +176 -0
- package/dist/telemetry/types.js +42 -0
- package/dist/telemetry/types.js.map +1 -0
- package/dist/utils/lz4.d.ts +2 -2
- package/dist/utils/lz4.js +13 -2
- package/dist/utils/lz4.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isSameHost = exports.getJWTIssuer = exports.decodeJWT = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Decodes a JWT token without verifying the signature.
|
|
6
|
+
* This is safe because the server will validate the token anyway.
|
|
7
|
+
*
|
|
8
|
+
* @param token - The JWT token string
|
|
9
|
+
* @returns The decoded payload as a record, or null if decoding fails
|
|
10
|
+
*/
|
|
11
|
+
function decodeJWT(token) {
|
|
12
|
+
try {
|
|
13
|
+
const parts = token.split('.');
|
|
14
|
+
if (parts.length < 2) {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
const payload = Buffer.from(parts[1], 'base64').toString('utf8');
|
|
18
|
+
return JSON.parse(payload);
|
|
19
|
+
}
|
|
20
|
+
catch (_a) {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.decodeJWT = decodeJWT;
|
|
25
|
+
/**
|
|
26
|
+
* Extracts the issuer from a JWT token.
|
|
27
|
+
*
|
|
28
|
+
* @param token - The JWT token string
|
|
29
|
+
* @returns The issuer string, or null if not found
|
|
30
|
+
*/
|
|
31
|
+
function getJWTIssuer(token) {
|
|
32
|
+
const payload = decodeJWT(token);
|
|
33
|
+
if (!payload || typeof payload.iss !== 'string') {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
return payload.iss;
|
|
37
|
+
}
|
|
38
|
+
exports.getJWTIssuer = getJWTIssuer;
|
|
39
|
+
/**
|
|
40
|
+
* Extracts the hostname from a URL or hostname string.
|
|
41
|
+
* Handles both full URLs and bare hostnames.
|
|
42
|
+
*
|
|
43
|
+
* @param urlOrHostname - A URL or hostname string
|
|
44
|
+
* @returns The extracted hostname
|
|
45
|
+
*/
|
|
46
|
+
function extractHostname(urlOrHostname) {
|
|
47
|
+
// If it looks like a URL, parse it
|
|
48
|
+
if (urlOrHostname.includes('://')) {
|
|
49
|
+
const url = new URL(urlOrHostname);
|
|
50
|
+
return url.hostname;
|
|
51
|
+
}
|
|
52
|
+
// Handle hostname with port (e.g., "databricks.com:443")
|
|
53
|
+
const colonIndex = urlOrHostname.indexOf(':');
|
|
54
|
+
if (colonIndex !== -1) {
|
|
55
|
+
return urlOrHostname.substring(0, colonIndex);
|
|
56
|
+
}
|
|
57
|
+
// Bare hostname
|
|
58
|
+
return urlOrHostname;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Compares two host URLs, ignoring ports.
|
|
62
|
+
* Treats "databricks.com" and "databricks.com:443" as equivalent.
|
|
63
|
+
*
|
|
64
|
+
* @param url1 - First URL or hostname
|
|
65
|
+
* @param url2 - Second URL or hostname
|
|
66
|
+
* @returns true if the hosts are the same
|
|
67
|
+
*/
|
|
68
|
+
function isSameHost(url1, url2) {
|
|
69
|
+
try {
|
|
70
|
+
const host1 = extractHostname(url1);
|
|
71
|
+
const host2 = extractHostname(url2);
|
|
72
|
+
// Empty hostnames are not valid
|
|
73
|
+
if (!host1 || !host2) {
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
return host1.toLowerCase() === host2.toLowerCase();
|
|
77
|
+
}
|
|
78
|
+
catch (_a) {
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
exports.isSameHost = isSameHost;
|
|
83
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../lib/connection/auth/tokenProvider/utils.ts"],"names":[],"mappings":";;;AAAA;;;;;;GAMG;AACH,SAAgB,SAAS,CAAC,KAAa;IACrC,IAAI;QACF,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC/B,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE;YACpB,OAAO,IAAI,CAAC;SACb;QACD,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QACjE,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;KAC5B;IAAC,WAAM;QACN,OAAO,IAAI,CAAC;KACb;AACH,CAAC;AAXD,8BAWC;AAED;;;;;GAKG;AACH,SAAgB,YAAY,CAAC,KAAa;IACxC,MAAM,OAAO,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC;IACjC,IAAI,CAAC,OAAO,IAAI,OAAO,OAAO,CAAC,GAAG,KAAK,QAAQ,EAAE;QAC/C,OAAO,IAAI,CAAC;KACb;IACD,OAAO,OAAO,CAAC,GAAG,CAAC;AACrB,CAAC;AAND,oCAMC;AAED;;;;;;GAMG;AACH,SAAS,eAAe,CAAC,aAAqB;IAC5C,mCAAmC;IACnC,IAAI,aAAa,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE;QACjC,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,aAAa,CAAC,CAAC;QACnC,OAAO,GAAG,CAAC,QAAQ,CAAC;KACrB;IAED,yDAAyD;IACzD,MAAM,UAAU,GAAG,aAAa,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAC9C,IAAI,UAAU,KAAK,CAAC,CAAC,EAAE;QACrB,OAAO,aAAa,CAAC,SAAS,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC;KAC/C;IAED,gBAAgB;IAChB,OAAO,aAAa,CAAC;AACvB,CAAC;AAED;;;;;;;GAOG;AACH,SAAgB,UAAU,CAAC,IAAY,EAAE,IAAY;IACnD,IAAI;QACF,MAAM,KAAK,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC;QACpC,MAAM,KAAK,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC;QACpC,gCAAgC;QAChC,IAAI,CAAC,KAAK,IAAI,CAAC,KAAK,EAAE;YACpB,OAAO,KAAK,CAAC;SACd;QACD,OAAO,KAAK,CAAC,WAAW,EAAE,KAAK,KAAK,CAAC,WAAW,EAAE,CAAC;KACpD;IAAC,WAAM;QACN,OAAO,KAAK,CAAC;KACd;AACH,CAAC;AAZD,gCAYC"}
|
|
@@ -14,7 +14,16 @@ export interface ClientConfig {
|
|
|
14
14
|
retryDelayMax: number;
|
|
15
15
|
useCloudFetch: boolean;
|
|
16
16
|
cloudFetchConcurrentDownloads: number;
|
|
17
|
+
cloudFetchSpeedThresholdMBps: number;
|
|
17
18
|
useLZ4Compression: boolean;
|
|
19
|
+
enableMetricViewMetadata?: boolean;
|
|
20
|
+
telemetryEnabled?: boolean;
|
|
21
|
+
telemetryBatchSize?: number;
|
|
22
|
+
telemetryFlushIntervalMs?: number;
|
|
23
|
+
telemetryMaxRetries?: number;
|
|
24
|
+
telemetryAuthenticatedExport?: boolean;
|
|
25
|
+
telemetryCircuitBreakerThreshold?: number;
|
|
26
|
+
telemetryCircuitBreakerTimeout?: number;
|
|
18
27
|
}
|
|
19
28
|
export default interface IClientContext {
|
|
20
29
|
getConfig(): ClientConfig;
|
|
@@ -3,6 +3,8 @@ import IDBSQLSession from './IDBSQLSession';
|
|
|
3
3
|
import IAuthentication from '../connection/contracts/IAuthentication';
|
|
4
4
|
import { ProxyOptions } from '../connection/contracts/IConnectionOptions';
|
|
5
5
|
import OAuthPersistence from '../connection/auth/DatabricksOAuth/OAuthPersistence';
|
|
6
|
+
import ITokenProvider from '../connection/auth/tokenProvider/ITokenProvider';
|
|
7
|
+
import { TokenCallback } from '../connection/auth/tokenProvider/ExternalTokenProvider';
|
|
6
8
|
export interface ClientOptions {
|
|
7
9
|
logger?: IDBSQLLogger;
|
|
8
10
|
}
|
|
@@ -19,6 +21,21 @@ type AuthOptions = {
|
|
|
19
21
|
} | {
|
|
20
22
|
authType: 'custom';
|
|
21
23
|
provider: IAuthentication;
|
|
24
|
+
} | {
|
|
25
|
+
authType: 'token-provider';
|
|
26
|
+
tokenProvider: ITokenProvider;
|
|
27
|
+
enableTokenFederation?: boolean;
|
|
28
|
+
federationClientId?: string;
|
|
29
|
+
} | {
|
|
30
|
+
authType: 'external-token';
|
|
31
|
+
getToken: TokenCallback;
|
|
32
|
+
enableTokenFederation?: boolean;
|
|
33
|
+
federationClientId?: string;
|
|
34
|
+
} | {
|
|
35
|
+
authType: 'static-token';
|
|
36
|
+
staticToken: string;
|
|
37
|
+
enableTokenFederation?: boolean;
|
|
38
|
+
federationClientId?: string;
|
|
22
39
|
};
|
|
23
40
|
export type ConnectionOptions = {
|
|
24
41
|
host: string;
|
|
@@ -27,10 +44,14 @@ export type ConnectionOptions = {
|
|
|
27
44
|
userAgentEntry?: string;
|
|
28
45
|
socketTimeout?: number;
|
|
29
46
|
proxy?: ProxyOptions;
|
|
47
|
+
enableMetricViewMetadata?: boolean;
|
|
30
48
|
} & AuthOptions;
|
|
31
49
|
export interface OpenSessionRequest {
|
|
32
50
|
initialCatalog?: string;
|
|
33
51
|
initialSchema?: string;
|
|
52
|
+
configuration?: {
|
|
53
|
+
[key: string]: string;
|
|
54
|
+
};
|
|
34
55
|
}
|
|
35
56
|
export default interface IDBSQLClient {
|
|
36
57
|
connect(options: ConnectionOptions): Promise<IDBSQLClient>;
|
package/dist/index.d.ts
CHANGED
|
@@ -7,11 +7,18 @@ import DBSQLSession from './DBSQLSession';
|
|
|
7
7
|
import { DBSQLParameter, DBSQLParameterType } from './DBSQLParameter';
|
|
8
8
|
import DBSQLLogger from './DBSQLLogger';
|
|
9
9
|
import PlainHttpAuthentication from './connection/auth/PlainHttpAuthentication';
|
|
10
|
+
import { Token, StaticTokenProvider, ExternalTokenProvider, CachedTokenProvider, FederationProvider } from './connection/auth/tokenProvider';
|
|
10
11
|
import HttpConnection from './connection/connections/HttpConnection';
|
|
11
12
|
import { formatProgress } from './utils';
|
|
12
13
|
import { LogLevel } from './contracts/IDBSQLLogger';
|
|
14
|
+
export type { default as ITokenProvider } from './connection/auth/tokenProvider/ITokenProvider';
|
|
13
15
|
export declare const auth: {
|
|
14
16
|
PlainHttpAuthentication: typeof PlainHttpAuthentication;
|
|
17
|
+
Token: typeof Token;
|
|
18
|
+
StaticTokenProvider: typeof StaticTokenProvider;
|
|
19
|
+
ExternalTokenProvider: typeof ExternalTokenProvider;
|
|
20
|
+
CachedTokenProvider: typeof CachedTokenProvider;
|
|
21
|
+
FederationProvider: typeof FederationProvider;
|
|
15
22
|
};
|
|
16
23
|
declare const TException: typeof Thrift.TException, TApplicationException: typeof Thrift.TApplicationException, TApplicationExceptionType: typeof Thrift.TApplicationExceptionType, TProtocolException: typeof Thrift.TProtocolException, TProtocolExceptionType: typeof Thrift.TProtocolExceptionType;
|
|
17
24
|
export { TException, TApplicationException, TApplicationExceptionType, TProtocolException, TProtocolExceptionType };
|
package/dist/index.js
CHANGED
|
@@ -19,12 +19,19 @@ Object.defineProperty(exports, "DBSQLParameterType", { enumerable: true, get: fu
|
|
|
19
19
|
const DBSQLLogger_1 = __importDefault(require("./DBSQLLogger"));
|
|
20
20
|
exports.DBSQLLogger = DBSQLLogger_1.default;
|
|
21
21
|
const PlainHttpAuthentication_1 = __importDefault(require("./connection/auth/PlainHttpAuthentication"));
|
|
22
|
+
const tokenProvider_1 = require("./connection/auth/tokenProvider");
|
|
22
23
|
const HttpConnection_1 = __importDefault(require("./connection/connections/HttpConnection"));
|
|
23
24
|
const utils_1 = require("./utils");
|
|
24
25
|
const IDBSQLLogger_1 = require("./contracts/IDBSQLLogger");
|
|
25
26
|
Object.defineProperty(exports, "LogLevel", { enumerable: true, get: function () { return IDBSQLLogger_1.LogLevel; } });
|
|
26
27
|
exports.auth = {
|
|
27
28
|
PlainHttpAuthentication: PlainHttpAuthentication_1.default,
|
|
29
|
+
// Token provider classes for custom authentication
|
|
30
|
+
Token: tokenProvider_1.Token,
|
|
31
|
+
StaticTokenProvider: tokenProvider_1.StaticTokenProvider,
|
|
32
|
+
ExternalTokenProvider: tokenProvider_1.ExternalTokenProvider,
|
|
33
|
+
CachedTokenProvider: tokenProvider_1.CachedTokenProvider,
|
|
34
|
+
FederationProvider: tokenProvider_1.FederationProvider,
|
|
28
35
|
};
|
|
29
36
|
const { TException, TApplicationException, TApplicationExceptionType, TProtocolException, TProtocolExceptionType } = thrift_1.Thrift;
|
|
30
37
|
exports.TException = TException;
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":";;;;;;AAAA,gEAAgE;AAChE,uBAAqB;AAErB,mCAAgC;AAChC,wEAAgD;AAChD,oFAA4D;AAC5D,gEAAwC;AA+
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":";;;;;;AAAA,gEAAgE;AAChE,uBAAqB;AAErB,mCAAgC;AAChC,wEAAgD;AAChD,oFAA4D;AAC5D,gEAAwC;AA+C/B,sBA/CF,qBAAW,CA+CE;AA9CpB,kEAA0C;AA8CpB,uBA9Cf,sBAAY,CA8Ce;AA7ClC,qDAAsE;AA6ClC,+FA7C3B,+BAAc,OA6C2B;AAAE,mGA7C3B,mCAAkB,OA6C2B;AA5CtE,gEAAwC;AA4CgC,sBA5CjE,qBAAW,CA4CiE;AA3CnF,wGAAgF;AAChF,mEAMyC;AACzC,6FAAqE;AACrE,mCAAyC;AACzC,2DAAoD;AAiCiC,yFAjC5E,uBAAQ,OAiC4E;AA5BhF,QAAA,IAAI,GAAG;IAClB,uBAAuB,EAAvB,iCAAuB;IACvB,mDAAmD;IACnD,KAAK,EAAL,qBAAK;IACL,mBAAmB,EAAnB,mCAAmB;IACnB,qBAAqB,EAArB,qCAAqB;IACrB,mBAAmB,EAAnB,mCAAmB;IACnB,kBAAkB,EAAlB,kCAAkB;CACnB,CAAC;AAEF,MAAM,EAAE,UAAU,EAAE,qBAAqB,EAAE,yBAAyB,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,GAChH,eAAM,CAAC;AAEA,gCAAU;AAAE,sDAAqB;AAAE,8DAAyB;AAAE,gDAAkB;AAAE,wDAAsB;AAEpG,QAAA,WAAW,GAAG;IACzB,cAAc,EAAd,wBAAc;CACf,CAAC;AAEW,QAAA,MAAM,GAAG;IACpB,WAAW,EAAX,qBAAW;IACX,iBAAiB,EAAjB,2BAAiB;CAClB,CAAC;AAEW,QAAA,KAAK,GAAG;IACnB,cAAc,EAAd,sBAAc;CACf,CAAC"}
|
|
@@ -14,7 +14,7 @@ class ArrowResultHandler {
|
|
|
14
14
|
// so it's possible to infer Arrow schema from Hive schema ignoring `useArrowNativeTypes` option
|
|
15
15
|
this.arrowSchema = arrowSchema !== null && arrowSchema !== void 0 ? arrowSchema : (0, utils_1.hiveSchemaToArrowSchema)(schema);
|
|
16
16
|
this.isLZ4Compressed = lz4Compressed !== null && lz4Compressed !== void 0 ? lz4Compressed : false;
|
|
17
|
-
if (this.isLZ4Compressed && !utils_2.LZ4) {
|
|
17
|
+
if (this.isLZ4Compressed && !(0, utils_2.LZ4)()) {
|
|
18
18
|
throw new HiveDriverError_1.default('Cannot handle LZ4 compressed result: module `lz4` not installed');
|
|
19
19
|
}
|
|
20
20
|
}
|
|
@@ -37,7 +37,7 @@ class ArrowResultHandler {
|
|
|
37
37
|
let totalRowCount = 0;
|
|
38
38
|
(_a = rowSet === null || rowSet === void 0 ? void 0 : rowSet.arrowBatches) === null || _a === void 0 ? void 0 : _a.forEach(({ batch, rowCount }) => {
|
|
39
39
|
if (batch) {
|
|
40
|
-
batches.push(this.isLZ4Compressed ? utils_2.LZ4.decode(batch) : batch);
|
|
40
|
+
batches.push(this.isLZ4Compressed ? (0, utils_2.LZ4)().decode(batch) : batch);
|
|
41
41
|
totalRowCount += rowCount.toNumber(true);
|
|
42
42
|
}
|
|
43
43
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ArrowResultHandler.js","sourceRoot":"","sources":["../../lib/result/ArrowResultHandler.ts"],"names":[],"mappings":";;;;;AACA,gFAAwD;AAGxD,mCAA8D;AAC9D,oCAA+B;AAE/B,MAAqB,kBAAkB;IASrC,YACE,OAAuB,EACvB,MAA6C,EAC7C,EAAE,MAAM,EAAE,WAAW,EAAE,aAAa,EAA6B;QAEjE,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,kGAAkG;QAClG,gGAAgG;QAChG,IAAI,CAAC,WAAW,GAAG,WAAW,aAAX,WAAW,cAAX,WAAW,GAAI,IAAA,+BAAuB,EAAC,MAAM,CAAC,CAAC;QAClE,IAAI,CAAC,eAAe,GAAG,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C,IAAI,aAAa,GAAG,CAAC,CAAC;QACtB,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,YAAY,0CAAE,OAAO,CAAC,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,EAAE;YACpD,IAAI,KAAK,EAAE;gBACT,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,IAAA,WAAG,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;gBAClE,aAAa,IAAI,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;aAC1C;QACH,CAAC,CAAC,CAAC;QAEH,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE;YACxB,OAAO;gBACL,OAAO,EAAE,EAAE;gBACX,QAAQ,EAAE,CAAC;aACZ,CAAC;SACH;QAED,OAAO;YACL,OAAO,EAAE,CAAC,IAAI,CAAC,WAAW,EAAE,GAAG,OAAO,CAAC;YACvC,QAAQ,EAAE,aAAa;SACxB,CAAC;IACJ,CAAC;CACF;AAhED,qCAgEC"}
|
|
@@ -11,6 +11,7 @@ export default class CloudFetchResultHandler implements IResultsProvider<ArrowBa
|
|
|
11
11
|
constructor(context: IClientContext, source: IResultsProvider<TRowSet | undefined>, { lz4Compressed }: TGetResultSetMetadataResp);
|
|
12
12
|
hasMore(): Promise<boolean>;
|
|
13
13
|
fetchNext(options: ResultsProviderFetchNextOptions): Promise<ArrowBatch>;
|
|
14
|
+
private logDownloadMetrics;
|
|
14
15
|
private downloadLink;
|
|
15
16
|
private fetch;
|
|
16
17
|
}
|
|
@@ -29,6 +29,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
29
29
|
const node_fetch_1 = __importStar(require("node-fetch"));
|
|
30
30
|
const HiveDriverError_1 = __importDefault(require("../errors/HiveDriverError"));
|
|
31
31
|
const utils_1 = require("../utils");
|
|
32
|
+
const IDBSQLLogger_1 = require("../contracts/IDBSQLLogger");
|
|
32
33
|
class CloudFetchResultHandler {
|
|
33
34
|
constructor(context, source, { lz4Compressed }) {
|
|
34
35
|
this.pendingLinks = [];
|
|
@@ -36,7 +37,7 @@ class CloudFetchResultHandler {
|
|
|
36
37
|
this.context = context;
|
|
37
38
|
this.source = source;
|
|
38
39
|
this.isLZ4Compressed = lz4Compressed !== null && lz4Compressed !== void 0 ? lz4Compressed : false;
|
|
39
|
-
if (this.isLZ4Compressed && !utils_1.LZ4) {
|
|
40
|
+
if (this.isLZ4Compressed && !(0, utils_1.LZ4)()) {
|
|
40
41
|
throw new HiveDriverError_1.default('Cannot handle LZ4 compressed result: module `lz4` not installed');
|
|
41
42
|
}
|
|
42
43
|
}
|
|
@@ -67,19 +68,35 @@ class CloudFetchResultHandler {
|
|
|
67
68
|
};
|
|
68
69
|
}
|
|
69
70
|
if (this.isLZ4Compressed) {
|
|
70
|
-
batch.batches = batch.batches.map((buffer) => utils_1.LZ4.decode(buffer));
|
|
71
|
+
batch.batches = batch.batches.map((buffer) => (0, utils_1.LZ4)().decode(buffer));
|
|
71
72
|
}
|
|
72
73
|
return batch;
|
|
73
74
|
}
|
|
75
|
+
logDownloadMetrics(url, fileSizeBytes, downloadTimeMs) {
|
|
76
|
+
const speedMBps = fileSizeBytes / (1024 * 1024) / (downloadTimeMs / 1000);
|
|
77
|
+
const cleanUrl = url.split('?')[0];
|
|
78
|
+
this.context
|
|
79
|
+
.getLogger()
|
|
80
|
+
.log(IDBSQLLogger_1.LogLevel.info, `Result File Download speed from cloud storage ${cleanUrl}: ${speedMBps.toFixed(4)} MB/s`);
|
|
81
|
+
const speedThresholdMBps = this.context.getConfig().cloudFetchSpeedThresholdMBps;
|
|
82
|
+
if (speedMBps < speedThresholdMBps) {
|
|
83
|
+
this.context
|
|
84
|
+
.getLogger()
|
|
85
|
+
.log(IDBSQLLogger_1.LogLevel.warn, `Results download is slower than threshold speed of ${speedThresholdMBps.toFixed(4)} MB/s: ${speedMBps.toFixed(4)} MB/s`);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
74
88
|
async downloadLink(link) {
|
|
75
89
|
if (Date.now() >= link.expiryTime.toNumber()) {
|
|
76
90
|
throw new Error('CloudFetch link has expired');
|
|
77
91
|
}
|
|
92
|
+
const startTime = Date.now();
|
|
78
93
|
const response = await this.fetch(link.fileLink, { headers: link.httpHeaders });
|
|
79
94
|
if (!response.ok) {
|
|
80
95
|
throw new Error(`CloudFetch HTTP error ${response.status} ${response.statusText}`);
|
|
81
96
|
}
|
|
82
97
|
const result = await response.arrayBuffer();
|
|
98
|
+
const downloadTimeMs = Date.now() - startTime;
|
|
99
|
+
this.logDownloadMetrics(link.fileLink, result.byteLength, downloadTimeMs);
|
|
83
100
|
return {
|
|
84
101
|
batches: [Buffer.from(result)],
|
|
85
102
|
rowCount: link.rowCount.toNumber(true),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CloudFetchResultHandler.js","sourceRoot":"","sources":["../../lib/result/CloudFetchResultHandler.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yDAAsE;AAEtE,gFAAwD;AAIxD,oCAA+B;
|
|
1
|
+
{"version":3,"file":"CloudFetchResultHandler.js","sourceRoot":"","sources":["../../lib/result/CloudFetchResultHandler.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yDAAsE;AAEtE,gFAAwD;AAIxD,oCAA+B;AAC/B,4DAAqD;AAErD,MAAqB,uBAAuB;IAW1C,YACE,OAAuB,EACvB,MAA6C,EAC7C,EAAE,aAAa,EAA6B;QAPtC,iBAAY,GAAiC,EAAE,CAAC;QAEhD,kBAAa,GAA+B,EAAE,CAAC;QAOrD,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,eAAe,GAAG,aAAa,aAAb,aAAa,cAAb,aAAa,GAAI,KAAK,CAAC;QAE9C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,OAAO,IAAA,oBAAK,EAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC;QACpE,CAAC,CAAC,CAAC;QACH,OAAO,MAAM,CAAC,QAAQ,CAAC;IACzB,CAAC;CACF;AArHD,0CAqHC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Databricks Contributors
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* Classifies exceptions as terminal (unrecoverable) vs retryable.
|
|
18
|
+
*
|
|
19
|
+
* Terminal exceptions should be flushed immediately to telemetry,
|
|
20
|
+
* while retryable exceptions are buffered until statement completion.
|
|
21
|
+
*
|
|
22
|
+
* This follows the JDBC driver pattern of smart exception flushing
|
|
23
|
+
* to optimize telemetry export efficiency while ensuring critical
|
|
24
|
+
* errors are reported immediately.
|
|
25
|
+
*/
|
|
26
|
+
export default class ExceptionClassifier {
|
|
27
|
+
/**
|
|
28
|
+
* Determines if an exception is terminal (non-retryable).
|
|
29
|
+
*
|
|
30
|
+
* Terminal exceptions indicate unrecoverable failures that should
|
|
31
|
+
* be reported immediately, such as authentication failures, invalid
|
|
32
|
+
* requests, or resource not found errors.
|
|
33
|
+
*
|
|
34
|
+
* @param error - The error to classify
|
|
35
|
+
* @returns true if the error is terminal, false otherwise
|
|
36
|
+
*/
|
|
37
|
+
static isTerminal(error: Error): boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Determines if an exception is retryable.
|
|
40
|
+
*
|
|
41
|
+
* Retryable exceptions indicate transient failures that may succeed
|
|
42
|
+
* on retry, such as rate limiting, server errors, or network timeouts.
|
|
43
|
+
*
|
|
44
|
+
* @param error - The error to classify
|
|
45
|
+
* @returns true if the error is retryable, false otherwise
|
|
46
|
+
*/
|
|
47
|
+
static isRetryable(error: Error): boolean;
|
|
48
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) 2025 Databricks Contributors
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
18
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
19
|
+
};
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
const AuthenticationError_1 = __importDefault(require("../errors/AuthenticationError"));
|
|
22
|
+
const RetryError_1 = __importDefault(require("../errors/RetryError"));
|
|
23
|
+
/**
|
|
24
|
+
* Classifies exceptions as terminal (unrecoverable) vs retryable.
|
|
25
|
+
*
|
|
26
|
+
* Terminal exceptions should be flushed immediately to telemetry,
|
|
27
|
+
* while retryable exceptions are buffered until statement completion.
|
|
28
|
+
*
|
|
29
|
+
* This follows the JDBC driver pattern of smart exception flushing
|
|
30
|
+
* to optimize telemetry export efficiency while ensuring critical
|
|
31
|
+
* errors are reported immediately.
|
|
32
|
+
*/
|
|
33
|
+
class ExceptionClassifier {
|
|
34
|
+
/**
|
|
35
|
+
* Determines if an exception is terminal (non-retryable).
|
|
36
|
+
*
|
|
37
|
+
* Terminal exceptions indicate unrecoverable failures that should
|
|
38
|
+
* be reported immediately, such as authentication failures, invalid
|
|
39
|
+
* requests, or resource not found errors.
|
|
40
|
+
*
|
|
41
|
+
* @param error - The error to classify
|
|
42
|
+
* @returns true if the error is terminal, false otherwise
|
|
43
|
+
*/
|
|
44
|
+
static isTerminal(error) {
|
|
45
|
+
var _a;
|
|
46
|
+
// Check for AuthenticationError (terminal)
|
|
47
|
+
if (error instanceof AuthenticationError_1.default) {
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
|
+
// Check for HTTP status codes in error properties
|
|
51
|
+
// Supporting both 'statusCode' and 'status' property names for flexibility
|
|
52
|
+
const statusCode = (_a = error.statusCode) !== null && _a !== void 0 ? _a : error.status;
|
|
53
|
+
if (typeof statusCode === 'number') {
|
|
54
|
+
// Terminal HTTP status codes:
|
|
55
|
+
// 400 - Bad Request (invalid request format)
|
|
56
|
+
// 401 - Unauthorized (authentication required)
|
|
57
|
+
// 403 - Forbidden (permission denied)
|
|
58
|
+
// 404 - Not Found (resource does not exist)
|
|
59
|
+
return statusCode === 400 || statusCode === 401 || statusCode === 403 || statusCode === 404;
|
|
60
|
+
}
|
|
61
|
+
// Default to false for unknown error types
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Determines if an exception is retryable.
|
|
66
|
+
*
|
|
67
|
+
* Retryable exceptions indicate transient failures that may succeed
|
|
68
|
+
* on retry, such as rate limiting, server errors, or network timeouts.
|
|
69
|
+
*
|
|
70
|
+
* @param error - The error to classify
|
|
71
|
+
* @returns true if the error is retryable, false otherwise
|
|
72
|
+
*/
|
|
73
|
+
static isRetryable(error) {
|
|
74
|
+
var _a;
|
|
75
|
+
// Check for RetryError (explicitly retryable)
|
|
76
|
+
if (error instanceof RetryError_1.default) {
|
|
77
|
+
return true;
|
|
78
|
+
}
|
|
79
|
+
// Check for network timeout errors
|
|
80
|
+
if (error.name === 'TimeoutError' || error.message.includes('timeout')) {
|
|
81
|
+
return true;
|
|
82
|
+
}
|
|
83
|
+
// Check for HTTP status codes in error properties
|
|
84
|
+
// Supporting both 'statusCode' and 'status' property names for flexibility
|
|
85
|
+
const statusCode = (_a = error.statusCode) !== null && _a !== void 0 ? _a : error.status;
|
|
86
|
+
if (typeof statusCode === 'number') {
|
|
87
|
+
// Retryable HTTP status codes:
|
|
88
|
+
// 429 - Too Many Requests (rate limiting)
|
|
89
|
+
// 500 - Internal Server Error
|
|
90
|
+
// 502 - Bad Gateway
|
|
91
|
+
// 503 - Service Unavailable
|
|
92
|
+
// 504 - Gateway Timeout
|
|
93
|
+
return statusCode === 429 || statusCode === 500 || statusCode === 502 || statusCode === 503 || statusCode === 504;
|
|
94
|
+
}
|
|
95
|
+
// Default to false for unknown error types
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
exports.default = ExceptionClassifier;
|
|
100
|
+
//# sourceMappingURL=ExceptionClassifier.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExceptionClassifier.js","sourceRoot":"","sources":["../../lib/telemetry/ExceptionClassifier.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;;;AAEH,wFAAgE;AAChE,sEAA8C;AAE9C;;;;;;;;;GASG;AACH,MAAqB,mBAAmB;IACtC;;;;;;;;;OASG;IACH,MAAM,CAAC,UAAU,CAAC,KAAY;;QAC5B,2CAA2C;QAC3C,IAAI,KAAK,YAAY,6BAAmB,EAAE;YACxC,OAAO,IAAI,CAAC;SACb;QAED,kDAAkD;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under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* Event types emitted by the telemetry system
|
|
18
|
+
*/
|
|
19
|
+
export declare enum TelemetryEventType {
|
|
20
|
+
CONNECTION_OPEN = "connection.open",
|
|
21
|
+
STATEMENT_START = "statement.start",
|
|
22
|
+
STATEMENT_COMPLETE = "statement.complete",
|
|
23
|
+
CLOUDFETCH_CHUNK = "cloudfetch.chunk",
|
|
24
|
+
ERROR = "error"
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Configuration for telemetry components
|
|
28
|
+
*/
|
|
29
|
+
export interface TelemetryConfiguration {
|
|
30
|
+
/** Whether telemetry is enabled */
|
|
31
|
+
enabled?: boolean;
|
|
32
|
+
/** Maximum number of metrics to batch before flushing */
|
|
33
|
+
batchSize?: number;
|
|
34
|
+
/** Interval in milliseconds to flush metrics */
|
|
35
|
+
flushIntervalMs?: number;
|
|
36
|
+
/** Maximum retry attempts for export */
|
|
37
|
+
maxRetries?: number;
|
|
38
|
+
/** Whether to use authenticated export endpoint */
|
|
39
|
+
authenticatedExport?: boolean;
|
|
40
|
+
/** Circuit breaker failure threshold */
|
|
41
|
+
circuitBreakerThreshold?: number;
|
|
42
|
+
/** Circuit breaker timeout in milliseconds */
|
|
43
|
+
circuitBreakerTimeout?: number;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Default telemetry configuration values
|
|
47
|
+
*/
|
|
48
|
+
export declare const DEFAULT_TELEMETRY_CONFIG: Required<TelemetryConfiguration>;
|
|
49
|
+
/**
|
|
50
|
+
* Runtime telemetry event emitted by the driver
|
|
51
|
+
*/
|
|
52
|
+
export interface TelemetryEvent {
|
|
53
|
+
/** Type of the event */
|
|
54
|
+
eventType: TelemetryEventType | string;
|
|
55
|
+
/** Timestamp when the event occurred (milliseconds since epoch) */
|
|
56
|
+
timestamp: number;
|
|
57
|
+
/** Session ID for correlation */
|
|
58
|
+
sessionId?: string;
|
|
59
|
+
/** Statement ID for correlation */
|
|
60
|
+
statementId?: string;
|
|
61
|
+
/** Workspace ID */
|
|
62
|
+
workspaceId?: string;
|
|
63
|
+
/** Driver configuration */
|
|
64
|
+
driverConfig?: DriverConfiguration;
|
|
65
|
+
/** Type of operation (SELECT, INSERT, etc.) */
|
|
66
|
+
operationType?: string;
|
|
67
|
+
/** Execution latency in milliseconds */
|
|
68
|
+
latencyMs?: number;
|
|
69
|
+
/** Result format (inline, cloudfetch, arrow) */
|
|
70
|
+
resultFormat?: string;
|
|
71
|
+
/** Number of result chunks */
|
|
72
|
+
chunkCount?: number;
|
|
73
|
+
/** Total bytes downloaded */
|
|
74
|
+
bytesDownloaded?: number;
|
|
75
|
+
/** Number of poll operations */
|
|
76
|
+
pollCount?: number;
|
|
77
|
+
/** Chunk index in the result set */
|
|
78
|
+
chunkIndex?: number;
|
|
79
|
+
/** Number of bytes in this chunk */
|
|
80
|
+
bytes?: number;
|
|
81
|
+
/** Whether compression was used */
|
|
82
|
+
compressed?: boolean;
|
|
83
|
+
/** Error name/type */
|
|
84
|
+
errorName?: string;
|
|
85
|
+
/** Error message */
|
|
86
|
+
errorMessage?: string;
|
|
87
|
+
/** Whether the error is terminal (non-retryable) */
|
|
88
|
+
isTerminal?: boolean;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Aggregated telemetry metric for export to Databricks
|
|
92
|
+
*/
|
|
93
|
+
export interface TelemetryMetric {
|
|
94
|
+
/** Type of metric */
|
|
95
|
+
metricType: 'connection' | 'statement' | 'error';
|
|
96
|
+
/** Timestamp when the metric was created (milliseconds since epoch) */
|
|
97
|
+
timestamp: number;
|
|
98
|
+
/** Session ID for correlation */
|
|
99
|
+
sessionId?: string;
|
|
100
|
+
/** Statement ID for correlation */
|
|
101
|
+
statementId?: string;
|
|
102
|
+
/** Workspace ID */
|
|
103
|
+
workspaceId?: string;
|
|
104
|
+
/** Driver configuration (for connection metrics) */
|
|
105
|
+
driverConfig?: DriverConfiguration;
|
|
106
|
+
/** Execution latency in milliseconds */
|
|
107
|
+
latencyMs?: number;
|
|
108
|
+
/** Result format (inline, cloudfetch, arrow) */
|
|
109
|
+
resultFormat?: string;
|
|
110
|
+
/** Number of result chunks */
|
|
111
|
+
chunkCount?: number;
|
|
112
|
+
/** Total bytes downloaded */
|
|
113
|
+
bytesDownloaded?: number;
|
|
114
|
+
/** Number of poll operations */
|
|
115
|
+
pollCount?: number;
|
|
116
|
+
/** Error name/type */
|
|
117
|
+
errorName?: string;
|
|
118
|
+
/** Error message */
|
|
119
|
+
errorMessage?: string;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Driver configuration metadata collected once per connection
|
|
123
|
+
*/
|
|
124
|
+
export interface DriverConfiguration {
|
|
125
|
+
/** Driver version */
|
|
126
|
+
driverVersion: string;
|
|
127
|
+
/** Driver name */
|
|
128
|
+
driverName: string;
|
|
129
|
+
/** Node.js version */
|
|
130
|
+
nodeVersion: string;
|
|
131
|
+
/** Platform (linux, darwin, win32) */
|
|
132
|
+
platform: string;
|
|
133
|
+
/** OS version */
|
|
134
|
+
osVersion: string;
|
|
135
|
+
/** Whether CloudFetch is enabled */
|
|
136
|
+
cloudFetchEnabled: boolean;
|
|
137
|
+
/** Whether LZ4 compression is enabled */
|
|
138
|
+
lz4Enabled: boolean;
|
|
139
|
+
/** Whether Arrow format is enabled */
|
|
140
|
+
arrowEnabled: boolean;
|
|
141
|
+
/** Whether direct results are enabled */
|
|
142
|
+
directResultsEnabled: boolean;
|
|
143
|
+
/** Socket timeout in milliseconds */
|
|
144
|
+
socketTimeout: number;
|
|
145
|
+
/** Maximum retry attempts */
|
|
146
|
+
retryMaxAttempts: number;
|
|
147
|
+
/** Number of concurrent CloudFetch downloads */
|
|
148
|
+
cloudFetchConcurrentDownloads: number;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Per-statement metrics aggregated from multiple events
|
|
152
|
+
*/
|
|
153
|
+
export interface StatementMetrics {
|
|
154
|
+
/** Statement ID */
|
|
155
|
+
statementId: string;
|
|
156
|
+
/** Session ID */
|
|
157
|
+
sessionId: string;
|
|
158
|
+
/** Type of operation */
|
|
159
|
+
operationType?: string;
|
|
160
|
+
/** Start timestamp (milliseconds since epoch) */
|
|
161
|
+
startTime: number;
|
|
162
|
+
/** Total execution latency in milliseconds */
|
|
163
|
+
executionLatencyMs?: number;
|
|
164
|
+
/** Number of poll operations */
|
|
165
|
+
pollCount: number;
|
|
166
|
+
/** Total poll latency in milliseconds */
|
|
167
|
+
pollLatencyMs: number;
|
|
168
|
+
/** Result format (inline, cloudfetch, arrow) */
|
|
169
|
+
resultFormat?: string;
|
|
170
|
+
/** Number of CloudFetch chunks downloaded */
|
|
171
|
+
chunkCount: number;
|
|
172
|
+
/** Total bytes downloaded */
|
|
173
|
+
totalBytesDownloaded: number;
|
|
174
|
+
/** Whether compression was used */
|
|
175
|
+
compressionEnabled?: boolean;
|
|
176
|
+
}
|