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

Replace warehouse variable with current_warehouse #196

Merged
merged 1 commit into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
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
11 changes: 3 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,11 @@ SELECT SYSTEM$BEHAVIOR_CHANGE_BUNDLE_STATUS('2024_08');
> For more information on this bundle please see our [BCR Documentation](https://docs.snowflake.com/en/release-notes/behavior-changes).


[Snowflake CLI](https://docs.snowflake.com/en/developer-guide/snowflake-cli-v2/index) is recommended for deploying the app in Streamlit in Snowflake. Please see Snowflake CLI [installation instructions](https://docs.snowflake.com/en/developer-guide/snowflake-cli-v2/installation/installation) to install. **Snowflake CLI version 3.0+ is required**. Follow the below instructions to install the Semantic Model Generator in Streamlit in Snowflake.
[Snowflake CLI](https://docs.snowflake.com/en/developer-guide/snowflake-cli-v2/index) is recommended for deploying the app in Streamlit in Snowflake. Please see Snowflake CLI [installation instructions](https://docs.snowflake.com/en/developer-guide/snowflake-cli-v2/installation/installation) to install. **Snowflake CLI version 3.0+ is recommended**. Follow the below instructions to install the Semantic Model Generator in Streamlit in Snowflake.

If you do not have Snowflake CLI installed, the setup can be replicated manually with the [VS Code Snowflake extension](https://docs.snowflake.com/en/user-guide/vscode-ext), Snowsight or [Snowflake Native Git Integration](https://docs.snowflake.com/en/developer-guide/git/git-overview):
- For VS Code extention, please note that parameters passed (with flag `-D`) will be need to be hard-coded in the `.sql` files directly.
- If using Snowsight, you may use the files upload wizard to upload files. Please pay close attention to maintain the directory structure referenced in `setup_sis/app_setup.sql`.
- If using the Native Git Integration, copy and paste the code from this [setup file](https://github.com/Snowflake-Labs/semantic-model-generator/blob/main/sis_setup/sissetup_snowsightgit.sql) and run in Snowsight. Please note that you will have to set the Streamlit Warehouse as a variable in line 2:
```sql
SET my_streamlit_warehouse=<streamlit warehouse>;
```
- If using the Native Git Integration, copy and paste the code from this [setup file](https://github.com/Snowflake-Labs/semantic-model-generator/blob/main/sis_setup/sissetup_snowsightgit.sql) and run in Snowsight.

### Snowflake CLI Installation

Expand All @@ -56,12 +52,11 @@ Follow [instructions](https://docs.snowflake.com/en/developer-guide/snowflake-cl
2. Deploy app in Streamlit in Snowflake

Run the below command from the project root directory to create all necessary objects in Snowflake.
Before running, replace `<STREAMLIT_WAREHOUSE>` with an available warehouse to power the app.

**Hint**: The owner of the app will be the role specified in your Snowflake CLI connection. To use a different role, append `--role <DESIRED_ROLE>` to the end of the command, replacing `<DESIRED_ROLE>`.

```bash
snow sql -f sis_setup/app_setup.sql -D "warehouse=<STREAMLIT_WAREHOUSE>"
snow sql -f sis_setup/app_setup.sql
```

The app, titled Semantic Model Generator can be opened directly in Snowsight. Alternatively, you may run the below command in your terminal to open it.
Expand Down
4 changes: 3 additions & 1 deletion sis_setup/app_setup.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
SET (streamlit_warehouse)=(SELECT CURRENT_WAREHOUSE());

CREATE DATABASE IF NOT EXISTS CORTEX_ANALYST_SEMANTICS
COMMENT = '{"origin": "sf_sit",
"name": "skimantics",
Expand Down Expand Up @@ -42,7 +44,7 @@ MAIN_FILE = 'app.py'
TITLE = "Semantic Model Generator"
IMPORTS = ('@cortex_analyst_semantics.semantic_model_generator.streamlit_stage/looker_sdk.zip',
'@cortex_analyst_semantics.semantic_model_generator.streamlit_stage/strictyaml.zip')
QUERY_WAREHOUSE = <% warehouse %>
QUERY_WAREHOUSE = $streamlit_warehouse
COMMENT = '{"origin": "sf_sit",
"name": "skimantics",
"version": {"major": 2, "minor": 0},
Expand Down
6 changes: 2 additions & 4 deletions sis_setup/sissetup_snowsightgit.sql
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
-- Please first set your Streamlit Warehouse here by replacing <streamlit warehouse> with a valid warehouse:

SET my_streamlit_warehouse=<streamlit warehouse>;
SET (streamlit_warehouse)=(SELECT CURRENT_WAREHOUSE());

CREATE DATABASE IF NOT EXISTS CORTEX_ANALYST_SEMANTICS;
USE DATABASE CORTEX_ANALYST_SEMANTICS;
Expand Down Expand Up @@ -79,7 +77,7 @@ MAIN_FILE = 'app.py'
TITLE = "Semantic Model Generator"
IMPORTS = ('@cortex_analyst_semantics.semantic_model_generator.streamlit_stage/looker_sdk.zip',
'@cortex_analyst_semantics.semantic_model_generator.streamlit_stage/strictyaml.zip')
QUERY_WAREHOUSE = $my_streamlit_warehouse
QUERY_WAREHOUSE = $streamlit_warehouse
COMMENT = '{"origin": "sf_sit",
"name": "skimantics",
"version": {"major": 2, "minor": 0},
Expand Down