terraform-provider-databricks
terraform-provider-databricks copied to clipboard
[ISSUE] databricks_sql_query errors during `terraform apply` with `cannot create sql query: Internal Server Error`
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:
terraform apply

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

no reported outage during this issue
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
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