Commit 299af6c
authored
Respect user's default warehouse override in aitools (#4614)
## 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
- [x] `make test-exp-aitools` passes (96 unit tests + 25 acceptance
tests)
- [x] Manual: `get-default-warehouse` returns existing default when no
override is set
- [x] Manual: set override with `create-default-warehouse-override me
CUSTOM --warehouse-id <id>`, verified `get-default-warehouse` returns
the overridden warehouse
- [x] Manual: deleted override, verified fallback to original behavior1 parent d00476d commit 299af6c
File tree
5 files changed
+68
-8
lines changed- experimental/aitools
- cmd
- lib
- middlewares
- providers/clitools
5 files changed
+68
-8
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
53 | | - | |
| 53 | + | |
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
46 | | - | |
| 46 | + | |
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
44 | | - | |
| 44 | + | |
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| |||
39 | 40 | | |
40 | 41 | | |
41 | 42 | | |
42 | | - | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
43 | 46 | | |
44 | 47 | | |
45 | 48 | | |
| |||
68 | 71 | | |
69 | 72 | | |
70 | 73 | | |
71 | | - | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
72 | 85 | | |
73 | 86 | | |
74 | | - | |
75 | | - | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
76 | 91 | | |
77 | 92 | | |
78 | 93 | | |
79 | 94 | | |
80 | 95 | | |
81 | 96 | | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
82 | 117 | | |
83 | 118 | | |
84 | 119 | | |
85 | 120 | | |
86 | 121 | | |
| 122 | + | |
| 123 | + | |
87 | 124 | | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
88 | 130 | | |
89 | 131 | | |
90 | 132 | | |
| |||
101 | 143 | | |
102 | 144 | | |
103 | 145 | | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
104 | 164 | | |
105 | 165 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
| 19 | + | |
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| |||
0 commit comments