Skip to content

Commit 76d2659

Browse files
authored
[Exporter] better handling of online tables/vsis in listing (#4288)
## Changes <!-- Summary of your changes that are easy to understand --> Right now, to export vector search indexes and online tables, the `uc-tables` needs to be specified in the listing. This PR removes this limitation by checking if the corresponding service is enabled without requiring `uc-tables` to be enabled as well. ## Tests <!-- How is this tested? Please see the checklist below and also describe any other relevant tests --> - [x] `make test` run locally - [ ] relevant change in `docs/` folder - [ ] covered with integration tests in `internal/acceptance` - [ ] relevant acceptance tests are passing - [ ] using Go SDK
1 parent f5fce0f commit 76d2659

File tree

1 file changed

+24
-16
lines changed

1 file changed

+24
-16
lines changed

exporter/importables.go

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2747,8 +2747,10 @@ var resourcesMap map[string]importable = map[string]importable{
27472747
}, volume.UpdatedAt, fmt.Sprintf("volume '%s'", volume.FullName))
27482748
}
27492749
}
2750-
if ic.isServiceInListing("uc-tables") {
2751-
// list tables
2750+
isTablesListingEnabled := ic.isServiceInListing("uc-tables")
2751+
isOnlineTablesListingEnabled := ic.isServiceInListing("uc-online-tables")
2752+
isVectorSearchListingEnabled := ic.isServiceInListing("vector-search")
2753+
if isTablesListingEnabled || isOnlineTablesListingEnabled || isVectorSearchListingEnabled {
27522754
it := ic.workspaceClient.Tables.List(ic.Context, catalog.ListTablesRequest{
27532755
CatalogName: catalogName,
27542756
SchemaName: schemaName,
@@ -2760,25 +2762,31 @@ var resourcesMap map[string]importable = map[string]importable{
27602762
}
27612763
switch table.TableType {
27622764
case "MANAGED", "EXTERNAL", "VIEW":
2763-
ic.EmitIfUpdatedAfterMillis(&resource{
2764-
Resource: "databricks_sql_table",
2765-
ID: table.FullName,
2766-
DependsOn: dependsOn,
2767-
}, table.UpdatedAt, fmt.Sprintf("table '%s'", table.FullName))
2765+
if isTablesListingEnabled {
2766+
ic.EmitIfUpdatedAfterMillis(&resource{
2767+
Resource: "databricks_sql_table",
2768+
ID: table.FullName,
2769+
DependsOn: dependsOn,
2770+
}, table.UpdatedAt, fmt.Sprintf("table '%s'", table.FullName))
2771+
}
27682772
case "FOREIGN":
27692773
// TODO: it's better to use SecurableKind if it will be added to the Go SDK
27702774
switch table.DataSourceFormat {
27712775
case "VECTOR_INDEX_FORMAT":
2772-
ic.Emit(&resource{
2773-
Resource: "databricks_vector_search_index",
2774-
ID: table.FullName,
2775-
})
2776+
if isVectorSearchListingEnabled {
2777+
ic.Emit(&resource{
2778+
Resource: "databricks_vector_search_index",
2779+
ID: table.FullName,
2780+
})
2781+
}
27762782
case "MYSQL_FORMAT":
2777-
ic.EmitIfUpdatedAfterMillis(&resource{
2778-
Resource: "databricks_online_table",
2779-
ID: table.FullName,
2780-
DependsOn: dependsOn,
2781-
}, table.UpdatedAt, fmt.Sprintf("table '%s'", table.FullName))
2783+
if isOnlineTablesListingEnabled {
2784+
ic.EmitIfUpdatedAfterMillis(&resource{
2785+
Resource: "databricks_online_table",
2786+
ID: table.FullName,
2787+
DependsOn: dependsOn,
2788+
}, table.UpdatedAt, fmt.Sprintf("table '%s'", table.FullName))
2789+
}
27822790
default:
27832791
log.Printf("[DEBUG] Skipping foreign table %s of format %s", table.FullName, table.DataSourceFormat)
27842792
}

0 commit comments

Comments
 (0)