Skip to content

feat(cli): make location optional in init and init-creds - #2402

Open
Ford544 wants to merge 3 commits into
mainfrom
location-optional
Open

Ford544 wants to merge 3 commits into
mainfrom
location-optional

Conversation

@Ford544

@Ford544 Ford544 commented Oct 21, 2026

Copy link
Copy Markdown
Collaborator

Make location optional in the init and init-creds commands:

  • the location positional argument for the init command is now optional. If it's not added, generated workflow-settings.yaml will not include location
  • init-creds now allow skipping selecting the location by choosing the "auto" option (in which case the field is not added to the generated .df-credentials.json file)

@Ford544
Ford544 added this pull request to stack #2403 October 21, 2026 12:21
@Ford544
Ford544 requested a review from a team as a code owner October 21, 2026 12:21
@Ford544
Ford544 requested review from a team, apilaskowski, rafal-hawrylak and zaptot and removed request for a team October 21, 2026 12:21
Comment thread cli/credentials.ts
"US (default)",
"EU",
"other",
"auto (let BigQuery choose dynamically)",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With "auto", location is unset, but BigQueryDbAdapter.createSchema still does location || this.bigQueryCredentials.location || "US", and the region-${location}.INFORMATION_SCHEMA.COLUMN_FIELD_PATHS query also falls back to US. So a user with EU data who picks "auto" would get new datasets created in US, and then cross-region queries would fail. Could we either handle the unset location in those paths, or at least say in this label/help text that dataset creation defaults to US?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bigger change that I'm working on, but you are right that the message is misleading as of now - perhaps best to wait with this PR until the automatic location inference is ready

);
}
"The default location to use (optional). If not set, BigQuery chooses the location " +
"dynamically. See https://cloud.google.com/bigquery/docs/locations for supported values.",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"BigQuery chooses the location dynamically" holds for query jobs, but not for dataset creation, which falls back to US in the BigQuery adapter (createSchema). The new README text for default-location / init-creds makes the same claim. Could we reword both (or fix the fallback) so users aren't surprised?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As above, this was written with further changes in mind. I'm going to turn this PR into a draft until that is ready.

Comment thread cli/credentials_test.ts
});
});

test("ADC with auto location leaves location unset", () => {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice coverage. Could you also add tests for (a) "other" with an empty region name, and (b) what the adapter does (e.g. createSchema) when no location is set?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For A, explicitly set location to undefined and print out a warning if empty region name provided. For B, tests were introduced by #2394

Comment thread cli/README.md Outdated
DATAFORM_LINEAGE_DEBUG=1 dataform run --emit-lineage
```

Lineage events are sent to the location set by `defaultLocation` in `workflow_settings.yaml` or, if that is not set, by `location` in `.df-credentials.json`. If neither is set, lineage emission is skipped with a warning and the run proceeds normally.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't seem to match the code: cli/api/lineage/emitter.ts does const location = (this.credentials.location || "US").toLowerCase();, so when neither defaultLocation nor the credentials location is set, lineage is sent to US without a warning rather than skipped. Either this PR needs the skip-and-warn logic, or the README should describe the US fallback.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be changed in the PR that this one is stacked on (#2393)

@apilaskowski
apilaskowski removed the request for review from zaptot October 21, 2026 12:52
@Ford544
Ford544 marked this pull request as draft October 21, 2026 13:23
Base automatically changed from location-fixes to main October 28, 2026 11:29
@Ford544
Ford544 removed this pull request from stack #2403 November 3, 2026 10:47
@Ford544
Ford544 changed the base branch from main to lazy-schema-creation November 3, 2026 10:47
@Ford544
Ford544 added this pull request to stack #2416 November 3, 2026 10:47
@Ford544

Ford544 commented Nov 3, 2026

Copy link
Copy Markdown
Collaborator Author

I rebased this on top of #2408 which actually allows BigQuery to pick the location dynamically, so now the changes to README and CLI prompts are accurate.

@Ford544
Ford544 marked this pull request as ready for review November 3, 2026 11:15
Comment thread cli/credentials.ts
location = "EU";
} else if (locationIndex === 2) {
location = prompts.question("Enter the location's region name (e.g. 'asia-south1'):");
if (!location) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider calling .trim() on prompts.question("Enter the location's region name (e.g. 'asia-south1'):") (matching withServiceAccountToImpersonate below) so whitespace-only input is treated as empty and accidental surrounding spaces are stripped.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment thread cli/README.md
| `--json` | `compile`, `test`, `run` | Requests JSON output instead of human-readable text. |
| `--timeout` | `compile`, `test`, `run` | Bounds project **compilation** time only (default `60s`). |

## Credentials file

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Under ## Credentials file, consider noting that "location" is optional in .df-credentials.json (omitted when "auto" is selected).

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Base automatically changed from lazy-schema-creation to main November 3, 2026 14:06

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants