Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix] Add no_wait flag to databricks_online_table to avoid timeouts #4056

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 20 additions & 5 deletions catalog/resource_online_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"errors"
"fmt"
"log"
"time"

"github.com/databricks/databricks-sdk-go"
Expand Down Expand Up @@ -64,6 +65,16 @@ func ResourceOnlineTable() common.Resource {
runTypes := []string{"spec.0.run_triggered", "spec.0.run_continuously"}
common.CustomizeSchemaPath(m, "spec", "run_triggered").SetAtLeastOneOf(runTypes).SetSuppressDiff()
common.CustomizeSchemaPath(m, "spec", "run_continuously").SetAtLeastOneOf(runTypes).SetSuppressDiff()

m["no_wait"] = &schema.Schema{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious -- how useful would this be? My understanding is that it would fail most of the times if waiting for online table creation takes a few minutes. But if this helps some use cases, then I think it might be helpful to have this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need to retest - we have a recent change when the product team added a native wait functionality, but it's not clear how much time we'll still spend on waiting

Type: schema.TypeBool,
Optional: true,
Default: false,
DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool {
return true
},
}

return m
})

Expand All @@ -79,11 +90,15 @@ func ResourceOnlineTable() common.Resource {
if err != nil {
return err
}
// this should be specified in the API Spec - filed a ticket to add it
err = waitForOnlineTableCreation(w, ctx, res.Name)
if err != nil {

return err
noWait := d.Get("no_wait").(bool)
if noWait {
log.Print("[INFO] Not waiting for online table creation")
} else {
// this should be specified in the API Spec - filed a ticket to add it
err = waitForOnlineTableCreation(w, ctx, res.Name)
if err != nil {
return err
}
}
d.SetId(res.Name)
return nil
Expand Down
1 change: 1 addition & 0 deletions docs/resources/online_table.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ In addition to all arguments above, the following attributes are exported:
* `status` - object describing status of the online table:
* `detailed_state` - The state of the online table.
* `message` - A text description of the current state of the online table.
* `no_wait` - optional boolean flag specifying if we shouldn't wait until table update is done. **Note: there is a chance that table could be in failed state if something goes wrong, so use this flag carefully!**

## Import

Expand Down
Loading