@malloydata/db-bigquery 0.0.80-dev230822210650 → 0.0.80-dev230830211713

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,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, QueryRunStats, SQLBlock, StreamingConnection, StructDef } from '@malloydata/malloy';
4
+ import { Connection, MalloyQueryData, PersistSQLResults, PooledConnection, QueryData, QueryDataRow, QueryRunStats, SQLBlock, StreamingConnection, StructDef } from '@malloydata/malloy';
5
5
  export interface BigQueryManagerOptions {
6
6
  credentials?: {
7
7
  clientId: string;
@@ -38,6 +38,7 @@ export declare class BigQueryAuthenticationError extends Error {
38
38
  constructor(message: string);
39
39
  }
40
40
  export declare class BigQueryConnection implements Connection, PersistSQLResults, StreamingConnection {
41
+ private readonly dialect;
41
42
  static DEFAULT_QUERY_OPTIONS: BigQueryQueryOptions;
42
43
  private bigQuery;
43
44
  private projectId;
@@ -49,9 +50,6 @@ export declare class BigQueryConnection implements Connection, PersistSQLResults
49
50
  private config;
50
51
  private location;
51
52
  readonly name: string;
52
- bqToMalloyTypes: {
53
- [key: string]: Partial<FieldTypeDef>;
54
- };
55
53
  constructor(name: string, queryOptions?: QueryOptionsReader, config?: BigQueryConnectionConfiguration);
56
54
  get dialectName(): string;
57
55
  private readQueryOptions;
@@ -89,28 +89,10 @@ const TIMEOUT_MS = 1000 * 60 * 10;
89
89
  // manage access to BQ, control costs, enforce global data/API limits
90
90
  class BigQueryConnection {
91
91
  constructor(name, queryOptions, config = {}) {
92
+ this.dialect = new malloy_1.StandardSQLDialect();
92
93
  this.temporaryTables = new Map();
93
94
  this.schemaCache = new Map();
94
95
  this.sqlSchemaCache = new Map();
95
- this.bqToMalloyTypes = {
96
- 'DATE': { type: 'date' },
97
- 'STRING': { type: 'string' },
98
- 'INTEGER': { type: 'number', numberType: 'integer' },
99
- 'INT64': { type: 'number', numberType: 'integer' },
100
- 'FLOAT': { type: 'number', numberType: 'float' },
101
- 'FLOAT64': { type: 'number', numberType: 'float' },
102
- 'NUMERIC': { type: 'number', numberType: 'float' },
103
- 'BIGNUMERIC': { type: 'number', numberType: 'float' },
104
- 'TIMESTAMP': { type: 'timestamp' },
105
- 'BOOLEAN': { type: 'boolean' },
106
- 'BOOL': { type: 'boolean' },
107
- 'JSON': { type: 'json' },
108
- // TODO (https://cloud.google.com/bigquery/docs/reference/rest/v2/tables#tablefieldschema):
109
- // BYTES
110
- // DATETIME
111
- // TIME
112
- // GEOGRAPHY
113
- };
114
96
  this.name = name;
115
97
  this.bigQuery = new bigquery_1.BigQuery({
116
98
  userAgent: `Malloy/${malloy_1.Malloy.version}`,
@@ -356,6 +338,7 @@ class BigQueryConnection {
356
338
  return job.id;
357
339
  }
358
340
  addFieldsToStructDef(structDef, tableFieldSchema) {
341
+ var _a;
359
342
  if (!tableFieldSchema.fields)
360
343
  return;
361
344
  for (const field of tableFieldSchema.fields) {
@@ -364,7 +347,7 @@ class BigQueryConnection {
364
347
  const name = field.name;
365
348
  // check for an array
366
349
  if (field.mode === 'REPEATED' && !['STRUCT', 'RECORD'].includes(type)) {
367
- const malloyType = this.bqToMalloyTypes[type];
350
+ const malloyType = this.dialect.sqlTypeToMalloyType(type);
368
351
  if (malloyType) {
369
352
  const innerStructDef = {
370
353
  type: 'struct',
@@ -396,7 +379,7 @@ class BigQueryConnection {
396
379
  structDef.fields.push(innerStructDef);
397
380
  }
398
381
  else {
399
- const malloyType = this.bqToMalloyTypes[type] || {
382
+ const malloyType = (_a = this.dialect.sqlTypeToMalloyType(type)) !== null && _a !== void 0 ? _a : {
400
383
  type: 'unsupported',
401
384
  rawType: type.toLowerCase(),
402
385
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@malloydata/db-bigquery",
3
- "version": "0.0.80-dev230822210650",
3
+ "version": "0.0.80-dev230830211713",
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.80-dev230822210650",
28
+ "@malloydata/malloy": "^0.0.80-dev230830211713",
29
29
  "gaxios": "^4.2.0"
30
30
  }
31
31
  }