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

[ISSUE] databricks_sql_query errors during `terraform apply` with `cannot create sql query: Internal Server Error`

Open crankswagon opened this issue 3 years ago • 1 comments

Hi there,

Configuration

resource "databricks_sql_query" "user_transaction_history" {
  data_source_id = data.terraform_remote_state.derp_module_repo.outputs.sql-endpoint-id
  name           = "Extract Transactions"
  query          = <<EOT
                    SELECT
                    *
                    FROM
                    derp.derp_table
                    WHERE
                    1 = 1
                    and vertical = '{{ Vertical }}'
                    and account_id = {{ AccountId }}
                    EOT

  run_as_role = "owner"

  parameter {
    name  = "Vertical"
    title = "Vertical"
    enum {
      options = ["Redacted_A", "Redacted_B"]
    }
  }

  parameter {
    name  = "AccountId"
    title = "Account Id"
    number {
      value = "123456"
    }
  }

  tags = [
    "Derp Query",
    "Derp Dashboard",
  ]
}

Expected Behavior

Expecting this to create a query in databricks's SQL endpoint

Actual Behavior

terraform validate passes terraform plan passes terraform apply errors on server error

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. terraform apply

Screen Shot 2022-07-18 at 3 55 59 pm

Terraform and provider versions

0.6.1

Debug Output

│ Error: cannot create sql query: Internal Server Error
│ 
│   with databricks_sql_query.user_transaction_history,
│   on derp-analytics-dashboards.tf line 1, in resource "databricks_sql_query" "user_transaction_history":
│    1: resource "databricks_sql_query" "user_transaction_history" {

Important Factoids

crankswagon avatar Jul 18 '22 05:07 crankswagon

Screen Shot 2022-07-18 at 4 00 17 pm

no reported outage during this issue

jay-vgw avatar Jul 18 '22 06:07 jay-vgw

In data_source_id = data.terraform_remote_state.derp_module_repo.outputs.sql-endpoint-id

It should rather point to data_source_id and not endpoint/warehouse id. Giving incorrect data_source_id will also lead to Internal Server Error

pratikbhawsar26 avatar Sep 02 '22 00:09 pratikbhawsar26

thank you @pratik-databricks, that fixed the issue for us 🙏 🙏

for any future reader of this issue: https://registry.terraform.io/providers/databricks/databricks/latest/docs/resources/sql_endpoint#data_source_id

jay-vgw avatar Sep 02 '22 03:09 jay-vgw