@lightdash/warehouses 2.263.1 → 2.264.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 +1 @@
1
- {"version":3,"file":"RedshiftWarehouseClient.d.ts","sourceRoot":"","sources":["../../src/warehouseClients/RedshiftWarehouseClient.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,OAAO,EACP,yBAAyB,EAGzB,mBAAmB,EACnB,gBAAgB,EAChB,gBAAgB,EAChB,cAAc,EACjB,MAAM,mBAAmB,CAAC;AAI3B,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAsC/E,qBAAa,kBAAmB,SAAQ,kBAAkB;IACtD,IAAI,iBAA2B;IAE/B,cAAc,IAAI,mBAAmB,CAEpC;CACJ;AAED,qBAAa,uBAAwB,SAAQ,cAAc,CAAC,yBAAyB,CAAC;IAClF,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAoB;IAExC,OAAO,CAAC,mBAAmB,CAEX;IAEhB,YAAY,WAAW,EAAE,yBAAyB,EA8BjD;IAED,OAAO,CAAC,MAAM,CAAC,mBAAmB;IAgB5B,WAAW,CACb,GAAG,EAAE,MAAM,EACX,cAAc,EAAE,CAAC,IAAI,EAAE,gBAAgB,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,EAChE,OAAO,EAAE;QACL,MAAM,CAAC,EAAE,OAAO,EAAE,CAAC;QACnB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAC9B,QAAQ,CAAC,EAAE,MAAM,CAAC;KACrB,GACF,OAAO,CAAC,IAAI,CAAC,CAUf;IAKK,YAAY;;;;;SAkBjB;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,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4BrC"}
@@ -121,25 +121,25 @@ class RedshiftWarehouseClient extends PostgresWarehouseClient_1.PostgresClient {
121
121
  }
122
122
  return super.streamQuery(sql, streamCallback, options);
123
123
  }
124
- // information_schema omits late-binding views and Spectrum external tables;
125
- // the SVV_* views cover them alongside regular tables and views. A Redshift
126
- // project pointed at plain Postgres keeps the Postgres catalog.
124
+ // SVV_ALL_* are grant-filtered catalog views; SVV_TABLES and SVV_COLUMNS are
125
+ // visible to all users unless metadata_security is on. Keep SVV_COLUMNS for
126
+ // late-binding view columns, gated on SVV_ALL_TABLES. Plain Postgres keeps its catalog.
127
127
  async getAllTables() {
128
128
  if (!(await this.isRedshift()))
129
129
  return super.getAllTables();
130
130
  const query = `
131
- SELECT table_catalog, table_schema, table_name, table_type
132
- FROM svv_tables
133
- WHERE table_catalog = $1
134
- AND table_schema NOT IN ('information_schema', 'pg_catalog', 'pg_internal')
131
+ SELECT database_name, schema_name, table_name, table_type
132
+ FROM svv_all_tables
133
+ WHERE database_name = $1
134
+ AND schema_name NOT IN ('information_schema', 'pg_catalog', 'pg_internal')
135
135
  ORDER BY 1, 2, 3
136
136
  `;
137
137
  const { rows } = await this.runQuery(query, {}, undefined, [
138
138
  this.credentials.dbname,
139
139
  ]);
140
140
  return rows.map((row) => ({
141
- database: row.table_catalog,
142
- schema: row.table_schema,
141
+ database: row.database_name,
142
+ schema: row.schema_name,
143
143
  table: row.table_name,
144
144
  tableType: (0, common_1.getWarehouseTableType)(row.table_type),
145
145
  }));
@@ -150,16 +150,20 @@ class RedshiftWarehouseClient extends PostgresWarehouseClient_1.PostgresClient {
150
150
  }
151
151
  const { values, schemaParam, databaseParam } = this.bindFieldsFilters(tableName, schema, database);
152
152
  const query = `
153
- SELECT table_catalog,
154
- table_schema,
155
- table_name,
156
- column_name,
157
- data_type
158
- FROM svv_columns
159
- WHERE table_name = $1
160
- ${schemaParam ? `AND table_schema = ${schemaParam}` : ''}
161
- ${databaseParam ? `AND table_catalog = ${databaseParam}` : ''}
162
- ORDER BY ordinal_position
153
+ SELECT c.table_catalog,
154
+ c.table_schema,
155
+ c.table_name,
156
+ c.column_name,
157
+ c.data_type
158
+ FROM svv_columns c
159
+ JOIN svv_all_tables t
160
+ ON t.database_name = c.table_catalog
161
+ AND t.schema_name = c.table_schema
162
+ AND t.table_name = c.table_name
163
+ WHERE c.table_name = $1
164
+ ${schemaParam ? `AND c.table_schema = ${schemaParam}` : ''}
165
+ ${databaseParam ? `AND c.table_catalog = ${databaseParam}` : ''}
166
+ ORDER BY c.ordinal_position
163
167
  `;
164
168
  const { rows } = await this.runQuery(query, tags, undefined, values);
165
169
  return this.parsePostgresCatalog(rows);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lightdash/warehouses",
3
- "version": "2.263.1",
3
+ "version": "2.264.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": "2.263.1",
24
+ "@lightdash/common": "2.264.0",
25
25
  "node-fetch": "2.7.0",
26
26
  "pg": "8.13.1",
27
27
  "pg-cursor": "2.10.0",