Skip to content

Commit d4a20e2

Browse files
pieternnfx
authored andcommitted
Add examples to docs
1 parent 5086f59 commit d4a20e2

File tree

4 files changed

+133
-4
lines changed

4 files changed

+133
-4
lines changed

docs/resources/sql_dashboard.md

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,30 @@ To manage [SQLA resources](https://docs.databricks.com/sql/get-started/concepts.
99

1010
**Note:** documentation for this resource is a work in progress.
1111

12-
In the meantime, you can refer to the tests for this resource for usage examples.
12+
A dashboard may have one or more [widgets](sql_widget.md).
13+
14+
## Example Usage
15+
16+
```hcl
17+
resource "databricks_sql_dashboard" "d1" {
18+
name = "My Dashboard Name"
19+
20+
tags = [
21+
"some-tag",
22+
"another-tag",
23+
]
24+
}
25+
```
26+
27+
Example [permission](permissions.md) to share dashboard with all users:
28+
29+
```hcl
30+
resource "databricks_permissions" "d1" {
31+
sql_dashboard_id = databricks_sql_dashboard.d1.id
32+
33+
access_control {
34+
group_name = data.databricks_group.users.display_name
35+
permission_level = "CAN_RUN"
36+
}
37+
}
38+
```

docs/resources/sql_query.md

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,46 @@ To manage [SQLA resources](https://docs.databricks.com/sql/get-started/concepts.
99

1010
**Note:** documentation for this resource is a work in progress.
1111

12-
In the meantime, you can refer to the tests for this resource for usage examples.
12+
A query may have one or more [visualizations](sql_visualization.md).
13+
14+
## Example Usage
15+
16+
```hcl
17+
resource "databricks_sql_query" "q1" {
18+
data_source_id = databricks_sql_endpoint.example.data_source_id
19+
name = "My Query Name"
20+
query = "SELECT {{ p1 }} AS p1, 2 as p2"
21+
22+
schedule {
23+
continuous {
24+
interval_seconds = 5 * 60
25+
}
26+
}
27+
28+
parameter {
29+
name = "p1"
30+
title = "Title for p1"
31+
text {
32+
value = "default"
33+
}
34+
}
35+
36+
tags = [
37+
"t1",
38+
"t2",
39+
]
40+
}
41+
```
42+
43+
Example [permission](permissions.md) to share query with all users:
44+
45+
```hcl
46+
resource "databricks_permissions" "q1" {
47+
sql_query_id = databricks_sql_query.q1.id
48+
49+
access_control {
50+
group_name = data.databricks_group.users.display_name
51+
permission_level = "CAN_RUN"
52+
}
53+
}
54+
```

docs/resources/sql_visualization.md

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,37 @@ To manage [SQLA resources](https://docs.databricks.com/sql/get-started/concepts.
99

1010
**Note:** documentation for this resource is a work in progress.
1111

12-
In the meantime, you can refer to the tests for this resource for usage examples.
12+
A visualization is always tied to a [query](sql_query.md). Every query may have one or more visualizations.
13+
14+
## Example Usage
15+
16+
```hcl
17+
resource "databricks_sql_visualization" "q1v1" {
18+
query_id = databricks_sql_query.q1.id
19+
type = "table"
20+
name = "My Table"
21+
description = "Some Description"
22+
23+
// The options encoded in this field are passed verbatim to the SQLA API.
24+
options = jsonencode(
25+
{
26+
"itemsPerPage" : 25,
27+
"columns" : [
28+
{
29+
"name" : "p1",
30+
"type" : "string"
31+
"title" : "Parameter 1",
32+
"displayAs" : "string",
33+
},
34+
{
35+
"name" : "p2",
36+
"type" : "string"
37+
"title" : "Parameter 2",
38+
"displayAs" : "link",
39+
"highlightLinks" : true,
40+
}
41+
]
42+
}
43+
)
44+
}
45+
```

docs/resources/sql_widget.md

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,32 @@ To manage [SQLA resources](https://docs.databricks.com/sql/get-started/concepts.
99

1010
**Note:** documentation for this resource is a work in progress.
1111

12-
In the meantime, you can refer to the tests for this resource for usage examples.
12+
A widget is always tied to a [dashboard](sql_dashboard.md). Every dashboard may have one or more widgets.
13+
14+
## Example Usage
15+
16+
```
17+
resource "databricks_sql_widget" "d1w1" {
18+
dashboard_id = databricks_sql_dashboard.d1.id
19+
text = "Hello! I'm a **text widget**!"
20+
21+
position {
22+
size_x = 3
23+
size_y = 4
24+
pos_x = 0
25+
pos_y = 0
26+
}
27+
}
28+
29+
resource "databricks_sql_widget" "d1w2" {
30+
dashboard_id = databricks_sql_dashboard.d1.id
31+
visualization_id = databricks_sql_visualization.q1v1.id
32+
33+
position {
34+
size_x = 3
35+
size_y = 4
36+
pos_x = 3
37+
pos_y = 0
38+
}
39+
}
40+
```

0 commit comments

Comments
 (0)