Skip to content

Commit 45b51e1

Browse files
committed
finish cherrypicking
1 parent a1e1bea commit 45b51e1

File tree

12 files changed

+726
-94
lines changed

12 files changed

+726
-94
lines changed
138 KB
Loading

src/content/docs/snowflake/capabilities/ephemeral-instances.md

Lines changed: 0 additions & 29 deletions
This file was deleted.

src/content/docs/snowflake/capabilities/state-management.md

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ State Management in LocalStack allows you to save and load the state of your Loc
1111

1212
State Management in LocalStack encompasses the following features:
1313

14-
- **Cloud Pods**: Cloud Pods are persistent state snapshots of your LocalStack instance that can easily be shared, stored, versioned, and restored.
1514
- **Export & Import State**: Export and import the state of your LocalStack instance on your local machine as a local file.
1615
- **Persistence**: Persist the state of your LocalStack instance on your local machine using a configuration variable.
1716

@@ -75,30 +74,3 @@ $ localstack state import '<file-name>'
7574
{{< /command >}}
7675

7776
The `<file-name>` argument is required and specifies the file path to import the state from. The file should be generated from a previous export.
78-
79-
## Cloud Pods
80-
81-
Cloud pods are persistent state snapshots of your LocalStack instance that can easily be stored, versioned, shared, and restored. Cloud Pods can be used for various purposes, such as:
82-
83-
- Save and manage snapshots of active LocalStack instances.
84-
- Share state snapshots with your team to debug collectively.
85-
- Automate your testing pipelines by pre-seeding CI environments.
86-
- Create reproducible development and testing environments locally.
87-
88-
You can save and load the persistent state of Cloud Pods, using the Cloud Pods CLI. LocalStack provides a remote storage backend that can be used to store the state of your running application and share it with your team members. Cloud Pods CLI is included in the [LocalStack CLI installation](https://docs.localstack.cloud/getting-started/installation/#localstack-cli), so there's no need for additional installations to begin using it.
89-
90-
### Create a new Cloud Pod
91-
92-
To create the Cloud Pod, you can run the following command:
93-
94-
{{< command >}}
95-
$ localstack pod save '<pod-name>'
96-
{{< /command >}}
97-
98-
### Load an existing Cloud Pod
99-
100-
To load the Cloud Pod, you can run the following command:
101-
102-
{{< command >}}
103-
$ localstack pod load '<pod-name>'
104-
{{< /command >}}

src/content/docs/snowflake/integrations/dbt.md

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -142,35 +142,6 @@ models:
142142
materialized: table
143143
```
144144
145-
### Connect to dbt Cloud
146-
147-
To use dbt Cloud with the Snowflake emulator, you'll first need to configure an ephemeral instance. Ephemeral instances provide isolated environments for testing and development. For more information, see the [Ephemeral Instances documentation]({{< ref "user-guide/ephemeral-instances" >}}).
148-
149-
1. First, create an ephemeral instance for Snowflake in the LocalStack Web application.
150-
151-
2. Once your ephemeral instance is running, note the host URL (e.g., `sf-v09rkl9fcjs21.sandbox.localstack.cloud`).
152-
153-
3. In the dbt Cloud interface:
154-
- Navigate to **Deploy** > **Environments**
155-
- Create a new environment or edit an existing one
156-
- Under **Connection Settings**, select **Snowflake**
157-
- Fill in the basic credentials:
158-
* Username: `test`
159-
* Password: `test`
160-
* Schema: `public`
161-
162-
4. In the **Extended attributes** section, specify the host from your ephemeral instance:
163-
164-
```yaml
165-
host: sf-v09rkl9fcjs21.sandbox.localstack.cloud
166-
```
167-
168-
<!-- ![dbt Cloud Configuration](dbt-cloud-config.png) -->
169-
170-
{{< alert type="info" >}}
171-
The host value must match your ephemeral instance URL. This overrides the default Snowflake host and directs connections to your LocalStack environment.
172-
{{< /alert >}}
173-
174145
## Best Practices
175146
176147
1. **Version Control**: Keep your dbt models and configurations in version control
@@ -180,4 +151,4 @@ The host value must match your ephemeral instance URL. This overrides the defaul
180151
181152
{{< alert type="info" >}}
182153
It's a good practice to always test your dbt models locally with the Snowflake emulator before deploying to production, to save time and resources.
183-
{{< /alert >}}
154+
{{< /alert >}}
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
---
2+
title: Authentication
3+
description: Get started with authentication in Snowflake.
4+
---
5+
6+
## Introduction
7+
8+
Snowflake supports [multiple authentication methods](https://docs.snowflake.com/en/user-guide/authentication-policies). The Snowflake emulator supports the following authentication methods:
9+
10+
* Username and password
11+
* RSA key pair authentication
12+
13+
This guide demonstrates how to use the Snowflake emulator to authenticate using both methods.
14+
15+
## Username and password
16+
17+
To authenticate using a username and password, you can set the `user` and `password` parameters in the connection string. The values for these parameters can be set to `test` in the Snowflake emulator. Since the Snowflake emulator is a local instance, the username and password can be the same, and the authentication mechanism is mocked.
18+
19+
Here's an example of how to connect to the Snowflake emulator using a username and password in a Python script:
20+
21+
```python
22+
import snowflake.connector as sf
23+
24+
sf_conn_obj = sf.connect(
25+
user="test",
26+
password="test",
27+
account="test",
28+
database="test",
29+
host="snowflake.localhost.localstack.cloud",
30+
)
31+
```
32+
33+
The default username and password are set to `test` and can be changed using `SF_DEFAULT_USER` and `SF_DEFAULT_PASSWORD` when starting the Snowflake emulator.
34+
35+
{{< alert title="Note" >}}
36+
It is not recommended to use your production credentials in the Snowflake emulator.
37+
{{< /alert >}}
38+
39+
## RSA key pair authentication
40+
41+
The Snowflake emulator supports RSA key-based authentication, allowing users to log in without a password by using a private key and a configured public key.
42+
43+
To enable this, create a private key and a public key pair.
44+
45+
```bash
46+
openssl genrsa -out private_key.pem 2048
47+
openssl rsa -in private_key.pem -pubout -out public_key.pem
48+
```
49+
50+
Then set a public key for the user:
51+
52+
```sql
53+
ALTER USER your_user_name SET RSA_PUBLIC_KEY='<public_key>';
54+
```
55+
56+
Then authenticate with the private key using the Snowflake client:
57+
58+
```python
59+
import snowflake.connector
60+
61+
conn = snowflake.connector.connect(
62+
user='your_user_name',
63+
account='your_account_identifier',
64+
private_key_file='/path/to/private_key.pem',
65+
# Add other parameters as needed
66+
)
67+
```
68+
69+
{{< alert title="Note" >}}
70+
The Snowflake emulator does not validate key contents—RSA authentication is mocked for local testing only.
71+
{{< /alert >}}
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
---
2+
title: "Materialized Views"
3+
description: Get started with Materialized Views in LocalStack for Snowflake
4+
---
5+
6+
## Introduction
7+
8+
Materialized views are a feature of Snowflake that allows you to create a persistent view of a table. This view is pre-computed and stored in the database, allowing for faster queries and improved performance.
9+
10+
The Snowflake emulator supports Materialized Views, allowing you to accurately test materialized view logic and behavior in local development environments. The following operations are supported:
11+
12+
- [`CREATE MATERIALIZED VIEW`](https://docs.snowflake.com/en/sql-reference/sql/create-materialized-view)
13+
- [`ALTER MATERIALIZED VIEW`](https://docs.snowflake.com/en/sql-reference/sql/alter-materialized-view)
14+
- [`DESCRIBE MATERIALIZED VIEW`](https://docs.snowflake.com/en/sql-reference/sql/desc-materialized-view)
15+
- [`DROP MATERIALIZED VIEW`](https://docs.snowflake.com/en/sql-reference/sql/drop-materialized-view)
16+
- [`SHOW MATERIALIZED VIEWS`](https://docs.snowflake.com/en/sql-reference/sql/show-materialized-views)
17+
- [`TRUNCATE MATERIALIZED VIEW`](https://docs.snowflake.com/en/sql-reference/sql/truncate-materialized-view)
18+
19+
## Getting started
20+
21+
This guide is designed for users new to Materialized Views and assumes basic knowledge of SQL and Snowflake. Start your Snowflake emulator and connect to it using an SQL client to execute the queries below.
22+
23+
The following sections guide you through creating materialized views, inserting data into source tables, querying from views, and performing operations like rename, describe, and drop.
24+
25+
### Create a materialized view
26+
27+
To create a materialized view, use the `CREATE MATERIALIZED VIEW` statement. The following example creates a view `order_view` that selects specific columns from the `orders` table.
28+
29+
```sql
30+
CREATE TABLE IF NOT EXISTS orders (
31+
id INT,
32+
product TEXT,
33+
shipped BOOLEAN
34+
);
35+
36+
CREATE MATERIALIZED VIEW IF NOT EXISTS order_view AS
37+
SELECT id, product FROM orders;
38+
```
39+
40+
### Insert data into source table
41+
42+
Inserting new data into the base table automatically refreshes the materialized view in the background.
43+
44+
```sql
45+
INSERT INTO orders(id, product, shipped)
46+
VALUES (1, 'Book', FALSE), (2, 'Pen', TRUE);
47+
```
48+
49+
### Query from materialized view
50+
51+
You can query a materialized view just like a regular table. The view reflects the data from the source table as of its most recent refresh.
52+
53+
```sql
54+
SELECT * FROM order_view;
55+
```
56+
57+
The output should be:
58+
59+
```sql
60+
ID|PRODUCT|
61+
--+-------+
62+
1|Book |
63+
2|Pen |
64+
```
65+
66+
### Describe the view
67+
68+
Use `DESCRIBE MATERIALIZED VIEW` to inspect the schema of the view, including column names and types.
69+
70+
```sql
71+
DESCRIBE MATERIALIZED VIEW order_view;
72+
```
73+
74+
The output should be:
75+
76+
```sql
77+
name |type|kind |null?|default|primary key|unique key|check|expression|comment|policy name|privacy domain|
78+
-------+----+------+-----+-------+-----------+----------+-----+----------+-------+-----------+--------------+
79+
ID |INT4|COLUMN|Y | |N |N | | | | | |
80+
PRODUCT|TEXT|COLUMN|Y | |N |N | | | | | |
81+
```
82+
83+
### Rename and drop view
84+
85+
You can rename and drop materialized views using standard SQL statements.
86+
87+
```sql
88+
ALTER MATERIALIZED VIEW order_view RENAME TO order_view_new;
89+
90+
DROP MATERIALIZED VIEW IF EXISTS order_view_new;
91+
```
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
---
2+
title: "Native Apps"
3+
description: Get started with Native Apps in LocalStack for Snowflake
4+
---
5+
6+
## Introduction
7+
8+
Snowflake Native Apps are applications built and executed directly within the Snowflake Data Cloud platform. These apps can be used to extend the capabilities of Snowflake by integrating with external services, automating workflows, and building custom data applications. These apps are developed using Snowflake-native tools (e.g., Snowflake SQL, Snowflake API, and JavaScript) and can be distributed on the Snowflake Marketplace.
9+
10+
The Snowflake emulator supports creating & deploying Native Apps locally with the same statements as the Snowflake service. The following operations are supported:
11+
12+
- [`CREATE APPLICATIONS`](https://docs.snowflake.com/en/sql-reference/sql/create-application.html)
13+
- [`SHOW APPLICATION PACKAGES`](https://docs.snowflake.com/en/sql-reference/sql/show-application-packages.html)
14+
- [`ALTER APPLICATION PACKAGE`](https://docs.snowflake.com/en/sql-reference/sql/alter-application-package.html)
15+
- [`DESCRIBE APPLICATION`]( https://docs.snowflake.com/en/sql-reference/sql/desc-application)
16+
- [`DROP APPLICATION PACKAGE`](https://docs.snowflake.com/en/sql-reference/sql/drop-application-package.html)
17+
18+
## Getting started
19+
20+
This guide is designed for users new to Native Apps and assumes basic knowledge of Snow CLI and Snowflake. Start your Snowflake emulator and connect to it using the Snow CLI in order to execute the commands further below.
21+
22+
In this guide, you will locally deploy a Native App using an existing Application Package.
23+
24+
### Clone the repository
25+
26+
Clone the [Native Apps repository](https://github.com/snowflakedb/native-apps-examples) and navigate to the `tasks-streams` directory:
27+
28+
```bash
29+
git clone https://github.com/snowflakedb/native-apps-examples.git
30+
cd native-apps-examples/tasks-streams
31+
```
32+
33+
### Deploy Native App
34+
35+
Deploy the Native App using the Snow CLI:
36+
37+
```bash
38+
snow app run --connection localstack
39+
```
40+
41+
The following output should be displayed:
42+
43+
```bash
44+
Creating new application package tasks_streams_app_pkg_username in account.
45+
Checking if stage tasks_streams_app_pkg_username.app_src.stage exists, or creating a new one if none exists.
46+
Performing a diff between the Snowflake stage: stage and your local deploy_root: /Users/username/code/localstack/native-apps-examples/tasks-streams/output/deploy.
47+
Local changes to be deployed:
48+
added: app/manifest.yml -> manifest.yml
49+
added: app/setup_script.sql -> setup_script.sql
50+
added: src/module-ui/src/environment.yml -> streamlit/environment.yml
51+
added: src/module-ui/src/ui.py -> streamlit/ui.py
52+
Updating the Snowflake stage from your local /Users/username/code/localstack/native-apps-examples/tasks-streams/output/deploy directory.
53+
Validating Snowflake Native App setup script.
54+
Creating new application object tasks_streams_app_username in account.
55+
Application 'TASKS_STREAMS_APP_username' created successfully.
56+
57+
Your application object (tasks_streams_app_username) is now available:
58+
https://app.snowflake.com/test/test/#/apps/application/TASKS_STREAMS_APP_username
59+
```
60+
61+
### Access Native App
62+
63+
You can access the Native App by visiting your preferred browser and navigating to the following URL:
64+
65+
```bash
66+
https://snowflake.localhost.localstack.cloud:4566/apps/test/test/TASKS_STREAMS_APP_username/
67+
```
68+
69+
{{< alert title="Note" >}}
70+
The URL above is an example. Change the outputted URL by:
71+
72+
1. Replacing `https://app.snowflake.com` with `https://snowflake.localhost.localstack.cloud:4566`.
73+
2. Changing the path structure from `/#/apps/application/` to `/apps/test/test/`.
74+
75+
You can make additional changes depending on your local setup.
76+
{{< /alert >}}
77+
78+
The following app should be displayed:
79+
80+
![Native App](/images/snowflake/native-app.png)

0 commit comments

Comments
 (0)