Skip to content

Commit ad0bd09

Browse files
authored
[Fix] Revert partition read in databricks_sql_table (#4536)
## Changes Revert #4486 to resolve #4535 ## Tests <!-- How is this tested? Please see the checklist below and also describe any other relevant tests --> - [x] `make test` run locally NO_CHANGELOG=true
1 parent 9040cb9 commit ad0bd09

File tree

2 files changed

+0
-184
lines changed

2 files changed

+0
-184
lines changed

catalog/resource_sql_table.go

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77
"log"
88
"reflect"
99
"slices"
10-
"sort"
1110
"strings"
1211
"time"
1312

@@ -669,42 +668,13 @@ func ResourceSqlTable() common.Resource {
669668
if err != nil {
670669
return err
671670
}
672-
w, err := c.WorkspaceClient()
673-
if err != nil {
674-
return err
675-
}
676-
partitionInfo, err := w.Tables.GetByFullName(ctx, d.Id())
677-
if err != nil {
678-
return err
679-
}
680-
partitionIndexes := map[int]string{}
681671
for i := range ti.ColumnInfos {
682672
c := &ti.ColumnInfos[i]
683673
c.Identity, err = reconstructIdentity(c)
684674
if err != nil {
685675
return err
686676
}
687677
}
688-
689-
for i := range partitionInfo.Columns {
690-
c := &partitionInfo.Columns[i]
691-
if slices.Contains(c.ForceSendFields, "PartitionIndex") {
692-
partitionIndexes[c.PartitionIndex] = c.Name
693-
}
694-
}
695-
indexes := []int{}
696-
partitions := []string{}
697-
698-
for index := range partitionIndexes {
699-
indexes = append(indexes, index)
700-
}
701-
sort.Ints(indexes)
702-
703-
for _, p := range indexes {
704-
partitions = append(partitions, partitionIndexes[p])
705-
}
706-
707-
d.Set("partitions", partitions)
708678
return common.StructToData(ti, tableSchema, d)
709679
},
710680
Update: func(ctx context.Context, d *schema.ResourceData, c *common.DatabricksClient) error {

catalog/resource_sql_table_test.go

Lines changed: 0 additions & 154 deletions
Original file line numberDiff line numberDiff line change
@@ -229,11 +229,6 @@ func TestResourceSqlTableCreateTable(t *testing.T) {
229229
},
230230
},
231231
},
232-
{
233-
Method: "GET",
234-
Resource: "/api/2.1/unity-catalog/tables/main.foo.bar?",
235-
Response: catalog.TableInfo{},
236-
},
237232
}, useExistingClusterForSql...),
238233
Create: true,
239234
Resource: ResourceSqlTable(),
@@ -309,11 +304,6 @@ func TestResourceSqlTableCreateTableWithOwner(t *testing.T) {
309304
},
310305
},
311306
},
312-
{
313-
Method: "GET",
314-
Resource: "/api/2.1/unity-catalog/tables/main.foo.bar?",
315-
Response: catalog.TableInfo{},
316-
},
317307
}, useExistingClusterForSql...),
318308
Create: true,
319309
Resource: ResourceSqlTable(),
@@ -436,11 +426,6 @@ func TestResourceSqlTableUpdateTable(t *testing.T) {
436426
},
437427
},
438428
},
439-
{
440-
Method: "GET",
441-
Resource: "/api/2.1/unity-catalog/tables/main.foo.bar?",
442-
Response: catalog.TableInfo{},
443-
},
444429
{
445430
Method: "POST",
446431
Resource: "/api/2.0/clusters/start",
@@ -542,11 +527,6 @@ func TestResourceSqlTableUpdateTableAndOwner(t *testing.T) {
542527
Owner: "old group",
543528
},
544529
},
545-
{
546-
Method: "GET",
547-
Resource: "/api/2.1/unity-catalog/tables/main.foo.bar?",
548-
Response: catalog.TableInfo{},
549-
},
550530
{
551531
Method: "POST",
552532
Resource: "/api/2.0/clusters/start",
@@ -643,11 +623,6 @@ func TestResourceSqlTableUpdateTableClusterKeys(t *testing.T) {
643623
},
644624
},
645625
},
646-
{
647-
Method: "GET",
648-
Resource: "/api/2.1/unity-catalog/tables/main.foo.bar?",
649-
Response: catalog.TableInfo{},
650-
},
651626
{
652627
Method: "POST",
653628
Resource: "/api/2.0/clusters/start",
@@ -738,11 +713,6 @@ func TestResourceSqlTableUpdateView(t *testing.T) {
738713
},
739714
},
740715
},
741-
{
742-
Method: "GET",
743-
Resource: "/api/2.1/unity-catalog/tables/main.foo.bar?",
744-
Response: catalog.TableInfo{},
745-
},
746716
{
747717
Method: "POST",
748718
Resource: "/api/2.0/clusters/start",
@@ -852,11 +822,6 @@ func TestResourceSqlTableUpdateView_Definition(t *testing.T) {
852822
ViewDefinition: "SELECT * FROM main.foo.bar2",
853823
},
854824
},
855-
{
856-
Method: "GET",
857-
Resource: "/api/2.1/unity-catalog/tables/main.foo.barview?",
858-
Response: catalog.TableInfo{},
859-
},
860825
{
861826
Method: "POST",
862827
Resource: "/api/2.0/clusters/start",
@@ -912,11 +877,6 @@ func TestResourceSqlTableUpdateView_Comments(t *testing.T) {
912877
Comment: "to be changed (requires new)",
913878
},
914879
},
915-
{
916-
Method: "GET",
917-
Resource: "/api/2.1/unity-catalog/tables/main.foo.barview?",
918-
Response: catalog.TableInfo{},
919-
},
920880
{
921881
Method: "POST",
922882
Resource: "/api/2.0/clusters/start",
@@ -1009,11 +969,6 @@ func resourceSqlTableUpdateColumnHelper(t *testing.T, testMetaData resourceSqlTa
1009969
ColumnInfos: testMetaData.oldColumns,
1010970
},
1011971
},
1012-
{
1013-
Method: "GET",
1014-
Resource: "/api/2.1/unity-catalog/tables/main.foo.bar?",
1015-
Response: catalog.TableInfo{},
1016-
},
1017972
{
1018973
Method: "POST",
1019974
Resource: "/api/2.0/clusters/start",
@@ -1402,11 +1357,6 @@ func TestResourceSqlTableCreateTable_ExistingSQLWarehouse(t *testing.T) {
14021357
},
14031358
},
14041359
},
1405-
{
1406-
Method: "GET",
1407-
Resource: "/api/2.1/unity-catalog/tables/main.foo.bar?",
1408-
Response: catalog.TableInfo{},
1409-
},
14101360
},
14111361
Create: true,
14121362
Resource: ResourceSqlTable(),
@@ -1500,11 +1450,6 @@ func TestResourceSqlTableCreateTableWithIdentityColumn_ExistingSQLWarehouse(t *t
15001450
},
15011451
},
15021452
},
1503-
{
1504-
Method: "GET",
1505-
Resource: "/api/2.1/unity-catalog/tables/main.foo.bar?",
1506-
Response: catalog.TableInfo{},
1507-
},
15081453
},
15091454
Create: true,
15101455
Resource: ResourceSqlTable(),
@@ -1571,99 +1516,6 @@ func TestResourceSqlTableReadTableWithIdentityColumn_ExistingSQLWarehouse(t *tes
15711516
},
15721517
},
15731518
},
1574-
{
1575-
Method: "GET",
1576-
Resource: "/api/2.1/unity-catalog/tables/main.foo.bar?",
1577-
Response: catalog.TableInfo{},
1578-
},
1579-
},
1580-
ID: "main.foo.bar",
1581-
Read: true,
1582-
Resource: ResourceSqlTable(),
1583-
}.ApplyAndExpectData(t, map[string]any{
1584-
"column.0.identity": "always",
1585-
"column.1.identity": "",
1586-
"column.2.identity": "default",
1587-
})
1588-
}
1589-
1590-
func TestResourceSqlTableReadTableWithPartitionColumn_ExistingSQLWarehouse(t *testing.T) {
1591-
qa.ResourceFixture{
1592-
CommandMock: func(commandStr string) common.CommandResults {
1593-
return common.CommandResults{
1594-
ResultType: "",
1595-
Data: nil,
1596-
}
1597-
},
1598-
HCL: `
1599-
name = "bar"
1600-
catalog_name = "main"
1601-
schema_name = "foo"
1602-
table_type = "MANAGED"
1603-
data_source_format = "DELTA"
1604-
storage_location = "abfss://container@account/somepath"
1605-
warehouse_id = "existingwarehouse"
1606-
1607-
1608-
comment = "this table is managed by terraform"
1609-
`,
1610-
Fixtures: []qa.HTTPFixture{
1611-
{
1612-
Method: "GET",
1613-
Resource: "/api/2.1/unity-catalog/tables/main.foo.bar",
1614-
Response: SqlTableInfo{
1615-
Name: "bar",
1616-
CatalogName: "main",
1617-
SchemaName: "foo",
1618-
TableType: "EXTERNAL",
1619-
DataSourceFormat: "DELTA",
1620-
StorageLocation: "s3://ext-main/foo/bar1",
1621-
StorageCredentialName: "somecred",
1622-
Comment: "terraform managed",
1623-
Properties: map[string]string{
1624-
"one": "two",
1625-
"three": "four",
1626-
},
1627-
ColumnInfos: []SqlColumnInfo{
1628-
{
1629-
Name: "id",
1630-
Type: "bigint",
1631-
TypeJson: "{\"type\":\"bigint\",\"nullable\":true, \"metadata\":{\"delta.identity.start\":1,\"delta.identity.allowExplicitInsert\":false}}",
1632-
},
1633-
{
1634-
Name: "name",
1635-
Type: "string",
1636-
Comment: "name of thing",
1637-
},
1638-
{
1639-
Name: "number",
1640-
Type: "bigint",
1641-
TypeJson: "{\"type\":\"bigint\",\"nullable\":true, \"metadata\":{\"delta.identity.start\":1,\"delta.identity.allowExplicitInsert\":true}}",
1642-
},
1643-
},
1644-
},
1645-
},
1646-
{
1647-
Method: "GET",
1648-
Resource: "/api/2.1/unity-catalog/tables/main.foo.bar?",
1649-
Response: catalog.TableInfo{
1650-
Columns: []catalog.ColumnInfo{
1651-
{
1652-
Name: "id",
1653-
PartitionIndex: 1,
1654-
ForceSendFields: []string{"PartitionIndex"},
1655-
},
1656-
{
1657-
Name: "name",
1658-
PartitionIndex: 0,
1659-
ForceSendFields: []string{"PartitionIndex"},
1660-
},
1661-
{
1662-
Name: "number",
1663-
},
1664-
},
1665-
},
1666-
},
16671519
},
16681520
ID: "main.foo.bar",
16691521
Read: true,
@@ -1672,7 +1524,6 @@ func TestResourceSqlTableReadTableWithPartitionColumn_ExistingSQLWarehouse(t *te
16721524
"column.0.identity": "always",
16731525
"column.1.identity": "",
16741526
"column.2.identity": "default",
1675-
"partitions": []any{"name", "id"},
16761527
})
16771528
}
16781529

@@ -1736,11 +1587,6 @@ func TestResourceSqlTableCreateTable_OnlyManagedProperties(t *testing.T) {
17361587
},
17371588
},
17381589
},
1739-
{
1740-
Method: "GET",
1741-
Resource: "/api/2.1/unity-catalog/tables/main.foo.bar?",
1742-
Response: catalog.TableInfo{},
1743-
},
17441590
},
17451591
Create: true,
17461592
Resource: ResourceSqlTable(),

0 commit comments

Comments
 (0)