Skip to content

Respect user's default warehouse override in aitools#4614

Merged
simonfaltum merged 4 commits intomainfrom
simonfaltum/warehouse-override-default
Feb 27, 2026
Merged

Respect user's default warehouse override in aitools#4614
simonfaltum merged 4 commits intomainfrom
simonfaltum/warehouse-override-default

Conversation

@simonfaltum
Copy link
Copy Markdown
Member

@simonfaltum simonfaltum commented Feb 27, 2026

Why

The aitools tools get-default-warehouse command ignores the user's default warehouse override (a per-user preference set via the SQL UI or databricks warehouses create-default-warehouse-override). Users who configured a preferred warehouse still get a different one. Additionally, commands like query and discover-schema fail when the resolved warehouse is stopped.

Changes

Before: the command checked the DATABRICKS_WAREHOUSE_ID env var, then fell through to server-side default detection (which does not incorporate user overrides). Stopped warehouses were returned as-is.

Now:

  • After the env var check, the command queries the user's default warehouse override via GetDefaultWarehouseOverride("default-warehouse-overrides/me"). If a CUSTOM override exists with a valid, non-deleted warehouse, that warehouse is used. All errors silently fall through to existing behavior. LAST_SELECTED overrides are skipped since they require UI state not available from the CLI.
  • GetWarehouseEndpoint and GetWarehouseID accept an autoStart parameter. When true, a stopped warehouse is started and the call blocks until it reaches RUNNING. Enabled for query and discover-schema, disabled for get-default-warehouse and discover.

New resolution priority:

  1. DATABRICKS_WAREHOUSE_ID env var
  2. User's default warehouse override (CUSTOM type only)
  3. Server-side "default" warehouse
  4. First usable warehouse by state

Test plan

  • make test-exp-aitools passes (96 unit tests + 25 acceptance tests)
  • Manual: get-default-warehouse returns existing default when no override is set
  • Manual: set override with create-default-warehouse-override me CUSTOM --warehouse-id <id>, verified get-default-warehouse returns the overridden warehouse
  • Manual: deleted override, verified fallback to original behavior

…house

The aitools get-default-warehouse command now checks the user's
default warehouse override (set via the SQL UI or CLI) before
falling back to server-side default detection. Only CUSTOM overrides
are used; LAST_SELECTED is skipped since it requires UI state.

New priority order:
1. DATABRICKS_WAREHOUSE_ID env var
2. User's default warehouse override (CUSTOM type)
3. Server-side "default" warehouse
4. First usable warehouse by state
If the user's overridden warehouse is in DELETED or DELETING state,
fall through to default detection instead of returning an unusable
warehouse.
If the resolved warehouse is in STOPPED or STOPPING state, start it
and wait for it to reach RUNNING before returning. This applies to
all resolution paths (env var, user override, auto-detection).

Extracts warehouse resolution into resolveWarehouse() for clarity.
GetWarehouseEndpoint and GetWarehouseID now accept an autoStart
parameter. When true, a stopped warehouse is started and the call
blocks until it reaches RUNNING state.

Enabled for query and discover-schema (which need a running
warehouse). Disabled for get-default-warehouse and discover
(which only report warehouse info).
@simonfaltum simonfaltum added this pull request to the merge queue Feb 27, 2026
Merged via the queue into main with commit 299af6c Feb 27, 2026
14 checks passed
@simonfaltum simonfaltum deleted the simonfaltum/warehouse-override-default branch February 27, 2026 13:05
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