@malloydata/db-bigquery 0.0.38-dev230601002801 → 0.0.38-dev230605182241
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/dist/bigquery.spec.js
CHANGED
|
@@ -69,8 +69,8 @@ describe('db:BigQuery', () => {
|
|
|
69
69
|
expect(res.rows[0]['t']).toBe(1);
|
|
70
70
|
});
|
|
71
71
|
it('costs a SQL query', async () => {
|
|
72
|
-
const res = await bq.
|
|
73
|
-
expect(res).toBe(3029200);
|
|
72
|
+
const res = await bq.estimateQueryCost('SELECT * FROM malloy-data.faa.airports');
|
|
73
|
+
expect(res.queryCostBytes).toBe(3029200);
|
|
74
74
|
});
|
|
75
75
|
it('gets table schema', async () => {
|
|
76
76
|
const res = await bq.getTableFieldSchema('malloy-data.faa.carriers');
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { RowMetadata } from '@google-cloud/bigquery';
|
|
2
2
|
import bigquery from '@google-cloud/bigquery/build/src/types';
|
|
3
3
|
import { ResourceStream } from '@google-cloud/paginator';
|
|
4
|
-
import { Connection, FieldTypeDef, MalloyQueryData, PersistSQLResults, PooledConnection, QueryData, QueryDataRow, SQLBlock, StreamingConnection, StructDef } from '@malloydata/malloy';
|
|
4
|
+
import { Connection, FieldTypeDef, MalloyQueryData, PersistSQLResults, PooledConnection, QueryData, QueryDataRow, QueryRunStats, SQLBlock, StreamingConnection, StructDef } from '@malloydata/malloy';
|
|
5
5
|
export interface BigQueryManagerOptions {
|
|
6
6
|
credentials?: {
|
|
7
7
|
clientId: string;
|
|
@@ -68,7 +68,7 @@ export declare class BigQueryConnection implements Connection, PersistSQLResults
|
|
|
68
68
|
}>;
|
|
69
69
|
downloadMalloyQuery(sqlCommand: string): Promise<ResourceStream<RowMetadata>>;
|
|
70
70
|
private dryRunSQLQuery;
|
|
71
|
-
|
|
71
|
+
estimateQueryCost(sqlCommand: string): Promise<QueryRunStats>;
|
|
72
72
|
structDefFromSQL(sqlCommand: string): Promise<StructDef>;
|
|
73
73
|
getTableFieldSchema(tableURL: string): Promise<SchemaInfo>;
|
|
74
74
|
executeSQLRaw(sqlCommand: string): Promise<QueryData>;
|
|
@@ -213,9 +213,11 @@ class BigQueryConnection {
|
|
|
213
213
|
throw maybeRewriteError(e);
|
|
214
214
|
}
|
|
215
215
|
}
|
|
216
|
-
async
|
|
216
|
+
async estimateQueryCost(sqlCommand) {
|
|
217
217
|
const dryRunResults = await this.dryRunSQLQuery(sqlCommand);
|
|
218
|
-
return
|
|
218
|
+
return {
|
|
219
|
+
queryCostBytes: Number(dryRunResults.metadata.statistics.totalBytesProcessed),
|
|
220
|
+
};
|
|
219
221
|
}
|
|
220
222
|
async structDefFromSQL(sqlCommand) {
|
|
221
223
|
const dryRunResults = await this.dryRunSQLQuery(sqlCommand);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@malloydata/db-bigquery",
|
|
3
|
-
"version": "0.0.38-
|
|
3
|
+
"version": "0.0.38-dev230605182241",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"@google-cloud/bigquery": "^5.5.0",
|
|
26
26
|
"@google-cloud/common": "^3.6.0",
|
|
27
27
|
"@google-cloud/paginator": "^4.0.1",
|
|
28
|
-
"@malloydata/malloy": "^0.0.38-
|
|
28
|
+
"@malloydata/malloy": "^0.0.38-dev230605182241",
|
|
29
29
|
"gaxios": "^4.2.0"
|
|
30
30
|
}
|
|
31
31
|
}
|