@sqlanvil/cli 1.36.0 → 1.36.2

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.
Files changed (3) hide show
  1. package/README.md +2 -2
  2. package/bundle.js +35 -13
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -12,7 +12,7 @@ authority for the version you have installed: `sqlanvil help` lists the commands
12
12
 
13
13
  ```bash
14
14
  npm install -g @sqlanvil/cli
15
- sqlanvil --version # sqlanvil 1.36.0 (Dataform core 3.1.0)
15
+ sqlanvil --version # sqlanvil 1.36.2 (Dataform core 3.1.2)
16
16
  ```
17
17
 
18
18
  Requires Node.js 20.19+ or 22.12+. `--version` reports the sqlanvil release and the Dataform core
@@ -349,7 +349,7 @@ exist.
349
349
  | `--environment` | | Load a named environment from `environments:` in `workflow_settings.yaml`. That environment's `schemaSuffix`, `vars`, `defaultDatabase`, `defaultLocation` and `credentials` file apply. See [Named Environments](https://sqlanvil.com/docs/guides/environments/). |
350
350
  | `--default-database` | `defaultProject` | Default database. On BigQuery, the Google Cloud project ID. |
351
351
  | `--default-schema` | `defaultDataset` | Default schema (a dataset on BigQuery). |
352
- | `--default-location` | `defaultLocation` | BigQuery only. Default location, e.g. `US`. |
352
+ | `--default-location` | `defaultLocation` | BigQuery only. Default location, e.g. `US`. `run` and `validate` send BigQuery jobs and create new datasets in this location, even when the credentials file names a different `location` (since 1.36.2; `run` warns about the mismatch). |
353
353
  | `--assertion-schema` | `defaultAssertionDataset` | Schema that assertions are written to. |
354
354
  | `--database-suffix` | `projectSuffix` | Suffix appended to database names. |
355
355
  | `--schema-suffix` | `datasetSuffix` | Suffix appended to schema names, e.g. `dev` gives `analytics_dev`. Letters, digits and underscores only. |
package/bundle.js CHANGED
@@ -55124,8 +55124,8 @@ function requireVersion () {
55124
55124
  hasRequiredVersion = 1;
55125
55125
  Object.defineProperty(version, "__esModule", { value: true });
55126
55126
  version.dataformVersion = version.version = void 0;
55127
- version.version = "1.36.0";
55128
- version.dataformVersion = "3.1.0";
55127
+ version.version = "1.36.2";
55128
+ version.dataformVersion = "3.1.2";
55129
55129
 
55130
55130
  return version;
55131
55131
  }
@@ -57183,8 +57183,9 @@ function requireBigquery () {
57183
57183
  return tablesMetadata;
57184
57184
  }
57185
57185
  async search(searchText, options = { limit: 1000 }) {
57186
+ const location = options.location || this.bigQueryCredentials.location || "US";
57186
57187
  const results = await this.execute(`select table_catalog, table_schema, table_name
57187
- from region-${this.bigQueryCredentials.location}.INFORMATION_SCHEMA.COLUMN_FIELD_PATHS
57188
+ from region-${location}.INFORMATION_SCHEMA.COLUMN_FIELD_PATHS
57188
57189
  where regexp_contains(table_schema, @searchText) or regexp_contains(table_name, @searchText) or regexp_contains(field_path, @searchText)
57189
57190
  group by 1, 2, 3`, {
57190
57191
  params: {
@@ -57192,12 +57193,14 @@ function requireBigquery () {
57192
57193
  },
57193
57194
  interactive: true,
57194
57195
  rowLimit: options.limit,
57196
+ bigquery: { location },
57195
57197
  });
57196
- return await Promise.all(results.rows.map((row) => this.table({
57198
+ const tables = await Promise.all(results.rows.map((row) => this.table({
57197
57199
  database: row.table_catalog,
57198
57200
  schema: row.table_schema,
57199
57201
  name: row.table_name,
57200
57202
  })));
57203
+ return tables.filter((table) => Boolean(table));
57201
57204
  }
57202
57205
  async table(target) {
57203
57206
  var _a;
@@ -57243,8 +57246,8 @@ function requireBigquery () {
57243
57246
  });
57244
57247
  return data[0].map((dataset) => dataset.id);
57245
57248
  }
57246
- async createSchema(database, schema) {
57247
- await this.execute(`create schema if not exists \`${database || this.bigQueryCredentials.projectId}.${schema}\``, { bigquery: { location: this.bigQueryCredentials.location || "US" } });
57249
+ async createSchema(database, schema, location) {
57250
+ await this.execute(`create schema if not exists \`${database || this.bigQueryCredentials.projectId}.${schema}\``, { bigquery: { location: location || this.bigQueryCredentials.location || "US" } });
57248
57251
  }
57249
57252
  async setMetadata(action) {
57250
57253
  const { target, actionDescriptor } = action;
@@ -59241,7 +59244,10 @@ function requireRun () {
59241
59244
  const existingSchemas = new Set(await this.dbadapter.schemas(database));
59242
59245
  await Promise.all(Array.from(schemas)
59243
59246
  .filter((schema) => !existingSchemas.has(schema))
59244
- .map((schema) => this.dbadapter.createSchema(database, schema)));
59247
+ .map((schema) => {
59248
+ var _a;
59249
+ return this.dbadapter.createSchema(database, schema, ((_a = this.graph.projectConfig) === null || _a === void 0 ? void 0 : _a.defaultLocation) || undefined);
59250
+ }));
59245
59251
  }));
59246
59252
  }
59247
59253
  async executeAllActionsReadyForExecution() {
@@ -59341,7 +59347,7 @@ function requireRun () {
59341
59347
  actionResult.timing = timer.current();
59342
59348
  this.notifyListeners();
59343
59349
  await this.dbadapter.withClientLock(async (client) => {
59344
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
59350
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
59345
59351
  for (const task of action.tasks.slice(actionResult.tasks.length)) {
59346
59352
  if (this.stopped) {
59347
59353
  return actionResult;
@@ -59352,10 +59358,11 @@ function requireRun () {
59352
59358
  bigquery: {
59353
59359
  labels: Object.assign(Object.assign({}, (((_b = (_a = this.executionOptions) === null || _a === void 0 ? void 0 : _a.bigquery) === null || _b === void 0 ? void 0 : _b.labels) || {})), (((_c = action.actionDescriptor) === null || _c === void 0 ? void 0 : _c.bigqueryLabels) || {})),
59354
59360
  actionRetryLimit: (_e = (_d = this.executionOptions) === null || _d === void 0 ? void 0 : _d.bigquery) === null || _e === void 0 ? void 0 : _e.actionRetryLimit,
59355
- jobPrefix: (_g = (_f = this.executionOptions) === null || _f === void 0 ? void 0 : _f.bigquery) === null || _g === void 0 ? void 0 : _g.jobPrefix,
59356
- dryRun: (_j = (_h = this.executionOptions) === null || _h === void 0 ? void 0 : _h.bigquery) === null || _j === void 0 ? void 0 : _j.dryRun,
59357
- reservation: ((_k = action.actionDescriptor) === null || _k === void 0 ? void 0 : _k.reservation) ||
59358
- ((_l = this.graph.projectConfig) === null || _l === void 0 ? void 0 : _l.defaultReservation),
59361
+ location: ((_f = this.graph.projectConfig) === null || _f === void 0 ? void 0 : _f.defaultLocation) || undefined,
59362
+ jobPrefix: (_h = (_g = this.executionOptions) === null || _g === void 0 ? void 0 : _g.bigquery) === null || _h === void 0 ? void 0 : _h.jobPrefix,
59363
+ dryRun: (_k = (_j = this.executionOptions) === null || _j === void 0 ? void 0 : _j.bigquery) === null || _k === void 0 ? void 0 : _k.dryRun,
59364
+ reservation: ((_l = action.actionDescriptor) === null || _l === void 0 ? void 0 : _l.reservation) ||
59365
+ ((_m = this.graph.projectConfig) === null || _m === void 0 ? void 0 : _m.defaultReservation),
59359
59366
  },
59360
59367
  }, action);
59361
59368
  if (taskStatus === ts_1.sqlanvil.TaskResult.ExecutionStatus.FAILED) {
@@ -60333,6 +60340,7 @@ function requireConsole () {
60333
60340
  console$1.print = print;
60334
60341
  console$1.printSuccess = printSuccess;
60335
60342
  console$1.printError = printError;
60343
+ console$1.printWarning = printWarning;
60336
60344
  console$1.printInitResult = printInitResult;
60337
60345
  console$1.printInitCredsResult = printInitCredsResult;
60338
60346
  console$1.isInteractive = isInteractive;
@@ -60458,6 +60466,9 @@ function requireConsole () {
60458
60466
  function printError(errorText, indentCount = 0) {
60459
60467
  writeStdErr(errorOutput(errorText), indentCount);
60460
60468
  }
60469
+ function printWarning(warningText, indentCount = 0) {
60470
+ writeStdErr(warningOutput(warningText), indentCount);
60471
+ }
60461
60472
  function printInitResult(result) {
60462
60473
  if (result.dirsCreated && result.dirsCreated.length) {
60463
60474
  writeStdOut(successOutput("Directories successfully created:"));
@@ -66680,7 +66691,7 @@ function requireValidate_command () {
66680
66691
  dbadapter = await mysql_1.MySqlDbAdapter.create(readCredentials);
66681
66692
  }
66682
66693
  else if (warehouse === "bigquery") {
66683
- dbadapter = new bigquery_1.BigQueryDbAdapter(readCredentials);
66694
+ dbadapter = new bigquery_1.BigQueryDbAdapter(Object.assign(Object.assign({}, readCredentials), { location: compiledGraph.projectConfig.defaultLocation || readCredentials.location }));
66684
66695
  }
66685
66696
  else {
66686
66697
  dbadapter = await postgres_1.PostgresDbAdapter.create(readCredentials);
@@ -66869,6 +66880,7 @@ function requireRun_command () {
66869
66880
  ...project_config_options_1.ProjectConfigOptions.allYargsOptions,
66870
66881
  ],
66871
66882
  processFn: async (argv) => {
66883
+ var _a;
66872
66884
  if (argv[common_options_1.jsonOutputOption.name] && !argv[dryRunOptionName]) {
66873
66885
  (0, console_1.print)(`For execution, the --${common_options_1.jsonOutputOption.name} option is only supported if the ` +
66874
66886
  `--${dryRunOptionName} option is enabled`);
@@ -66928,6 +66940,16 @@ function requireRun_command () {
66928
66940
  return (0, validate_command_1.runValidate)(argv);
66929
66941
  }
66930
66942
  const readCredentials = api_1.credentials.read((0, common_options_1.credentialsPathWithEnvironment)(argv[common_options_1.projectDirOption.name], argv), warehouse);
66943
+ const defaultLocation = (_a = compiledGraph.projectConfig) === null || _a === void 0 ? void 0 : _a.defaultLocation;
66944
+ if (warehouse.toLowerCase() === "bigquery" &&
66945
+ !argv[common_options_1.jsonOutputOption.name] &&
66946
+ defaultLocation &&
66947
+ readCredentials.location &&
66948
+ defaultLocation.toLowerCase() !== readCredentials.location.toLowerCase()) {
66949
+ (0, console_1.printWarning)(`Warning: defaultLocation "${defaultLocation}" in the project config differs from ` +
66950
+ `location "${readCredentials.location}" in the credentials file. BigQuery jobs and ` +
66951
+ `new datasets will use "${defaultLocation}".\n`);
66952
+ }
66931
66953
  let dbadapter;
66932
66954
  if (warehouse.toLowerCase() === "supabase") {
66933
66955
  dbadapter = await supabase_1.SupabaseDbAdapter.create(readCredentials);
package/package.json CHANGED
@@ -90,7 +90,7 @@
90
90
  "engines": {
91
91
  "node": "^20.19.0 || >=22.12.0"
92
92
  },
93
- "version": "1.36.0",
93
+ "version": "1.36.2",
94
94
  "name": "@sqlanvil/cli",
95
95
  "description": "sqlanvil command line interface.",
96
96
  "main": "bundle.js"