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

[ISSUE] Empty lines or tabs inside SQL query of view definition will trigger redeployment of databricks_sql_table resource #3865

Open
p-venclovas opened this issue Aug 8, 2024 · 1 comment

Comments

@p-venclovas
Copy link

p-venclovas commented Aug 8, 2024

Configuration

resource "databricks_sql_table" "test_view" {
  provider                = databricks.workspace
  cluster_id              = data.databricks_cluster.test_cluster.id
  catalog_name            = "test"
  schema_name             = "test"
  name                    = "view_test"
  table_type              = "VIEW"
  view_definition = "select 1,\n\n\n\2,\t3"
}

Expected Behavior

After initial terraform apply, resource would be deployed. Running terraform plan afterwards, no changes should be detected in the resource.

Actual Behavior

After initial terraform apply, resource was deployed. Running terraform plan afterwards, changes were detected in the view definition.

View definition read and returned by the provider looks like: "select 1,\n2, 3" thus changes in the view_definition are detected.

Steps to Reproduce

  1. terraform apply
  2. After successfully creating resource, run terraform plan

Terraform and provider versions

Terraform v1.5.7. Databricks latest release.

Debug Output

After debugging databricks terraform provider,it became clear that when databricks terraform provider is reading the state of view, view definition is returned with the following formatting applied:

  • Empty new lines are removed. E.g. "1\n\n\n2" -> "1\n2"
  • Tab symbol is replaced by 4 spaces. E.g. "1\t2" -> "1 2"

Would you like to implement a fix?

Yes, I would be happy to share the fix with the community.

There was an attempt to resolve this for empty new lines specifically, but it was never merged.

@p-venclovas
Copy link
Author

p-venclovas commented Sep 6, 2024

Raised PR #4003

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant