@malloydata/db-bigquery 0.0.393 → 0.0.395
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.
|
@@ -84,7 +84,7 @@ export declare class BigQueryConnection extends BaseConnection implements Connec
|
|
|
84
84
|
downloadMalloyQuery(sqlCommand: string): Promise<ResourceStream<RowMetadata>>;
|
|
85
85
|
private dryRunSQLQuery;
|
|
86
86
|
estimateQueryCost(sqlCommand: string): Promise<QueryRunStats>;
|
|
87
|
-
private
|
|
87
|
+
private decodeTablePathSegments;
|
|
88
88
|
getTableFieldSchema(tablePath: string): Promise<SchemaInfo>;
|
|
89
89
|
executeSQLRaw(sqlCommand: string): Promise<QueryData>;
|
|
90
90
|
test(): Promise<void>;
|
|
@@ -239,17 +239,29 @@ class BigQueryConnection extends connection_1.BaseConnection {
|
|
|
239
239
|
queryCostBytes: Number(dryRunResults.metadata.statistics.totalBytesProcessed),
|
|
240
240
|
};
|
|
241
241
|
}
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
242
|
+
// The whole-backtick form `` `proj.dataset.table` `` parses as one
|
|
243
|
+
// quoted segment, but the metadata API still wants the parts
|
|
244
|
+
// separately — split its decoded body on `.` to recover them.
|
|
245
|
+
decodeTablePathSegments(tablePath) {
|
|
246
|
+
const result = (0, malloy_1.decodeDottedTablePath)(tablePath, {
|
|
247
|
+
quoteChar: '`',
|
|
248
|
+
escapeStyle: 'backslash',
|
|
249
|
+
bareIdentRegex: this.dialect.tablePathBareIdentRegex,
|
|
250
|
+
dialectName: 'BigQuery',
|
|
251
|
+
});
|
|
252
|
+
if (!result.ok)
|
|
253
|
+
return [tablePath];
|
|
254
|
+
if (result.segments.length === 1 && result.segments[0].quoted) {
|
|
255
|
+
return result.segments[0].value.split('.');
|
|
248
256
|
}
|
|
257
|
+
return result.segments.map(s => s.value);
|
|
249
258
|
}
|
|
250
259
|
async getTableFieldSchema(tablePath) {
|
|
251
260
|
var _a, _b, _c, _d;
|
|
252
|
-
|
|
261
|
+
let segments = this.decodeTablePathSegments(tablePath);
|
|
262
|
+
if (segments.length === 2) {
|
|
263
|
+
segments = [this.projectId, ...segments];
|
|
264
|
+
}
|
|
253
265
|
if (segments.length !== 3) {
|
|
254
266
|
throw new Error(`Improper table path: ${tablePath}. A table path requires 2 or 3 segments`);
|
|
255
267
|
}
|
|
@@ -430,7 +442,10 @@ class BigQueryConnection extends connection_1.BaseConnection {
|
|
|
430
442
|
}
|
|
431
443
|
}
|
|
432
444
|
async fetchTableSchema(tableName, tablePath) {
|
|
433
|
-
tablePath
|
|
445
|
+
// Keep the canonical tablePath (which may be backtick-wrapped for
|
|
446
|
+
// wildcard tables) for downstream SQL emission. The metadata lookup
|
|
447
|
+
// wants the unwrapped form, which `getTableFieldSchema` handles via
|
|
448
|
+
// `normalizeTablePath`.
|
|
434
449
|
try {
|
|
435
450
|
const tableFieldSchema = await this.getTableFieldSchema(tablePath);
|
|
436
451
|
const tableDef = {
|
|
@@ -578,9 +593,9 @@ class BigQueryConnection extends connection_1.BaseConnection {
|
|
|
578
593
|
return (0, malloy_1.toAsyncGenerator)(streamBigQuery);
|
|
579
594
|
}
|
|
580
595
|
async fetchTableMetadata(tablePath) {
|
|
581
|
-
const
|
|
596
|
+
const [proj, dataset, table] = this.decodeTablePathSegments(tablePath);
|
|
582
597
|
return {
|
|
583
|
-
url: `https://console.cloud.google.com/bigquery?ws=!1m5!1m4!4m3!1s${
|
|
598
|
+
url: `https://console.cloud.google.com/bigquery?ws=!1m5!1m4!4m3!1s${proj}!2s${dataset}!3s${table}`,
|
|
584
599
|
};
|
|
585
600
|
}
|
|
586
601
|
async close() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@malloydata/db-bigquery",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.395",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"@google-cloud/bigquery": "^7.3.0",
|
|
27
27
|
"@google-cloud/common": "^5.0.1",
|
|
28
28
|
"@google-cloud/paginator": "^5.0.0",
|
|
29
|
-
"@malloydata/malloy": "0.0.
|
|
29
|
+
"@malloydata/malloy": "0.0.395",
|
|
30
30
|
"gaxios": "^4.2.0"
|
|
31
31
|
}
|
|
32
32
|
}
|