Skip to content

Commit

Permalink
Expand parameter documentation for databricks_sql_query resource (d…
Browse files Browse the repository at this point in the history
  • Loading branch information
crankswagon authored Sep 16, 2022
1 parent 179fa97 commit b0a40e4
Showing 1 changed file with 37 additions and 2 deletions.
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

0 comments on commit b0a40e4

Please sign in to comment.