@@ -2,7 +2,6 @@ package sql_test
22
33import (
44 "fmt"
5- "os"
65 "regexp"
76 "strconv"
87 "testing"
@@ -12,9 +11,6 @@ import (
1211)
1312
1413func TestUcAccResourceSqlTable_Managed (t * testing.T ) {
15- if os .Getenv ("GOOGLE_CREDENTIALS" ) != "" {
16- acceptance .Skipf (t )("databricks_sql_table resource not available on GCP" )
17- }
1814 acceptance .UnityWorkspaceLevel (t , acceptance.Step {
1915 Template : `
2016 resource "databricks_schema" "this" {
@@ -27,6 +23,7 @@ func TestUcAccResourceSqlTable_Managed(t *testing.T) {
2723 catalog_name = "main"
2824 schema_name = databricks_schema.this.name
2925 table_type = "MANAGED"
26+ warehouse_id = "{env.TEST_DEFAULT_WAREHOUSE_ID}"
3027 properties = {
3128 this = "that"
3229 something = "else"
@@ -55,6 +52,7 @@ func TestUcAccResourceSqlTable_Managed(t *testing.T) {
5552 catalog_name = "main"
5653 schema_name = databricks_schema.this.name
5754 table_type = "MANAGED"
55+ warehouse_id = "{env.TEST_DEFAULT_WAREHOUSE_ID}"
5856 properties = {
5957 that = "this"
6058 something = "else2"
@@ -74,9 +72,6 @@ func TestUcAccResourceSqlTable_Managed(t *testing.T) {
7472}
7573
7674func TestUcAccResourceSqlTableWithIdentityColumn_Managed (t * testing.T ) {
77- if os .Getenv ("GOOGLE_CREDENTIALS" ) != "" {
78- acceptance .Skipf (t )("databricks_sql_table resource not available on GCP" )
79- }
8075 acceptance .UnityWorkspaceLevel (t , acceptance.Step {
8176 Template : `
8277 resource "databricks_schema" "this" {
@@ -89,6 +84,7 @@ func TestUcAccResourceSqlTableWithIdentityColumn_Managed(t *testing.T) {
8984 catalog_name = "main"
9085 schema_name = databricks_schema.this.name
9186 table_type = "MANAGED"
87+ warehouse_id = "{env.TEST_DEFAULT_WAREHOUSE_ID}"
9288 properties = {
9389 this = "that"
9490 something = "else"
@@ -118,6 +114,7 @@ func TestUcAccResourceSqlTableWithIdentityColumn_Managed(t *testing.T) {
118114 catalog_name = "main"
119115 schema_name = databricks_schema.this.name
120116 table_type = "MANAGED"
117+ warehouse_id = "{env.TEST_DEFAULT_WAREHOUSE_ID}"
121118 properties = {
122119 that = "this"
123120 something = "else2"
@@ -167,17 +164,19 @@ func TestUcAccResourceSqlTable_External(t *testing.T) {
167164 schema_name = databricks_schema.this.name
168165 table_type = "EXTERNAL"
169166 data_source_format = "DELTA"
170- storage_location = "s3://{env.TEST_BUCKET}/ some{var.RANDOM}"
167+ storage_location = databricks_external_location. some.url
171168 comment = "this table is managed by terraform"
172169 owner = "account users"
170+ warehouse_id = "{env.TEST_DEFAULT_WAREHOUSE_ID}"
171+
172+ depends_on = [
173+ databricks_external_location.some
174+ ]
173175 }` ,
174176 })
175177}
176178
177179func TestUcAccResourceSqlTable_View (t * testing.T ) {
178- if os .Getenv ("GOOGLE_CREDENTIALS" ) != "" {
179- acceptance .Skipf (t )("databricks_sql_table resource not available on GCP" )
180- }
181180 acceptance .UnityWorkspaceLevel (t , acceptance.Step {
182181 Template : `
183182 resource "databricks_schema" "this" {
@@ -193,6 +192,7 @@ func TestUcAccResourceSqlTable_View(t *testing.T) {
193192 data_source_format = "DELTA"
194193 comment = "this table is managed by terraform..."
195194 owner = "account users"
195+ warehouse_id = "{env.TEST_DEFAULT_WAREHOUSE_ID}"
196196
197197 column {
198198 name = "id"
@@ -212,6 +212,7 @@ func TestUcAccResourceSqlTable_View(t *testing.T) {
212212 table_type = "VIEW"
213213 comment = "this view is managed by terraform..."
214214 view_definition = format("SELECT id, name FROM %s", databricks_sql_table.this.id)
215+ warehouse_id = "{env.TEST_DEFAULT_WAREHOUSE_ID}"
215216
216217 column {
217218 name = "id"
@@ -226,24 +227,8 @@ func TestUcAccResourceSqlTable_View(t *testing.T) {
226227}
227228
228229func TestUcAccResourceSqlTable_WarehousePartition (t * testing.T ) {
229- if os .Getenv ("GOOGLE_CREDENTIALS" ) != "" {
230- acceptance .Skipf (t )("databricks_sql_table resource not available on GCP" )
231- }
232230 acceptance .UnityWorkspaceLevel (t , acceptance.Step {
233231 Template : `
234- resource "databricks_sql_endpoint" "this" {
235- name = "tf-{var.RANDOM}"
236- cluster_size = "2X-Small"
237- max_num_clusters = 1
238-
239- tags {
240- custom_tags {
241- key = "Owner"
242- 243- }
244- }
245- }
246-
247232 resource "databricks_schema" "this" {
248233 name = "{var.STICKY_RANDOM}"
249234 catalog_name = "main"
@@ -254,7 +239,7 @@ func TestUcAccResourceSqlTable_WarehousePartition(t *testing.T) {
254239 catalog_name = "main"
255240 schema_name = databricks_schema.this.name
256241 table_type = "MANAGED"
257- warehouse_id = databricks_sql_endpoint.this.id
242+ warehouse_id = "{env.TEST_DEFAULT_WAREHOUSE_ID}"
258243 properties = {
259244 them = "that"
260245 something = "else"
@@ -277,9 +262,6 @@ func TestUcAccResourceSqlTable_WarehousePartition(t *testing.T) {
277262 })
278263}
279264func TestUcAccResourceSqlTable_Liquid (t * testing.T ) {
280- if os .Getenv ("GOOGLE_CREDENTIALS" ) != "" {
281- acceptance .Skipf (t )("databricks_sql_table resource not available on GCP" )
282- }
283265 acceptance .UnityWorkspaceLevel (t , acceptance.Step {
284266 Template : `
285267 resource "databricks_schema" "this" {
@@ -292,6 +274,7 @@ func TestUcAccResourceSqlTable_Liquid(t *testing.T) {
292274 catalog_name = "main"
293275 schema_name = databricks_schema.this.name
294276 table_type = "MANAGED"
277+ warehouse_id = "{env.TEST_DEFAULT_WAREHOUSE_ID}"
295278 properties = {
296279 them = "that"
297280 something = "else"
@@ -323,6 +306,7 @@ func TestUcAccResourceSqlTable_Liquid(t *testing.T) {
323306 catalog_name = "main"
324307 schema_name = databricks_schema.this.name
325308 table_type = "MANAGED"
309+ warehouse_id = "{env.TEST_DEFAULT_WAREHOUSE_ID}"
326310 properties = {
327311 them = "that"
328312 something = "else"
@@ -359,6 +343,7 @@ func constructManagedSqlTableTemplate(tableName string, columnInfos []catalog.Sq
359343 catalog_name = "main"
360344 schema_name = databricks_schema.this.name
361345 table_type = "MANAGED"
346+ warehouse_id = "{env.TEST_DEFAULT_WAREHOUSE_ID}"
362347 properties = {
363348 "this" = "that"
364349 "something" = "else"
@@ -381,9 +366,6 @@ var inlineAndMembershipChangeErrorPattern = "detected changes in both number of
381366var inlineAndMembershipChangeErrorRegex = regexp .MustCompile (inlineAndMembershipChangeErrorPattern )
382367
383368func TestUcAccResourceSqlTable_RenameColumn (t * testing.T ) {
384- if os .Getenv ("GOOGLE_CREDENTIALS" ) != "" {
385- acceptance .Skipf (t )("databricks_sql_table resource not available on GCP" )
386- }
387369 tableName := acceptance .RandomName ()
388370 acceptance .UnityWorkspaceLevel (t , acceptance.Step {
389371 Template : constructManagedSqlTableTemplate (tableName , []catalog.SqlColumnInfo {{Name : "name" , Type : "string" , Nullable : true , Comment : "comment" }}),
@@ -406,9 +388,6 @@ func constructManagedSqlTableTemplateWithColumnTypeUpdates(tableName string, col
406388}
407389
408390func TestUcAccResourceSqlTable_ColumnTypeSuppressDiff (t * testing.T ) {
409- if os .Getenv ("GOOGLE_CREDENTIALS" ) != "" {
410- acceptance .Skipf (t )("databricks_sql_table resource not available on GCP" )
411- }
412391 tableName := acceptance .RandomName ()
413392 columnName := acceptance .RandomName ()
414393 acceptance .UnityWorkspaceLevel (t , acceptance.Step {
@@ -448,9 +427,6 @@ func TestUcAccResourceSqlTable_ColumnTypeSuppressDiff(t *testing.T) {
448427}
449428
450429func TestUcAccResourceSqlTable_AddColumnComment (t * testing.T ) {
451- if os .Getenv ("GOOGLE_CREDENTIALS" ) != "" {
452- acceptance .Skipf (t )("databricks_sql_table resource not available on GCP" )
453- }
454430 tableName := acceptance .RandomName ()
455431 acceptance .UnityWorkspaceLevel (t , acceptance.Step {
456432 Template : constructManagedSqlTableTemplate (tableName , []catalog.SqlColumnInfo {{Name : "name" , Type : "string" , Nullable : true , Comment : "comment" }}),
@@ -460,9 +436,6 @@ func TestUcAccResourceSqlTable_AddColumnComment(t *testing.T) {
460436}
461437
462438func TestUcAccResourceSqlTable_DropColumnNullable (t * testing.T ) {
463- if os .Getenv ("GOOGLE_CREDENTIALS" ) != "" {
464- acceptance .Skipf (t )("databricks_sql_table resource not available on GCP" )
465- }
466439 tableName := acceptance .RandomName ()
467440 acceptance .UnityWorkspaceLevel (t , acceptance.Step {
468441 Template : constructManagedSqlTableTemplate (tableName , []catalog.SqlColumnInfo {{Name : "name" , Type : "string" , Nullable : true , Comment : "comment" }}),
@@ -472,9 +445,6 @@ func TestUcAccResourceSqlTable_DropColumnNullable(t *testing.T) {
472445}
473446
474447func TestUcAccResourceSqlTable_MultipleColumnUpdates (t * testing.T ) {
475- if os .Getenv ("GOOGLE_CREDENTIALS" ) != "" {
476- acceptance .Skipf (t )("databricks_sql_table resource not available on GCP" )
477- }
478448 tableName := acceptance .RandomName ()
479449 acceptance .UnityWorkspaceLevel (t , acceptance.Step {
480450 Template : constructManagedSqlTableTemplate (tableName , []catalog.SqlColumnInfo {{Name : "name" , Type : "string" , Nullable : true , Comment : "comment" }}),
@@ -484,9 +454,6 @@ func TestUcAccResourceSqlTable_MultipleColumnUpdates(t *testing.T) {
484454}
485455
486456func TestUcAccResourceSqlTable_ChangeColumnTypeThrows (t * testing.T ) {
487- if os .Getenv ("GOOGLE_CREDENTIALS" ) != "" {
488- acceptance .Skipf (t )("databricks_sql_table resource not available on GCP" )
489- }
490457 tableName := acceptance .RandomName ()
491458
492459 acceptance .UnityWorkspaceLevel (t , acceptance.Step {
@@ -498,9 +465,6 @@ func TestUcAccResourceSqlTable_ChangeColumnTypeThrows(t *testing.T) {
498465}
499466
500467func TestUcAccResourceSqlTable_DropColumn (t * testing.T ) {
501- if os .Getenv ("GOOGLE_CREDENTIALS" ) != "" {
502- acceptance .Skipf (t )("databricks_sql_table resource not available on GCP" )
503- }
504468 tableName := acceptance .RandomName ()
505469 acceptance .UnityWorkspaceLevel (t , acceptance.Step {
506470 Template : constructManagedSqlTableTemplate (tableName , []catalog.SqlColumnInfo {
@@ -513,9 +477,6 @@ func TestUcAccResourceSqlTable_DropColumn(t *testing.T) {
513477}
514478
515479func TestUcAccResourceSqlTable_DropMultipleColumns (t * testing.T ) {
516- if os .Getenv ("GOOGLE_CREDENTIALS" ) != "" {
517- acceptance .Skipf (t )("databricks_sql_table resource not available on GCP" )
518- }
519480 tableName := acceptance .RandomName ()
520481 acceptance .UnityWorkspaceLevel (t , acceptance.Step {
521482 Template : constructManagedSqlTableTemplate (tableName , []catalog.SqlColumnInfo {
@@ -529,9 +490,6 @@ func TestUcAccResourceSqlTable_DropMultipleColumns(t *testing.T) {
529490}
530491
531492func TestUcAccResourceSqlTable_AddColumn (t * testing.T ) {
532- if os .Getenv ("GOOGLE_CREDENTIALS" ) != "" {
533- acceptance .Skipf (t )("databricks_sql_table resource not available on GCP" )
534- }
535493 tableName := acceptance .RandomName ()
536494 acceptance .UnityWorkspaceLevel (t , acceptance.Step {
537495 Template : constructManagedSqlTableTemplate (tableName , []catalog.SqlColumnInfo {{Name : "name" , Type : "string" , Nullable : true , Comment : "comment" }}),
@@ -544,9 +502,6 @@ func TestUcAccResourceSqlTable_AddColumn(t *testing.T) {
544502}
545503
546504func TestUcAccResourceSqlTable_AddMultipleColumns (t * testing.T ) {
547- if os .Getenv ("GOOGLE_CREDENTIALS" ) != "" {
548- acceptance .Skipf (t )("databricks_sql_table resource not available on GCP" )
549- }
550505 tableName := acceptance .RandomName ()
551506 acceptance .UnityWorkspaceLevel (t , acceptance.Step {
552507 Template : constructManagedSqlTableTemplate (tableName , []catalog.SqlColumnInfo {{Name : "name" , Type : "string" , Nullable : true , Comment : "comment" }}),
@@ -560,10 +515,6 @@ func TestUcAccResourceSqlTable_AddMultipleColumns(t *testing.T) {
560515}
561516
562517func TestUcAccResourceSqlTable_AddColumnAndUpdateThrows (t * testing.T ) {
563- if os .Getenv ("GOOGLE_CREDENTIALS" ) != "" {
564- acceptance .Skipf (t )("databricks_sql_table resource not available on GCP" )
565- }
566-
567518 tableName := acceptance .RandomName ()
568519 acceptance .UnityWorkspaceLevel (t , acceptance.Step {
569520 Template : constructManagedSqlTableTemplate (tableName , []catalog.SqlColumnInfo {{Name : "name" , Type : "string" , Nullable : true , Comment : "comment" }}),
@@ -577,10 +528,6 @@ func TestUcAccResourceSqlTable_AddColumnAndUpdateThrows(t *testing.T) {
577528}
578529
579530func TestUcAccResourceSqlTable_DropColumnAndUpdateThrows (t * testing.T ) {
580- if os .Getenv ("GOOGLE_CREDENTIALS" ) != "" {
581- acceptance .Skipf (t )("databricks_sql_table resource not available on GCP" )
582- }
583-
584531 tableName := acceptance .RandomName ()
585532 acceptance .UnityWorkspaceLevel (t , acceptance.Step {
586533 Template : constructManagedSqlTableTemplate (tableName , []catalog.SqlColumnInfo {
0 commit comments