@lightdash/warehouses 3.388.0 → 3.389.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.
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ConnectionOptions } from '@databricks/sql/dist/contracts/IDBSQLClient';
|
|
2
2
|
import { TTypeId as DatabricksDataTypes } from '@databricks/sql/thrift/TCLIService_types';
|
|
3
|
-
import { AnyType, CreateDatabricksCredentials, Metric, SupportedDbtAdapter, TimeIntervalUnit, UnnestSql, UnnestSqlArgs, WarehouseResults, WarehouseTypes, type ResultNumericKind, type TimestampDomain } from '@lightdash/common';
|
|
3
|
+
import { AnyType, CreateDatabricksCredentials, Metric, SupportedDbtAdapter, TimeIntervalUnit, UnnestSql, UnnestSqlArgs, WarehouseResults, WarehouseTypes, type ResultNumericKind, type TableListingFailure, type TimestampDomain } from '@lightdash/common';
|
|
4
4
|
import { type RequestInit } from 'node-fetch';
|
|
5
5
|
import { WarehouseCatalog } from '../types';
|
|
6
6
|
import WarehouseBaseClient from './WarehouseBaseClient';
|
|
@@ -48,6 +48,8 @@ export declare enum DatabricksErrorCondition {
|
|
|
48
48
|
ParseSyntaxError = "PARSE_SYNTAX_ERROR"
|
|
49
49
|
}
|
|
50
50
|
export declare const getDatabricksErrorCondition: (error: unknown) => DatabricksErrorCondition | undefined;
|
|
51
|
+
/** Reads why `information_schema.tables` could not be listed; `other` when the message names no known reason. */
|
|
52
|
+
export declare const getDatabricksTableListingFailure: (error: unknown, configuredCatalog: string | null) => TableListingFailure;
|
|
51
53
|
export declare class DatabricksWarehouseClient extends WarehouseBaseClient<CreateDatabricksCredentials> {
|
|
52
54
|
schema: string;
|
|
53
55
|
catalog?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DatabricksWarehouseClient.d.ts","sourceRoot":"","sources":["../../src/warehouseClients/DatabricksWarehouseClient.ts"],"names":[],"mappings":"AACA,OAAqB,EACjB,iBAAiB,EAC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AAO,CAAC;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,YAAY,CAAC,EAAE,MAAM,CAAA;CAAE,CAgCxD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,2BAA2B,SAC9B,MAAM,YACF,MAAM,gBACF,MAAM,iBACL,MAAM,cACT,IAAI,CAAC,WAAW,EAAE,OAAO,CAAC,KACvC,OAAO,CAAC;IACP,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;CACrB,CAsCA,CAAC"}
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.refreshDatabricksOAuthToken = exports.exchangeDatabricksOAuthCredentials = exports.DatabricksWarehouseClient = exports.getDatabricksErrorCondition = exports.DatabricksErrorCondition = exports.DatabricksSqlBuilder = exports.getDatabricksTimestampDomain = exports.getDatabricksNumericKind = exports.isDatabricksCliOAuthClientId = exports.DATABRICKS_DEFAULT_OAUTH_CLIENT_ID = void 0;
|
|
6
|
+
exports.refreshDatabricksOAuthToken = exports.exchangeDatabricksOAuthCredentials = exports.DatabricksWarehouseClient = exports.getDatabricksTableListingFailure = exports.getDatabricksErrorCondition = exports.DatabricksErrorCondition = exports.DatabricksSqlBuilder = exports.getDatabricksTimestampDomain = exports.getDatabricksNumericKind = exports.isDatabricksCliOAuthClientId = exports.DATABRICKS_DEFAULT_OAUTH_CLIENT_ID = void 0;
|
|
7
7
|
const sql_1 = require("@databricks/sql");
|
|
8
8
|
const StatusError_1 = __importDefault(require("@databricks/sql/dist/errors/StatusError"));
|
|
9
9
|
const TCLIService_types_1 = require("@databricks/sql/thrift/TCLIService_types");
|
|
@@ -334,6 +334,54 @@ const getDatabricksErrorCondition = (error) => {
|
|
|
334
334
|
return Object.values(DatabricksErrorCondition).find((known) => known === condition);
|
|
335
335
|
};
|
|
336
336
|
exports.getDatabricksErrorCondition = getDatabricksErrorCondition;
|
|
337
|
+
const splitSecurable = (name) => name.replaceAll('`', '').split('.').filter(Boolean);
|
|
338
|
+
/** Reads why `information_schema.tables` could not be listed; `other` when the message names no known reason. */
|
|
339
|
+
const getDatabricksTableListingFailure = (error, configuredCatalog) => {
|
|
340
|
+
const message = getDatabricksErrorMessage(error);
|
|
341
|
+
const quoted = /['`]([^'`\s]+)['`]/.exec(message)?.[1];
|
|
342
|
+
if (/\b(NO_SUCH_CATALOG_EXCEPTION|CATALOG_NOT_FOUND)\b/.test(message) ||
|
|
343
|
+
/Catalog '[^']+' was not found/.test(message)) {
|
|
344
|
+
return {
|
|
345
|
+
kind: 'catalog_not_found',
|
|
346
|
+
catalog: quoted ? splitSecurable(quoted)[0] : configuredCatalog,
|
|
347
|
+
message,
|
|
348
|
+
};
|
|
349
|
+
}
|
|
350
|
+
if (/\b(TABLE_OR_VIEW_NOT_FOUND|SCHEMA_NOT_FOUND)\b/.test(message) &&
|
|
351
|
+
/information_schema/i.test(message)) {
|
|
352
|
+
return {
|
|
353
|
+
kind: 'no_information_schema',
|
|
354
|
+
catalog: configuredCatalog,
|
|
355
|
+
message,
|
|
356
|
+
};
|
|
357
|
+
}
|
|
358
|
+
const missingGrant = /does not have (?:permission )?([A-Z][A-Z_ ]*?) on (?:(Catalog|Schema|Table|View) )?['`]?([\w.`-]+?)['`]?\.?(?:\s|$)/.exec(message);
|
|
359
|
+
if (missingGrant ||
|
|
360
|
+
/\b(INSUFFICIENT_PERMISSIONS\w*|PERMISSION_DENIED)\b/.test(message)) {
|
|
361
|
+
const securable = missingGrant?.[3] ?? quoted;
|
|
362
|
+
const parts = securable ? splitSecurable(securable) : [];
|
|
363
|
+
const type = missingGrant?.[2];
|
|
364
|
+
const depths = {
|
|
365
|
+
Catalog: 1,
|
|
366
|
+
Schema: 2,
|
|
367
|
+
Table: 3,
|
|
368
|
+
View: 3,
|
|
369
|
+
};
|
|
370
|
+
const depth = type ? depths[type] : null;
|
|
371
|
+
// Right-align a partly qualified name to catalog.schema.table
|
|
372
|
+
const padding = Array.from({ length: depth === null ? 0 : depth - parts.length }, () => null);
|
|
373
|
+
const aligned = [...padding, ...parts];
|
|
374
|
+
return {
|
|
375
|
+
kind: 'missing_privilege',
|
|
376
|
+
privilege: missingGrant?.[1] ?? null,
|
|
377
|
+
catalog: aligned[0] ?? null,
|
|
378
|
+
schema: depth === 1 ? null : (aligned[1] ?? null),
|
|
379
|
+
message,
|
|
380
|
+
};
|
|
381
|
+
}
|
|
382
|
+
return { kind: 'other', message };
|
|
383
|
+
};
|
|
384
|
+
exports.getDatabricksTableListingFailure = getDatabricksTableListingFailure;
|
|
337
385
|
// Don't let close errors override the original error
|
|
338
386
|
const closeQuietly = async (close, context) => {
|
|
339
387
|
try {
|
|
@@ -662,7 +710,16 @@ class DatabricksWarehouseClient extends WarehouseBaseClient_1.default {
|
|
|
662
710
|
WHERE table_schema <> 'information_schema'
|
|
663
711
|
ORDER BY 1,2,3
|
|
664
712
|
`;
|
|
665
|
-
|
|
713
|
+
let rows;
|
|
714
|
+
try {
|
|
715
|
+
({ rows } = await this.runQuery(query, {}, undefined, undefined));
|
|
716
|
+
}
|
|
717
|
+
catch (e) {
|
|
718
|
+
const failure = (0, exports.getDatabricksTableListingFailure)(e, this.catalog ?? null);
|
|
719
|
+
if (failure.kind === 'other')
|
|
720
|
+
throw e;
|
|
721
|
+
throw new common_1.WarehouseTableListingError(failure);
|
|
722
|
+
}
|
|
666
723
|
return rows.map((row) => ({
|
|
667
724
|
database: row.table_catalog,
|
|
668
725
|
schema: row.table_schema,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lightdash/warehouses",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.389.0",
|
|
4
4
|
"description": "Warehouse connectors for Lightdash",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"@databricks/sql": "1.13.0",
|
|
22
22
|
"@duckdb/node-api": "1.5.2-r.2",
|
|
23
23
|
"@google-cloud/bigquery": "8.3.1",
|
|
24
|
-
"@lightdash/common": "3.
|
|
24
|
+
"@lightdash/common": "3.389.0",
|
|
25
25
|
"node-fetch": "2.7.0",
|
|
26
26
|
"pg": "8.13.1",
|
|
27
27
|
"pg-cursor": "2.10.0",
|