Skip to content

Commit

Permalink
[Exporter] better handling of online tables/vsis in listing (#4288)
Browse files Browse the repository at this point in the history
## 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
  • Loading branch information
alexott authored Dec 4, 2024
1 parent f5fce0f commit 76d2659
Showing 1 changed file with 24 additions and 16 deletions.
40 changes: 24 additions & 16 deletions exporter/importables.go
Original file line number Diff line number Diff line change
Expand Up @@ -2747,8 +2747,10 @@ var resourcesMap map[string]importable = map[string]importable{
}, volume.UpdatedAt, fmt.Sprintf("volume '%s'", volume.FullName))
}
}
if ic.isServiceInListing("uc-tables") {
// list tables
isTablesListingEnabled := ic.isServiceInListing("uc-tables")
isOnlineTablesListingEnabled := ic.isServiceInListing("uc-online-tables")
isVectorSearchListingEnabled := ic.isServiceInListing("vector-search")
if isTablesListingEnabled || isOnlineTablesListingEnabled || isVectorSearchListingEnabled {
it := ic.workspaceClient.Tables.List(ic.Context, catalog.ListTablesRequest{
CatalogName: catalogName,
SchemaName: schemaName,
Expand All @@ -2760,25 +2762,31 @@ var resourcesMap map[string]importable = map[string]importable{
}
switch table.TableType {
case "MANAGED", "EXTERNAL", "VIEW":
ic.EmitIfUpdatedAfterMillis(&resource{
Resource: "databricks_sql_table",
ID: table.FullName,
DependsOn: dependsOn,
}, table.UpdatedAt, fmt.Sprintf("table '%s'", table.FullName))
if isTablesListingEnabled {
ic.EmitIfUpdatedAfterMillis(&resource{
Resource: "databricks_sql_table",
ID: table.FullName,
DependsOn: dependsOn,
}, table.UpdatedAt, fmt.Sprintf("table '%s'", table.FullName))
}
case "FOREIGN":
// TODO: it's better to use SecurableKind if it will be added to the Go SDK
switch table.DataSourceFormat {
case "VECTOR_INDEX_FORMAT":
ic.Emit(&resource{
Resource: "databricks_vector_search_index",
ID: table.FullName,
})
if isVectorSearchListingEnabled {
ic.Emit(&resource{
Resource: "databricks_vector_search_index",
ID: table.FullName,
})
}
case "MYSQL_FORMAT":
ic.EmitIfUpdatedAfterMillis(&resource{
Resource: "databricks_online_table",
ID: table.FullName,
DependsOn: dependsOn,
}, table.UpdatedAt, fmt.Sprintf("table '%s'", table.FullName))
if isOnlineTablesListingEnabled {
ic.EmitIfUpdatedAfterMillis(&resource{
Resource: "databricks_online_table",
ID: table.FullName,
DependsOn: dependsOn,
}, table.UpdatedAt, fmt.Sprintf("table '%s'", table.FullName))
}
default:
log.Printf("[DEBUG] Skipping foreign table %s of format %s", table.FullName, table.DataSourceFormat)
}
Expand Down

0 comments on commit 76d2659

Please sign in to comment.