@querypanel/node-sdk 1.3.3 → 1.3.5
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 +47 -19
- package/dist/index.cjs +50 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +23 -4
- package/dist/index.d.ts +23 -4
- package/dist/index.js +50 -6
- package/dist/index.js.map +1 -1
- package/package.json +16 -3
package/dist/index.d.cts
CHANGED
|
@@ -37,7 +37,7 @@ interface IntrospectOptions {
|
|
|
37
37
|
tables?: string[];
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
type DatabaseDialect = "bigquery" | "clickhouse" | "postgres" | "mysql";
|
|
40
|
+
type DatabaseDialect = "bigquery" | "clickhouse" | "postgres" | "redshift" | "mysql";
|
|
41
41
|
interface DatabaseExecutionResult {
|
|
42
42
|
fields: string[];
|
|
43
43
|
rows: Array<Record<string, unknown>>;
|
|
@@ -192,13 +192,19 @@ interface PostgresQueryResult {
|
|
|
192
192
|
}>;
|
|
193
193
|
}
|
|
194
194
|
type PostgresClientFn = (sql: string, params?: unknown[]) => Promise<PostgresQueryResult>;
|
|
195
|
+
type PostgresWireDialect = "postgres" | "redshift";
|
|
195
196
|
interface PostgresAdapterOptions {
|
|
196
197
|
/** Logical database name used in introspection metadata. */
|
|
197
198
|
database?: string;
|
|
198
199
|
/** Schema to assume when a table is provided without qualification. */
|
|
199
200
|
defaultSchema?: string;
|
|
200
|
-
/** Optional database kind label. Defaults to
|
|
201
|
+
/** Optional database kind label. Defaults to the dialect. */
|
|
201
202
|
kind?: SchemaIntrospection["db"]["kind"];
|
|
203
|
+
/**
|
|
204
|
+
* Wire-compatible engine behind the client. "redshift" uses Redshift's
|
|
205
|
+
* svv_* catalog views for introspection. Defaults to "postgres".
|
|
206
|
+
*/
|
|
207
|
+
dialect?: PostgresWireDialect;
|
|
202
208
|
/**
|
|
203
209
|
* Optional allow-list of table names (schema-qualified or bare).
|
|
204
210
|
* When specified, introspection and queries are restricted to these tables only.
|
|
@@ -215,6 +221,7 @@ declare class PostgresAdapter implements DatabaseAdapter {
|
|
|
215
221
|
private readonly databaseName;
|
|
216
222
|
private readonly defaultSchema;
|
|
217
223
|
private readonly kind;
|
|
224
|
+
private readonly dialect;
|
|
218
225
|
private readonly allowedTables?;
|
|
219
226
|
constructor(clientFn: PostgresClientFn, options?: PostgresAdapterOptions);
|
|
220
227
|
execute(sql: string, params?: Record<string, string | number | boolean | string[] | number[]>): Promise<DatabaseExecutionResult>;
|
|
@@ -225,7 +232,7 @@ declare class PostgresAdapter implements DatabaseAdapter {
|
|
|
225
232
|
*/
|
|
226
233
|
private convertNamedToPositionalParams;
|
|
227
234
|
validate(sql: string, params?: Record<string, string | number | boolean | string[] | number[]>): Promise<void>;
|
|
228
|
-
getDialect():
|
|
235
|
+
getDialect(): PostgresWireDialect;
|
|
229
236
|
/**
|
|
230
237
|
* Simplified introspection: only collect table/column metadata for IngestRequest
|
|
231
238
|
* No indexes, constraints, or statistics
|
|
@@ -1255,6 +1262,18 @@ declare class QueryPanelSdkAPI {
|
|
|
1255
1262
|
tenantFieldType?: string;
|
|
1256
1263
|
enforceTenantIsolation?: boolean;
|
|
1257
1264
|
}): void;
|
|
1265
|
+
/**
|
|
1266
|
+
* Attach an Amazon Redshift database. Redshift speaks the Postgres wire
|
|
1267
|
+
* protocol, so `clientFn` can wrap a `pg` client; introspection uses
|
|
1268
|
+
* Redshift's svv_* catalog views and SQL is generated for Redshift.
|
|
1269
|
+
*/
|
|
1270
|
+
attachRedshift(name: string, clientFn: PostgresClientFn, options?: Omit<PostgresAdapterOptions, "dialect"> & {
|
|
1271
|
+
description?: string;
|
|
1272
|
+
tags?: string[];
|
|
1273
|
+
tenantFieldName?: string;
|
|
1274
|
+
tenantFieldType?: string;
|
|
1275
|
+
enforceTenantIsolation?: boolean;
|
|
1276
|
+
}): void;
|
|
1258
1277
|
attachBigQuery(name: string, clientFn: BigQueryClientFn, options: BigQueryAdapterOptions & {
|
|
1259
1278
|
description?: string;
|
|
1260
1279
|
tags?: string[];
|
|
@@ -1993,4 +2012,4 @@ declare class QueryPanelSdkAPI {
|
|
|
1993
2012
|
}, signal?: AbortSignal): Promise<SdkDashboard[]>;
|
|
1994
2013
|
}
|
|
1995
2014
|
|
|
1996
|
-
export { ALL_VIZ_CHART_TYPES, type ActiveChartBulkGetResponse, type ActiveChartCreateInput, type ActiveChartListOptions, type ActiveChartUpdateInput, type AggregateOp, type AskOptions, type AskResponse, type AxisField, type AxisFieldInput, BigQueryAdapter, type BigQueryAdapterOptions, type BigQueryClientFn, type BigQueryQueryRequest, type BigQueryQueryResult, CallbackApiClient, type ChartBulkGetResponse, type ChartCreateInput, type ChartEncoding, type ChartEnvelope, type ChartListAllOptions, type ChartListOptions, type ChartModifyInput, type ChartModifyOptions, type ChartModifyResponse, type ChartSpec, type ChartType, type ChartUpdateInput, ClickHouseAdapter, type ClickHouseAdapterOptions, type ClickHouseClientFn, type ContextDocument, type DashboardCreateInput, type DashboardForkInput, type DashboardForkUpdateInput, type DashboardListOptions, type DashboardUpdateInput, type DatabaseAdapter, type DatabaseDialect, type DateRangeInput, type EncodingHints, type FieldRef, type FieldRefInput, type FieldType, type IQueryPanelApi, type IngestResponse, type IntentResult, type MetricEncoding, type MetricField, type MetricSpec, type PaginatedResponse$1 as PaginatedResponse, type PaginationInfo$1 as PaginationInfo, type PaginationQuery$1 as PaginationQuery, type ParamRecord, type ParamValue, type PipelineTrace, PostgresAdapter, type PostgresAdapterOptions, type PostgresClientFn, QueryErrorCode, QueryErrorCode as QueryErrorCodeType, QueryPanelSdkAPI, type QueryPanelSdkAPIOptions, QueryPipelineError, type RequestHandler, type RequestHandlerOptions, type RequestHandlerResult, type SchemaIntrospection, type SchemaSyncOptions, type SdkActiveChart, type SdkChart, type SdkDashboard, type SdkSession, type SdkSessionTurn, type SessionGetOptions, type SessionListOptions, type SessionUpdateInput, type SqlModifications, type StackingMode, type TableColumn, type TableEncoding, type TableSpec, type TimeUnit, type ValueFormat, type VizModifications, type VizSpec, type VizSpecGenerateInput, type VizSpecGenerateOptions, type VizSpecGeneratorInput, type VizSpecKind, type VizSpecResponse, type VizSpecResult, anonymizeResults, mapGeneratedParams, normalizeSqlParamsInput, resolveQueryPipeline };
|
|
2015
|
+
export { ALL_VIZ_CHART_TYPES, type ActiveChartBulkGetResponse, type ActiveChartCreateInput, type ActiveChartListOptions, type ActiveChartUpdateInput, type AggregateOp, type AskOptions, type AskResponse, type AxisField, type AxisFieldInput, BigQueryAdapter, type BigQueryAdapterOptions, type BigQueryClientFn, type BigQueryQueryRequest, type BigQueryQueryResult, CallbackApiClient, type ChartBulkGetResponse, type ChartCreateInput, type ChartEncoding, type ChartEnvelope, type ChartListAllOptions, type ChartListOptions, type ChartModifyInput, type ChartModifyOptions, type ChartModifyResponse, type ChartSpec, type ChartType, type ChartUpdateInput, ClickHouseAdapter, type ClickHouseAdapterOptions, type ClickHouseClientFn, type ContextDocument, type DashboardCreateInput, type DashboardForkInput, type DashboardForkUpdateInput, type DashboardListOptions, type DashboardUpdateInput, type DatabaseAdapter, type DatabaseDialect, type DateRangeInput, type EncodingHints, type FieldRef, type FieldRefInput, type FieldType, type IQueryPanelApi, type IngestResponse, type IntentResult, type MetricEncoding, type MetricField, type MetricSpec, type PaginatedResponse$1 as PaginatedResponse, type PaginationInfo$1 as PaginationInfo, type PaginationQuery$1 as PaginationQuery, type ParamRecord, type ParamValue, type PipelineTrace, PostgresAdapter, type PostgresAdapterOptions, type PostgresClientFn, type PostgresWireDialect, QueryErrorCode, QueryErrorCode as QueryErrorCodeType, QueryPanelSdkAPI, type QueryPanelSdkAPIOptions, QueryPipelineError, type RequestHandler, type RequestHandlerOptions, type RequestHandlerResult, type SchemaIntrospection, type SchemaSyncOptions, type SdkActiveChart, type SdkChart, type SdkDashboard, type SdkSession, type SdkSessionTurn, type SessionGetOptions, type SessionListOptions, type SessionUpdateInput, type SqlModifications, type StackingMode, type TableColumn, type TableEncoding, type TableSpec, type TimeUnit, type ValueFormat, type VizModifications, type VizSpec, type VizSpecGenerateInput, type VizSpecGenerateOptions, type VizSpecGeneratorInput, type VizSpecKind, type VizSpecResponse, type VizSpecResult, anonymizeResults, mapGeneratedParams, normalizeSqlParamsInput, resolveQueryPipeline };
|
package/dist/index.d.ts
CHANGED
|
@@ -37,7 +37,7 @@ interface IntrospectOptions {
|
|
|
37
37
|
tables?: string[];
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
type DatabaseDialect = "bigquery" | "clickhouse" | "postgres" | "mysql";
|
|
40
|
+
type DatabaseDialect = "bigquery" | "clickhouse" | "postgres" | "redshift" | "mysql";
|
|
41
41
|
interface DatabaseExecutionResult {
|
|
42
42
|
fields: string[];
|
|
43
43
|
rows: Array<Record<string, unknown>>;
|
|
@@ -192,13 +192,19 @@ interface PostgresQueryResult {
|
|
|
192
192
|
}>;
|
|
193
193
|
}
|
|
194
194
|
type PostgresClientFn = (sql: string, params?: unknown[]) => Promise<PostgresQueryResult>;
|
|
195
|
+
type PostgresWireDialect = "postgres" | "redshift";
|
|
195
196
|
interface PostgresAdapterOptions {
|
|
196
197
|
/** Logical database name used in introspection metadata. */
|
|
197
198
|
database?: string;
|
|
198
199
|
/** Schema to assume when a table is provided without qualification. */
|
|
199
200
|
defaultSchema?: string;
|
|
200
|
-
/** Optional database kind label. Defaults to
|
|
201
|
+
/** Optional database kind label. Defaults to the dialect. */
|
|
201
202
|
kind?: SchemaIntrospection["db"]["kind"];
|
|
203
|
+
/**
|
|
204
|
+
* Wire-compatible engine behind the client. "redshift" uses Redshift's
|
|
205
|
+
* svv_* catalog views for introspection. Defaults to "postgres".
|
|
206
|
+
*/
|
|
207
|
+
dialect?: PostgresWireDialect;
|
|
202
208
|
/**
|
|
203
209
|
* Optional allow-list of table names (schema-qualified or bare).
|
|
204
210
|
* When specified, introspection and queries are restricted to these tables only.
|
|
@@ -215,6 +221,7 @@ declare class PostgresAdapter implements DatabaseAdapter {
|
|
|
215
221
|
private readonly databaseName;
|
|
216
222
|
private readonly defaultSchema;
|
|
217
223
|
private readonly kind;
|
|
224
|
+
private readonly dialect;
|
|
218
225
|
private readonly allowedTables?;
|
|
219
226
|
constructor(clientFn: PostgresClientFn, options?: PostgresAdapterOptions);
|
|
220
227
|
execute(sql: string, params?: Record<string, string | number | boolean | string[] | number[]>): Promise<DatabaseExecutionResult>;
|
|
@@ -225,7 +232,7 @@ declare class PostgresAdapter implements DatabaseAdapter {
|
|
|
225
232
|
*/
|
|
226
233
|
private convertNamedToPositionalParams;
|
|
227
234
|
validate(sql: string, params?: Record<string, string | number | boolean | string[] | number[]>): Promise<void>;
|
|
228
|
-
getDialect():
|
|
235
|
+
getDialect(): PostgresWireDialect;
|
|
229
236
|
/**
|
|
230
237
|
* Simplified introspection: only collect table/column metadata for IngestRequest
|
|
231
238
|
* No indexes, constraints, or statistics
|
|
@@ -1255,6 +1262,18 @@ declare class QueryPanelSdkAPI {
|
|
|
1255
1262
|
tenantFieldType?: string;
|
|
1256
1263
|
enforceTenantIsolation?: boolean;
|
|
1257
1264
|
}): void;
|
|
1265
|
+
/**
|
|
1266
|
+
* Attach an Amazon Redshift database. Redshift speaks the Postgres wire
|
|
1267
|
+
* protocol, so `clientFn` can wrap a `pg` client; introspection uses
|
|
1268
|
+
* Redshift's svv_* catalog views and SQL is generated for Redshift.
|
|
1269
|
+
*/
|
|
1270
|
+
attachRedshift(name: string, clientFn: PostgresClientFn, options?: Omit<PostgresAdapterOptions, "dialect"> & {
|
|
1271
|
+
description?: string;
|
|
1272
|
+
tags?: string[];
|
|
1273
|
+
tenantFieldName?: string;
|
|
1274
|
+
tenantFieldType?: string;
|
|
1275
|
+
enforceTenantIsolation?: boolean;
|
|
1276
|
+
}): void;
|
|
1258
1277
|
attachBigQuery(name: string, clientFn: BigQueryClientFn, options: BigQueryAdapterOptions & {
|
|
1259
1278
|
description?: string;
|
|
1260
1279
|
tags?: string[];
|
|
@@ -1993,4 +2012,4 @@ declare class QueryPanelSdkAPI {
|
|
|
1993
2012
|
}, signal?: AbortSignal): Promise<SdkDashboard[]>;
|
|
1994
2013
|
}
|
|
1995
2014
|
|
|
1996
|
-
export { ALL_VIZ_CHART_TYPES, type ActiveChartBulkGetResponse, type ActiveChartCreateInput, type ActiveChartListOptions, type ActiveChartUpdateInput, type AggregateOp, type AskOptions, type AskResponse, type AxisField, type AxisFieldInput, BigQueryAdapter, type BigQueryAdapterOptions, type BigQueryClientFn, type BigQueryQueryRequest, type BigQueryQueryResult, CallbackApiClient, type ChartBulkGetResponse, type ChartCreateInput, type ChartEncoding, type ChartEnvelope, type ChartListAllOptions, type ChartListOptions, type ChartModifyInput, type ChartModifyOptions, type ChartModifyResponse, type ChartSpec, type ChartType, type ChartUpdateInput, ClickHouseAdapter, type ClickHouseAdapterOptions, type ClickHouseClientFn, type ContextDocument, type DashboardCreateInput, type DashboardForkInput, type DashboardForkUpdateInput, type DashboardListOptions, type DashboardUpdateInput, type DatabaseAdapter, type DatabaseDialect, type DateRangeInput, type EncodingHints, type FieldRef, type FieldRefInput, type FieldType, type IQueryPanelApi, type IngestResponse, type IntentResult, type MetricEncoding, type MetricField, type MetricSpec, type PaginatedResponse$1 as PaginatedResponse, type PaginationInfo$1 as PaginationInfo, type PaginationQuery$1 as PaginationQuery, type ParamRecord, type ParamValue, type PipelineTrace, PostgresAdapter, type PostgresAdapterOptions, type PostgresClientFn, QueryErrorCode, QueryErrorCode as QueryErrorCodeType, QueryPanelSdkAPI, type QueryPanelSdkAPIOptions, QueryPipelineError, type RequestHandler, type RequestHandlerOptions, type RequestHandlerResult, type SchemaIntrospection, type SchemaSyncOptions, type SdkActiveChart, type SdkChart, type SdkDashboard, type SdkSession, type SdkSessionTurn, type SessionGetOptions, type SessionListOptions, type SessionUpdateInput, type SqlModifications, type StackingMode, type TableColumn, type TableEncoding, type TableSpec, type TimeUnit, type ValueFormat, type VizModifications, type VizSpec, type VizSpecGenerateInput, type VizSpecGenerateOptions, type VizSpecGeneratorInput, type VizSpecKind, type VizSpecResponse, type VizSpecResult, anonymizeResults, mapGeneratedParams, normalizeSqlParamsInput, resolveQueryPipeline };
|
|
2015
|
+
export { ALL_VIZ_CHART_TYPES, type ActiveChartBulkGetResponse, type ActiveChartCreateInput, type ActiveChartListOptions, type ActiveChartUpdateInput, type AggregateOp, type AskOptions, type AskResponse, type AxisField, type AxisFieldInput, BigQueryAdapter, type BigQueryAdapterOptions, type BigQueryClientFn, type BigQueryQueryRequest, type BigQueryQueryResult, CallbackApiClient, type ChartBulkGetResponse, type ChartCreateInput, type ChartEncoding, type ChartEnvelope, type ChartListAllOptions, type ChartListOptions, type ChartModifyInput, type ChartModifyOptions, type ChartModifyResponse, type ChartSpec, type ChartType, type ChartUpdateInput, ClickHouseAdapter, type ClickHouseAdapterOptions, type ClickHouseClientFn, type ContextDocument, type DashboardCreateInput, type DashboardForkInput, type DashboardForkUpdateInput, type DashboardListOptions, type DashboardUpdateInput, type DatabaseAdapter, type DatabaseDialect, type DateRangeInput, type EncodingHints, type FieldRef, type FieldRefInput, type FieldType, type IQueryPanelApi, type IngestResponse, type IntentResult, type MetricEncoding, type MetricField, type MetricSpec, type PaginatedResponse$1 as PaginatedResponse, type PaginationInfo$1 as PaginationInfo, type PaginationQuery$1 as PaginationQuery, type ParamRecord, type ParamValue, type PipelineTrace, PostgresAdapter, type PostgresAdapterOptions, type PostgresClientFn, type PostgresWireDialect, QueryErrorCode, QueryErrorCode as QueryErrorCodeType, QueryPanelSdkAPI, type QueryPanelSdkAPIOptions, QueryPipelineError, type RequestHandler, type RequestHandlerOptions, type RequestHandlerResult, type SchemaIntrospection, type SchemaSyncOptions, type SdkActiveChart, type SdkChart, type SdkDashboard, type SdkSession, type SdkSessionTurn, type SessionGetOptions, type SessionListOptions, type SessionUpdateInput, type SqlModifications, type StackingMode, type TableColumn, type TableEncoding, type TableSpec, type TimeUnit, type ValueFormat, type VizModifications, type VizSpec, type VizSpecGenerateInput, type VizSpecGenerateOptions, type VizSpecGeneratorInput, type VizSpecKind, type VizSpecResponse, type VizSpecResult, anonymizeResults, mapGeneratedParams, normalizeSqlParamsInput, resolveQueryPipeline };
|
package/dist/index.js
CHANGED
|
@@ -501,7 +501,8 @@ var PostgresAdapter = class {
|
|
|
501
501
|
this.clientFn = clientFn;
|
|
502
502
|
this.databaseName = options.database ?? "postgres";
|
|
503
503
|
this.defaultSchema = options.defaultSchema ?? "public";
|
|
504
|
-
this.
|
|
504
|
+
this.dialect = options.dialect ?? "postgres";
|
|
505
|
+
this.kind = options.kind ?? this.dialect;
|
|
505
506
|
if (options.allowedTables) {
|
|
506
507
|
this.allowedTables = normalizeTableFilter3(
|
|
507
508
|
options.allowedTables,
|
|
@@ -513,6 +514,7 @@ var PostgresAdapter = class {
|
|
|
513
514
|
databaseName;
|
|
514
515
|
defaultSchema;
|
|
515
516
|
kind;
|
|
517
|
+
dialect;
|
|
516
518
|
allowedTables;
|
|
517
519
|
async execute(sql, params) {
|
|
518
520
|
if (this.allowedTables) {
|
|
@@ -592,7 +594,7 @@ var PostgresAdapter = class {
|
|
|
592
594
|
await this.clientFn(`EXPLAIN ${sql}`, paramArray);
|
|
593
595
|
}
|
|
594
596
|
getDialect() {
|
|
595
|
-
return
|
|
597
|
+
return this.dialect;
|
|
596
598
|
}
|
|
597
599
|
/**
|
|
598
600
|
* Simplified introspection: only collect table/column metadata for IngestRequest
|
|
@@ -601,12 +603,13 @@ var PostgresAdapter = class {
|
|
|
601
603
|
async introspect(options) {
|
|
602
604
|
const tablesToIntrospect = options?.tables ? normalizeTableFilter3(options.tables, this.defaultSchema) : this.allowedTables;
|
|
603
605
|
const normalizedTables = tablesToIntrospect ?? [];
|
|
606
|
+
const isRedshift = this.dialect === "redshift";
|
|
604
607
|
const tablesResult = await this.clientFn(
|
|
605
|
-
buildTablesQuery2(normalizedTables)
|
|
608
|
+
isRedshift ? buildRedshiftTablesQuery(normalizedTables) : buildTablesQuery2(normalizedTables)
|
|
606
609
|
);
|
|
607
610
|
const tableRows = tablesResult.rows;
|
|
608
611
|
const columnsResult = await this.clientFn(
|
|
609
|
-
buildColumnsQuery2(normalizedTables)
|
|
612
|
+
isRedshift ? buildRedshiftColumnsQuery(normalizedTables) : buildColumnsQuery2(normalizedTables)
|
|
610
613
|
);
|
|
611
614
|
const columnRows = columnsResult.rows;
|
|
612
615
|
const tablesByKey = /* @__PURE__ */ new Map();
|
|
@@ -720,10 +723,11 @@ function buildColumnsQuery2(tables) {
|
|
|
720
723
|
AND kcu.column_name = cols.column_name
|
|
721
724
|
) AS is_primary_key
|
|
722
725
|
FROM information_schema.columns cols
|
|
726
|
+
LEFT JOIN pg_catalog.pg_namespace n ON n.nspname = cols.table_schema
|
|
723
727
|
LEFT JOIN pg_catalog.pg_class c
|
|
724
728
|
ON c.relname = cols.table_name
|
|
729
|
+
AND c.relnamespace = n.oid
|
|
725
730
|
AND c.relkind IN ('r', 'v', 'm')
|
|
726
|
-
LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
|
|
727
731
|
LEFT JOIN pg_catalog.pg_attribute attr
|
|
728
732
|
ON attr.attrelid = c.oid
|
|
729
733
|
AND attr.attname = cols.column_name
|
|
@@ -733,6 +737,38 @@ function buildColumnsQuery2(tables) {
|
|
|
733
737
|
${filter}
|
|
734
738
|
ORDER BY cols.table_schema, cols.table_name, cols.ordinal_position;`;
|
|
735
739
|
}
|
|
740
|
+
var REDSHIFT_EXCLUDED_SCHEMAS = "('pg_catalog', 'information_schema', 'pg_internal', 'pg_automv')";
|
|
741
|
+
function buildRedshiftTablesQuery(tables) {
|
|
742
|
+
const filter = buildFilterClause(tables, "table_schema", "table_name");
|
|
743
|
+
return `SELECT
|
|
744
|
+
table_name,
|
|
745
|
+
table_schema AS schema_name,
|
|
746
|
+
table_type,
|
|
747
|
+
remarks AS comment
|
|
748
|
+
FROM svv_tables
|
|
749
|
+
WHERE table_catalog = current_database()
|
|
750
|
+
AND table_schema NOT IN ${REDSHIFT_EXCLUDED_SCHEMAS}
|
|
751
|
+
AND table_schema NOT LIKE 'pg_temp%'
|
|
752
|
+
${filter}
|
|
753
|
+
ORDER BY table_schema, table_name;`;
|
|
754
|
+
}
|
|
755
|
+
function buildRedshiftColumnsQuery(tables) {
|
|
756
|
+
const filter = buildFilterClause(tables, "table_schema", "table_name");
|
|
757
|
+
return `SELECT
|
|
758
|
+
table_name,
|
|
759
|
+
table_schema,
|
|
760
|
+
column_name,
|
|
761
|
+
data_type,
|
|
762
|
+
NULL AS udt_name,
|
|
763
|
+
remarks AS description,
|
|
764
|
+
FALSE AS is_primary_key
|
|
765
|
+
FROM svv_columns
|
|
766
|
+
WHERE table_catalog = current_database()
|
|
767
|
+
AND table_schema NOT IN ${REDSHIFT_EXCLUDED_SCHEMAS}
|
|
768
|
+
AND table_schema NOT LIKE 'pg_temp%'
|
|
769
|
+
${filter}
|
|
770
|
+
ORDER BY table_schema, table_name, ordinal_position;`;
|
|
771
|
+
}
|
|
736
772
|
function buildFilterClause(tables, schemaExpr, tableExpr) {
|
|
737
773
|
if (!tables.length) return "";
|
|
738
774
|
const clauses = tables.map(({ schema, table }) => {
|
|
@@ -2866,7 +2902,7 @@ var QueryPanelSdkAPI = class _QueryPanelSdkAPI {
|
|
|
2866
2902
|
const adapter = new PostgresAdapter(clientFn, options);
|
|
2867
2903
|
const metadata = {
|
|
2868
2904
|
name,
|
|
2869
|
-
dialect:
|
|
2905
|
+
dialect: adapter.getDialect(),
|
|
2870
2906
|
description: options?.description,
|
|
2871
2907
|
tags: options?.tags,
|
|
2872
2908
|
tenantFieldName: options?.tenantFieldName,
|
|
@@ -2878,6 +2914,14 @@ var QueryPanelSdkAPI = class _QueryPanelSdkAPI {
|
|
|
2878
2914
|
};
|
|
2879
2915
|
this.queryEngine.attachDatabase(name, adapter, metadata);
|
|
2880
2916
|
}
|
|
2917
|
+
/**
|
|
2918
|
+
* Attach an Amazon Redshift database. Redshift speaks the Postgres wire
|
|
2919
|
+
* protocol, so `clientFn` can wrap a `pg` client; introspection uses
|
|
2920
|
+
* Redshift's svv_* catalog views and SQL is generated for Redshift.
|
|
2921
|
+
*/
|
|
2922
|
+
attachRedshift(name, clientFn, options) {
|
|
2923
|
+
this.attachPostgres(name, clientFn, { ...options, dialect: "redshift" });
|
|
2924
|
+
}
|
|
2881
2925
|
attachBigQuery(name, clientFn, options) {
|
|
2882
2926
|
const adapter = new BigQueryAdapter(clientFn, options);
|
|
2883
2927
|
const metadata = {
|