terraform-provider-databricks icon indicating copy to clipboard operation
terraform-provider-databricks copied to clipboard

[ISSUE] Issue with `databricks_share` resource

Open junwei-db opened this issue 6 months ago • 2 comments
trafficstars

Configuration

We are trying to add the same table to an existing share with a different alias (shared_as):

Terraform will perform the following actions:

  # databricks_share.share_to_system_tables will be updated in-place
  ~ resource "databricks_share" "share_to_system_tables" {
        created_at = 1708023884922
        created_by = "discovery-ws-provision-sa@staging-gcp-us-central1.iam.gserviceaccount.com"
        id         = "lineage_staging_us-central1"
        name       = "lineage_staging_us-central1"

        object {
            added_at                    = 1708023886608
            added_by                    = "discovery-ws-provision-sa@staging-gcp-us-central1.iam.gserviceaccount.com"
            cdf_enabled                 = false
            data_object_type            = "TABLE"
            history_data_sharing_status = "ENABLED"
            name                        = "lineage_etl.shared.column_lineage"
            shared_as                   = "lineage.column_lineage"
            start_version               = 0
            status                      = "ACTIVE"
        }
        object {
            added_at                    = 1708023886622
            added_by                    = "discovery-ws-provision-sa@staging-gcp-us-central1.iam.gserviceaccount.com"
            cdf_enabled                 = false
            data_object_type            = "TABLE"
            history_data_sharing_status = "ENABLED"
            name                        = "lineage_etl.shared.table_lineage"
            shared_as                   = "lineage.table_lineage"
            start_version               = 0
            status                      = "ACTIVE"
        }
      + object {
          + data_object_type            = "TABLE"
          + history_data_sharing_status = "ENABLED"
          + name                        = "lineage_etl.shared.column_lineage"
          + shared_as                   = "lineage.column_lineage_v2"
        }
      + object {
          + data_object_type            = "TABLE"
          + history_data_sharing_status = "ENABLED"
          + name                        = "lineage_etl.shared.table_lineage"
          + shared_as                   = "lineage.table_lineage_v2"
        }
    }

Plan: 0 to add, 1 to change, 0 to destroy.

Expected Behavior

The two tables are added to the share with the new aliases lineage.column_lineage_v2 and lineage.table_lineage_v2.

Actual Behavior

No change was made.

Steps to Reproduce

  1. Create a share including table A and shared as A1:
resource "databricks_share" "some" {
  name = "my_share"
  object {
    name = "A"
    shared_as = "A1"
  }
  1. Add a new object to the share for the same table A but shared as A2:
resource "databricks_share" "some" {
  name = "my_share"
  object {
    name = "A"
    shared_as = "A1"
  }
  object {
    name = "A"
    shared_as = "A2"
  }

Terraform and provider versions

Terraform Version: 0.12 Provider "gcp_databricks" with version "~> 1.49.1"

Is it a regression?

No

Debug Output

Important Factoids

Would you like to implement a fix?

junwei-db avatar May 14 '25 18:05 junwei-db

Hi I observed the same behavior until databricks_grants resource was added, hope this helps you too https://registry.terraform.io/providers/databricks/databricks/latest/docs/resources/grants#delta-sharing-share-grants

dukovw avatar May 29 '25 18:05 dukovw

Hi I observed the same behavior until databricks_grants resource was added, hope this helps you too https://registry.terraform.io/providers/databricks/databricks/latest/docs/resources/grants#delta-sharing-share-grants

@dukovw Thanks for the pointer. How does databricks_grants help resolve this issue? IIUC databricks_grants is used to grant a share to a recipient. Here what we wanted to do is to add more tables to the share.

junwei-db avatar May 29 '25 18:05 junwei-db