-
Notifications
You must be signed in to change notification settings - Fork 428
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Streamlit v1 readiness (#2930)
<!-- Feel free to delete comments as you fill this in --> This PR adds streamlits datasource and streamlit resource. SDK is adjusted. <!-- summary of changes --> ## Test Plan <!-- detail ways in which this PR has been tested or needs to be tested --> * [x] acceptance tests <!-- add more below if you think they are relevant --> ## References <!-- issues documentation links, etc --> https://docs.snowflake.com/en/sql-reference/sql/create-streamlit
- Loading branch information
1 parent
ed712d7
commit aa42260
Showing
52 changed files
with
2,806 additions
and
239 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,177 @@ | ||
--- | ||
page_title: "snowflake_streamlits Data Source - terraform-provider-snowflake" | ||
subcategory: "" | ||
description: |- | ||
Datasource used to get details of filtered streamlits. Filtering is aligned with the current possibilities for SHOW STREAMLITS https://docs.snowflake.com/en/sql-reference/sql/show-streamlits query (only like is supported). The results of SHOW and DESCRIBE are encapsulated in one output collection streamlits. | ||
--- | ||
|
||
!> **V1 release candidate** This resource was reworked and is a release candidate for the V1. We do not expect significant changes in it before the V1. We will welcome any feedback and adjust the resource if needed. Any errors reported will be resolved with a higher priority. We encourage checking this resource out before the V1 release. Please follow the [migration guide](https://github.com/Snowflake-Labs/terraform-provider-snowflake/blob/main/MIGRATION_GUIDE.md#v0930--v0940) to use it. | ||
|
||
# snowflake_streamlits (Data Source) | ||
|
||
Datasource used to get details of filtered streamlits. Filtering is aligned with the current possibilities for [SHOW STREAMLITS](https://docs.snowflake.com/en/sql-reference/sql/show-streamlits) query (only `like` is supported). The results of SHOW and DESCRIBE are encapsulated in one output collection `streamlits`. | ||
|
||
## Example Usage | ||
|
||
```terraform | ||
# Simple usage | ||
data "snowflake_streamlits" "simple" { | ||
} | ||
output "simple_output" { | ||
value = data.snowflake_streamlits.simple.streamlits | ||
} | ||
# Filtering (like) | ||
data "snowflake_streamlits" "like" { | ||
like = "streamlit-name" | ||
} | ||
output "like_output" { | ||
value = data.snowflake_streamlits.like.streamlits | ||
} | ||
# Filtering by prefix (like) | ||
data "snowflake_streamlits" "like_prefix" { | ||
like = "prefix%" | ||
} | ||
output "like_prefix_output" { | ||
value = data.snowflake_streamlits.like_prefix.streamlits | ||
} | ||
# Filtering (limit) | ||
data "snowflake_streamlits" "limit" { | ||
limit { | ||
rows = 10 | ||
from = "prefix-" | ||
} | ||
} | ||
output "limit_output" { | ||
value = data.snowflake_streamlits.limit.streamlits | ||
} | ||
# Filtering (in) | ||
data "snowflake_streamlits" "in" { | ||
in { | ||
database = "database" | ||
} | ||
} | ||
output "in_output" { | ||
value = data.snowflake_streamlits.in.streamlits | ||
} | ||
# Without additional data (to limit the number of calls make for every found streamlit) | ||
data "snowflake_streamlits" "only_show" { | ||
# with_describe is turned on by default and it calls DESCRIBE STREAMLIT for every streamlit found and attaches its output to streamlits.*.describe_output field | ||
with_describe = false | ||
} | ||
output "only_show_output" { | ||
value = data.snowflake_streamlits.only_show.streamlits | ||
} | ||
# Ensure the number of streamlits is equal to at least one element (with the use of postcondition) | ||
data "snowflake_streamlits" "assert_with_postcondition" { | ||
like = "streamlit-name%" | ||
lifecycle { | ||
postcondition { | ||
condition = length(self.streamlits) > 0 | ||
error_message = "there should be at least one streamlit" | ||
} | ||
} | ||
} | ||
# Ensure the number of streamlits is equal to at exactly one element (with the use of check block) | ||
check "streamlit_check" { | ||
data "snowflake_streamlits" "assert_with_check_block" { | ||
like = "streamlit-name" | ||
} | ||
assert { | ||
condition = length(data.snowflake_streamlits.assert_with_check_block.streamlits) == 1 | ||
error_message = "streamlits filtered by '${data.snowflake_streamlits.assert_with_check_block.like}' returned ${length(data.snowflake_streamlits.assert_with_check_block.streamlits)} streamlits where one was expected" | ||
} | ||
} | ||
``` | ||
|
||
<!-- schema generated by tfplugindocs --> | ||
## Schema | ||
|
||
### Optional | ||
|
||
- `in` (Block List, Max: 1) IN clause to filter the list of streamlits (see [below for nested schema](#nestedblock--in)) | ||
- `like` (String) Filters the output with **case-insensitive** pattern, with support for SQL wildcard characters (`%` and `_`). | ||
- `limit` (Block List, Max: 1) Limits the number of rows returned. If the `limit.from` is set, then the limit wll start from the first element matched by the expression. The expression is only used to match with the first element, later on the elements are not matched by the prefix, but you can enforce a certain pattern with `starts_with` or `like`. (see [below for nested schema](#nestedblock--limit)) | ||
- `with_describe` (Boolean) Runs DESC STREAMLIT for each streamlit returned by SHOW STREAMLITS. The output of describe is saved to the description field. By default this value is set to true. | ||
|
||
### Read-Only | ||
|
||
- `id` (String) The ID of this resource. | ||
- `streamlits` (List of Object) Holds the aggregated output of all streamlits details queries. (see [below for nested schema](#nestedatt--streamlits)) | ||
|
||
<a id="nestedblock--in"></a> | ||
### Nested Schema for `in` | ||
|
||
Optional: | ||
|
||
- `account` (Boolean) Returns records for the entire account. | ||
- `database` (String) Returns records for the current database in use or for a specified database (db_name). | ||
- `schema` (String) Returns records for the current schema in use or a specified schema (schema_name). | ||
|
||
|
||
<a id="nestedblock--limit"></a> | ||
### Nested Schema for `limit` | ||
|
||
Required: | ||
|
||
- `rows` (Number) The maximum number of rows to return. | ||
|
||
Optional: | ||
|
||
- `from` (String) Specifies a **case-sensitive** pattern that is used to match object name. After the first match, the limit on the number of rows will be applied. | ||
|
||
|
||
<a id="nestedatt--streamlits"></a> | ||
### Nested Schema for `streamlits` | ||
|
||
Read-Only: | ||
|
||
- `describe_output` (List of Object) (see [below for nested schema](#nestedobjatt--streamlits--describe_output)) | ||
- `show_output` (List of Object) (see [below for nested schema](#nestedobjatt--streamlits--show_output)) | ||
|
||
<a id="nestedobjatt--streamlits--describe_output"></a> | ||
### Nested Schema for `streamlits.describe_output` | ||
|
||
Read-Only: | ||
|
||
- `default_packages` (String) | ||
- `external_access_integrations` (Set of String) | ||
- `external_access_secrets` (String) | ||
- `import_urls` (Set of String) | ||
- `main_file` (String) | ||
- `name` (String) | ||
- `query_warehouse` (String) | ||
- `root_location` (String) | ||
- `title` (String) | ||
- `url_id` (String) | ||
- `user_packages` (Set of String) | ||
|
||
|
||
<a id="nestedobjatt--streamlits--show_output"></a> | ||
### Nested Schema for `streamlits.show_output` | ||
|
||
Read-Only: | ||
|
||
- `comment` (String) | ||
- `created_on` (String) | ||
- `database_name` (String) | ||
- `name` (String) | ||
- `owner` (String) | ||
- `owner_role_type` (String) | ||
- `query_warehouse` (String) | ||
- `schema_name` (String) | ||
- `title` (String) | ||
- `url_id` (String) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
--- | ||
page_title: "snowflake_streamlit Resource - terraform-provider-snowflake" | ||
subcategory: "" | ||
description: |- | ||
Resource used to manage streamlits objects. For more information, check streamlit documentation https://docs.snowflake.com/en/sql-reference/commands-streamlit. | ||
--- | ||
|
||
!> **V1 release candidate** This resource was reworked and is a release candidate for the V1. We do not expect significant changes in it before the V1. We will welcome any feedback and adjust the resource if needed. Any errors reported will be resolved with a higher priority. We encourage checking this resource out before the V1 release. Please follow the [migration guide](https://github.com/Snowflake-Labs/terraform-provider-snowflake/blob/main/MIGRATION_GUIDE.md#v0930--v0940) to use it. | ||
|
||
# snowflake_streamlit (Resource) | ||
|
||
Resource used to manage streamlits objects. For more information, check [streamlit documentation](https://docs.snowflake.com/en/sql-reference/commands-streamlit). | ||
|
||
## Example Usage | ||
|
||
```terraform | ||
# basic resource | ||
resource "snowflake_streamlit" "streamlit" { | ||
database = "database" | ||
schema = "schema" | ||
name = "streamlit" | ||
stage = "streamlit_db.streamlit_schema.streamlit_stage" | ||
main_file = "/streamlit_main.py" | ||
} | ||
# resource with all fields set | ||
resource "snowflake_streamlit" "streamlit" { | ||
database = "database" | ||
schema = "schema" | ||
name = "streamlit" | ||
stage = "streamlit_db.streamlit_schema.streamlit_stage" | ||
directory_location = "src" | ||
main_file = "streamlit_main.py" | ||
query_warehouse = "warehouse" | ||
external_access_integrations = ["integration_id"] | ||
title = "title" | ||
comment = "comment" | ||
} | ||
``` | ||
|
||
<!-- schema generated by tfplugindocs --> | ||
## Schema | ||
|
||
### Required | ||
|
||
- `database` (String) The database in which to create the streamlit | ||
- `main_file` (String) Specifies the filename of the Streamlit Python application. This filename is relative to the value of `root_location` | ||
- `name` (String) String that specifies the identifier (i.e. name) for the streamlit; must be unique in your account. | ||
- `schema` (String) The schema in which to create the streamlit. | ||
- `stage` (String) The stage in which streamlit files are located. | ||
|
||
### Optional | ||
|
||
- `comment` (String) Specifies a comment for the streamlit. | ||
- `directory_location` (String) Specifies the full path to the named stage containing the Streamlit Python files, media files, and the environment.yml file. | ||
- `external_access_integrations` (Set of String) External access integrations connected to the Streamlit. | ||
- `query_warehouse` (String) Specifies the warehouse where SQL queries issued by the Streamlit application are run. | ||
- `title` (String) Specifies a title for the Streamlit app to display in Snowsight. | ||
|
||
### Read-Only | ||
|
||
- `describe_output` (List of Object) Outputs the result of `DESCRIBE STREAMLIT` for the given streamlit. (see [below for nested schema](#nestedatt--describe_output)) | ||
- `id` (String) The ID of this resource. | ||
- `show_output` (List of Object) Outputs the result of `SHOW STREAMLIT` for the given streamli. (see [below for nested schema](#nestedatt--show_output)) | ||
|
||
<a id="nestedatt--describe_output"></a> | ||
### Nested Schema for `describe_output` | ||
|
||
Read-Only: | ||
|
||
- `default_packages` (String) | ||
- `external_access_integrations` (Set of String) | ||
- `external_access_secrets` (String) | ||
- `import_urls` (Set of String) | ||
- `main_file` (String) | ||
- `name` (String) | ||
- `query_warehouse` (String) | ||
- `root_location` (String) | ||
- `title` (String) | ||
- `url_id` (String) | ||
- `user_packages` (Set of String) | ||
|
||
|
||
<a id="nestedatt--show_output"></a> | ||
### Nested Schema for `show_output` | ||
|
||
Read-Only: | ||
|
||
- `comment` (String) | ||
- `created_on` (String) | ||
- `database_name` (String) | ||
- `name` (String) | ||
- `owner` (String) | ||
- `owner_role_type` (String) | ||
- `query_warehouse` (String) | ||
- `schema_name` (String) | ||
- `title` (String) | ||
- `url_id` (String) | ||
|
||
## Import | ||
|
||
Import is supported using the following syntax: | ||
|
||
```shell | ||
# format is database name | schema name | streamlit name | ||
terraform import snowflake_streamlit.example 'dbName|schemaName|streamlitName' | ||
``` |
Oops, something went wrong.