@lightdash/warehouses 1.242.7 → 1.243.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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DatabricksWarehouseClient.d.ts","sourceRoot":"","sources":["../../src/warehouseClients/DatabricksWarehouseClient.ts"],"names":[],"mappings":"AACA,OAAqB,EACjB,iBAAiB,EACpB,MAAM,6CAA6C,CAAC;
|
|
1
|
+
{"version":3,"file":"DatabricksWarehouseClient.d.ts","sourceRoot":"","sources":["../../src/warehouseClients/DatabricksWarehouseClient.ts"],"names":[],"mappings":"AACA,OAAqB,EACjB,iBAAiB,EACpB,MAAM,6CAA6C,CAAC;AAKrD,OAAO,EACH,OAAO,EACP,2BAA2B,EAI3B,MAAM,EAIN,mBAAmB,EACnB,gBAAgB,EAIhB,gBAAgB,EAChB,cAAc,EACd,KAAK,eAAe,EACvB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAM5C,OAAO,mBAAmB,MAAM,uBAAuB,CAAC;AACxD,OAAO,uBAAuB,MAAM,2BAA2B,CAAC;AAEhE;;;;;;GAMG;AACH,eAAO,MAAM,kCAAkC,mBAAmB,CAAC;AAQnE,eAAO,MAAM,4BAA4B,aAC3B,MAAM,GAAG,SAAS,KAC7B,OAAsE,CAAC;AAoJ1E,eAAO,MAAM,4BAA4B,SAC/B,MAAM,KACb,eAAe,GAAG,SASpB,CAAC;AAEF,qBAAa,oBAAqB,SAAQ,uBAAuB;IAC7D,QAAQ,CAAC,IAAI,6BAA6B;IAE1C,cAAc,IAAI,mBAAmB,CAEpC;IAED,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAShD;IAED,iBAAiB,IAAI,MAAM,CAE1B;IAED,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAiBlC;IAED,cAAc,CAA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AAC,CAoB3B;IAEK,SAAS,CACX,SAAS,EAAE,MAAM,EACjB,MAAM,CAAC,EAAE,MAAM,EACf,QAAQ,CAAC,EAAE,MAAM,EACjB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC9B,OAAO,CAAC,gBAAgB,CAAC,CAyB3B;CACJ;AAED;;GAEG;AACH,eAAO,MAAM,kCAAkC,SACrC,MAAM,YACF,MAAM,gBACF,MAAM,KACrB,OAAO,CAAC;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,YAAY,CAAC,EAAE,MAAM,CAAA;CAAE,CA+BxD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,2BAA2B,SAC9B,MAAM,YACF,MAAM,gBACF,MAAM,iBACL,MAAM,KACtB,OAAO,CAAC;IACP,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;CACrB,CAqCA,CAAC"}
|
|
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.refreshDatabricksOAuthToken = exports.exchangeDatabricksOAuthCredentials = exports.DatabricksWarehouseClient = exports.DatabricksSqlBuilder = exports.getDatabricksTimestampDomain = exports.isDatabricksCliOAuthClientId = exports.DATABRICKS_DEFAULT_OAUTH_CLIENT_ID = void 0;
|
|
7
7
|
const sql_1 = require("@databricks/sql");
|
|
8
|
+
const StatusError_1 = __importDefault(require("@databricks/sql/dist/errors/StatusError"));
|
|
8
9
|
const TCLIService_types_1 = require("@databricks/sql/thrift/TCLIService_types");
|
|
9
10
|
const common_1 = require("@lightdash/common");
|
|
10
11
|
const node_fetch_1 = __importDefault(require("node-fetch"));
|
|
@@ -216,6 +217,9 @@ const DATABRICKS_QUERY_TIMEOUT_SECONDS = 300;
|
|
|
216
217
|
// @databricks/sql defaults fetchChunk to 100k rows, which materializes entire
|
|
217
218
|
// wide results in one array and can OOM the worker on large queries
|
|
218
219
|
const DATABRICKS_FETCH_CHUNK_MAX_ROWS = 5000;
|
|
220
|
+
const getDatabricksErrorMessage = (error) => error instanceof StatusError_1.default && error.message
|
|
221
|
+
? error.message
|
|
222
|
+
: (0, common_1.getErrorMessage)(error);
|
|
219
223
|
class DatabricksWarehouseClient extends WarehouseBaseClient_1.default {
|
|
220
224
|
constructor(credentials) {
|
|
221
225
|
super(credentials, new DatabricksSqlBuilder(credentials.startOfWeek));
|
|
@@ -267,7 +271,7 @@ class DatabricksWarehouseClient extends WarehouseBaseClient_1.default {
|
|
|
267
271
|
connection = await client.connect(this.connectionOptions);
|
|
268
272
|
}
|
|
269
273
|
catch (e) {
|
|
270
|
-
throw new common_1.WarehouseConnectionError((
|
|
274
|
+
throw new common_1.WarehouseConnectionError(getDatabricksErrorMessage(e));
|
|
271
275
|
}
|
|
272
276
|
try {
|
|
273
277
|
session = await connection.openSession({
|
|
@@ -282,7 +286,7 @@ class DatabricksWarehouseClient extends WarehouseBaseClient_1.default {
|
|
|
282
286
|
catch (closeError) {
|
|
283
287
|
console.error('Error closing connection after session failure', closeError);
|
|
284
288
|
}
|
|
285
|
-
throw new common_1.WarehouseConnectionError((
|
|
289
|
+
throw new common_1.WarehouseConnectionError(getDatabricksErrorMessage(e));
|
|
286
290
|
}
|
|
287
291
|
return {
|
|
288
292
|
session,
|
|
@@ -335,7 +339,7 @@ class DatabricksWarehouseClient extends WarehouseBaseClient_1.default {
|
|
|
335
339
|
} while (await query.hasMoreRows());
|
|
336
340
|
}
|
|
337
341
|
catch (e) {
|
|
338
|
-
throw new common_1.WarehouseQueryError((
|
|
342
|
+
throw new common_1.WarehouseQueryError(getDatabricksErrorMessage(e));
|
|
339
343
|
}
|
|
340
344
|
finally {
|
|
341
345
|
try {
|
|
@@ -364,7 +368,7 @@ class DatabricksWarehouseClient extends WarehouseBaseClient_1.default {
|
|
|
364
368
|
return (await query.fetchAll());
|
|
365
369
|
}
|
|
366
370
|
catch (e) {
|
|
367
|
-
throw new common_1.WarehouseQueryError((
|
|
371
|
+
throw new common_1.WarehouseQueryError(getDatabricksErrorMessage(e));
|
|
368
372
|
}
|
|
369
373
|
finally {
|
|
370
374
|
try {
|
|
@@ -379,7 +383,7 @@ class DatabricksWarehouseClient extends WarehouseBaseClient_1.default {
|
|
|
379
383
|
});
|
|
380
384
|
}
|
|
381
385
|
catch (e) {
|
|
382
|
-
throw new common_1.WarehouseQueryError((
|
|
386
|
+
throw new common_1.WarehouseQueryError(getDatabricksErrorMessage(e));
|
|
383
387
|
}
|
|
384
388
|
finally {
|
|
385
389
|
try {
|
|
@@ -1,32 +1,55 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
/* eslint-disable prefer-arrow-callback, func-names */
|
|
7
|
+
const StatusError_1 = __importDefault(require("@databricks/sql/dist/errors/StatusError"));
|
|
8
|
+
const TCLIService_types_1 = require("@databricks/sql/thrift/TCLIService_types");
|
|
4
9
|
const DatabricksWarehouseClient_1 = require("./DatabricksWarehouseClient");
|
|
5
10
|
const DatabricksWarehouseClient_mock_1 = require("./DatabricksWarehouseClient.mock");
|
|
6
11
|
const WarehouseClient_mock_1 = require("./WarehouseClient.mock");
|
|
7
12
|
const mocks = vi.hoisted(() => ({
|
|
8
13
|
fetchChunk: vi.fn(),
|
|
14
|
+
openSession: vi.fn(),
|
|
15
|
+
closeConnection: vi.fn(),
|
|
9
16
|
}));
|
|
10
17
|
vi.mock('@databricks/sql', async () => ({
|
|
11
18
|
...(await vi.importActual('@databricks/sql')),
|
|
12
19
|
DBSQLClient: vi.fn(function () {
|
|
13
20
|
return {
|
|
14
21
|
connect: vi.fn(() => ({
|
|
15
|
-
openSession:
|
|
16
|
-
|
|
17
|
-
getSchema: vi.fn(async () => DatabricksWarehouseClient_mock_1.schema),
|
|
18
|
-
fetchChunk: mocks.fetchChunk.mockImplementation(async () => DatabricksWarehouseClient_mock_1.rows),
|
|
19
|
-
hasMoreRows: vi.fn(async () => false),
|
|
20
|
-
close: vi.fn(async () => undefined),
|
|
21
|
-
})),
|
|
22
|
-
close: vi.fn(async () => undefined),
|
|
23
|
-
})),
|
|
24
|
-
close: vi.fn(async () => undefined),
|
|
22
|
+
openSession: mocks.openSession,
|
|
23
|
+
close: mocks.closeConnection,
|
|
25
24
|
})),
|
|
26
25
|
};
|
|
27
26
|
}),
|
|
28
27
|
}));
|
|
29
28
|
describe('DatabricksWarehouseClient', () => {
|
|
29
|
+
beforeEach(() => {
|
|
30
|
+
mocks.fetchChunk.mockReset().mockResolvedValue(DatabricksWarehouseClient_mock_1.rows);
|
|
31
|
+
mocks.closeConnection.mockReset().mockResolvedValue(undefined);
|
|
32
|
+
mocks.openSession.mockReset().mockResolvedValue({
|
|
33
|
+
executeStatement: vi.fn(() => ({
|
|
34
|
+
getSchema: vi.fn(async () => DatabricksWarehouseClient_mock_1.schema),
|
|
35
|
+
fetchChunk: mocks.fetchChunk,
|
|
36
|
+
hasMoreRows: vi.fn(async () => false),
|
|
37
|
+
close: vi.fn(async () => undefined),
|
|
38
|
+
})),
|
|
39
|
+
close: vi.fn(async () => undefined),
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
it('surfaces Databricks status messages when opening a session fails', async () => {
|
|
43
|
+
const message = 'SQL warehouse xyz is not ready to accept connections (current state: STARTING)';
|
|
44
|
+
mocks.openSession.mockRejectedValueOnce(new StatusError_1.default({
|
|
45
|
+
statusCode: TCLIService_types_1.TStatusCode.ERROR_STATUS,
|
|
46
|
+
errorMessage: message,
|
|
47
|
+
}));
|
|
48
|
+
const warehouse = new DatabricksWarehouseClient_1.DatabricksWarehouseClient(DatabricksWarehouseClient_mock_1.credentials);
|
|
49
|
+
await expect(warehouse.runQuery('fake sql')).rejects.toMatchObject({
|
|
50
|
+
message,
|
|
51
|
+
});
|
|
52
|
+
});
|
|
30
53
|
it('expect query fields and rows', async () => {
|
|
31
54
|
const warehouse = new DatabricksWarehouseClient_1.DatabricksWarehouseClient(DatabricksWarehouseClient_mock_1.credentials);
|
|
32
55
|
const results = await warehouse.runQuery('fake sql');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lightdash/warehouses",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.243.1",
|
|
4
4
|
"description": "Warehouse connectors for Lightdash",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"snowflake-sdk": "2.3.4",
|
|
29
29
|
"ssh2": "1.14.0",
|
|
30
30
|
"trino-client": "0.2.9",
|
|
31
|
-
"@lightdash/common": "1.
|
|
31
|
+
"@lightdash/common": "1.243.1"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"oxlint": "1.75.0",
|