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

expand documentation for databricks_sql_query resource #1603

Merged
merged 1 commit into from
Sep 16, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 37 additions & 2 deletions docs/resources/sql_query.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,14 @@ A query may have one or more [visualizations](sql_visualization.md).
resource "databricks_sql_query" "q1" {
data_source_id = databricks_sql_endpoint.example.data_source_id
name = "My Query Name"
query = "SELECT {{ p1 }} AS p1, 2 as p2"
run_as_role = "viewer"
query = <<EOT
SELECT {{ p1 }} AS p1
WHERE 1=1
AND p2 in ({{ p2 }})
AND event_date > date '{{ p3 }}'
EOT

run_as_role = "viewer"

schedule {
continuous {
Expand All @@ -32,6 +38,31 @@ resource "databricks_sql_query" "q1" {
}
}

parameter {
name = "p2"
title = "Title for p2"
enum {
options = ["default", "foo", "bar"]
value = "default"
// passes to sql query as string `"foo", "bar"` if foo and bar are both selected in the front end
multiple {
prefix = "\""
suffix = "\""
separator = ","
}

}
}

parameter {
name = "p3"
title = "Title for p3"
date {
value = "2022-01-01"
}
}


tags = [
"t1",
"t2",
Expand Down Expand Up @@ -66,6 +97,10 @@ You can import a `databricks_sql_query` resource with ID like the following:
$ terraform import databricks_sql_query.this <query-id>
```

## Troubleshooting

In case you see `Error: cannot create sql query: Internal Server Error` during `terraform apply`; double check that you are using the correct [`data_source_id`](sql_endpoint.md)

## Related Resources

The following resources are often used in the same context:
Expand Down