Skip to content

Commit de2f6c5

Browse files
authored
fix(db_sql_warehouse): forward tags to the API (#240)
1 parent 0b0331c commit de2f6c5

3 files changed

Lines changed: 10 additions & 5 deletions

File tree

NEWS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
- Fixed `git_source()` erroring when `type` was left at its default
44
- Fixed Unity Catalog volume file requests so `db_volume_*` paths containing spaces are encoded correctly (#231)
55
- `db_cluster_events()` now forwards the `event_types` argument to the API, which was previously ignored
6+
- `db_sql_warehouse_create()` and `db_sql_warehouse_edit()` now forward the `tags` argument to the API, which was previously ignored
67
- `db_uc_volumes_list()` now forwards the `max_results`, `include_browse`, and `page_token` arguments to the API, which were previously ignored
78
- `db_vs_indexes_query()` now sends the `score_threshold` argument to the API, which was previously ignored
89
- Added `show_progress` to `dbConnect()` for the DBI backend; `dbGetQuery()`, `dbFetch()`, `dbWriteTable()`, and dbplyr `collect()` now use the connection default while preserving per-call `show_progress` overrides (#223)

R/warehouses.R

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ db_sql_warehouse_create <- function(
7979
min_num_clusters = min_num_clusters,
8080
max_num_clusters = max_num_clusters,
8181
auto_stop_mins = auto_stop_mins,
82+
tags = tags,
8283
spot_instance_policy = spot_instance_policy,
8384
enable_photon = enable_photon,
8485
warehouse_type = warehouse_type,
@@ -195,6 +196,7 @@ db_sql_warehouse_edit <- function(
195196
min_num_clusters = min_num_clusters,
196197
max_num_clusters = max_num_clusters,
197198
auto_stop_mins = auto_stop_mins,
199+
tags = tags,
198200
spot_instance_policy = spot_instance_policy,
199201
enable_photon = enable_photon,
200202
warehouse_type = warehouse_type,

tests/testthat/test-warehouses.R

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
test_that("Warehouse API - don't perform", {
2-
32
withr::local_envvar(c(
43
"DATABRICKS_HOST" = "http://mock_host",
54
"DATABRICKS_TOKEN" = "mock_token"
@@ -11,13 +10,17 @@ test_that("Warehouse API - don't perform", {
1110
resp_global_get <- db_sql_global_warehouse_get(perform_request = FALSE)
1211
expect_s3_class(resp_global_get, "httr2_request")
1312

13+
tags <- list(custom_tags = list(list(key = "team", value = "data")))
14+
1415
resp_create <- db_sql_warehouse_create(
1516
name = "brickster_test_warehouse",
1617
cluster_size = "2X-Small",
1718
enable_serverless_compute = TRUE,
19+
tags = tags,
1820
perform_request = FALSE
1921
)
2022
expect_s3_class(resp_create, "httr2_request")
23+
expect_identical(resp_create$body$data$tags, tags)
2124

2225
resp_get <- db_sql_warehouse_get(
2326
id = "some_warehouse_id",
@@ -34,13 +37,15 @@ test_that("Warehouse API - don't perform", {
3437
resp_edit <- db_sql_warehouse_edit(
3538
id = "some_warehouse_id",
3639
name = "some_warehouse_name",
37-
cluster_size = "2X-Small",
40+
cluster_size = "2X-Small",
3841
spot_instance_policy = "COST_OPTIMIZED",
3942
channel = "CHANNEL_NAME_CURRENT",
4043
warehouse_type = "PRO",
44+
tags = tags,
4145
perform_request = FALSE
4246
)
4347
expect_s3_class(resp_edit, "httr2_request")
48+
expect_identical(resp_edit$body$data$tags, tags)
4449

4550
resp_start <- db_sql_warehouse_start(
4651
id = "some_warehouse_id",
@@ -53,15 +58,13 @@ test_that("Warehouse API - don't perform", {
5358
perform_request = FALSE
5459
)
5560
expect_s3_class(resp_delete, "httr2_request")
56-
5761
})
5862

5963
skip_on_cran()
6064
skip_unless_authenticated()
6165
skip_unless_aws_workspace()
6266

6367
test_that("Warehouse API", {
64-
6568
random_id <- sample.int(100000, 1)
6669

6770
expect_no_error({
@@ -138,5 +141,4 @@ test_that("Warehouse API", {
138141
})
139142
expect_type(resp_delete, "list")
140143
expect_length(resp_delete, 0L)
141-
142144
})

0 commit comments

Comments
 (0)