databricks / terraform-provider-databricks

Databricks Terraform Provider
https://registry.terraform.io/providers/databricks/databricks/latest
Other
457 stars 393 forks source link

[ISSUE] Issue with `databricks_sql_table` resource perpetual diff on options #4098

Closed apamildner closed 1 month ago

apamildner commented 1 month ago

Configuration

resource "databricks_sql_table" "my_table" {
  name               = "foo"
  catalog_name       = "bar"
  schema_name        ="baz"
  table_type         = "EXTERNAL"
  storage_location   = "abfss://some-location"
  data_source_format = "JSON"
  options = {
    recursiveFileLookup = true
    multiLine           = true
  }
}

Expected Behavior

The options should be applied and not trigger a change on the next plan

Actual Behavior

We get a perpetual diff like this:

  ~ resource "databricks_sql_table" "my_table" {
      ~ effective_properties = {
          + "option.multiLine"                                = "true"
          + "option.recursiveFileLookup"                      = "true"
            # (2 unchanged elements hidden)
        }

Steps to Reproduce

  1. terraform apply
  2. terraform apply again
  3. Diff appears, even though we didn't change any code

Terraform and provider versions

Terraform version: 1.8.5 Provider version: 1.52

Is it a regression?

Yes, I think this is en edge case that wasn't covered by the great PR that solved a previous similar issue: https://github.com/databricks/terraform-provider-databricks/pull/3925 I would assume that since the options in this case end up like this in the state:

     "effective_properties": {
              "spark.sql.dataSourceOptions.multiLine": "true",
              "spark.sql.dataSourceOptions.recursiveFileLookup": "true"
            },

And not

     "effective_properties": {
              "options.multiLine": "true",
              "options.recursiveFileLookup": "true"
            },

we will get that diff. I think we need to handle the edge case where the options are of type spark.sql.dataSourceOptions.