From dad97841b7984a5c4f4406b966d1815c2845789c Mon Sep 17 00:00:00 2001 From: Future-Outlier Date: Fri, 2 Aug 2024 10:54:13 +0800 Subject: [PATCH] revert Signed-off-by: Future-Outlier --- .../snowflake_plugin_example.md | 55 ++++++++++++++++++- 1 file changed, 53 insertions(+), 2 deletions(-) diff --git a/docs/deprecated_integrations/snowflake_plugin/snowflake_plugin_example.md b/docs/deprecated_integrations/snowflake_plugin/snowflake_plugin_example.md index a0f35c2629..9994884fbe 100644 --- a/docs/deprecated_integrations/snowflake_plugin/snowflake_plugin_example.md +++ b/docs/deprecated_integrations/snowflake_plugin/snowflake_plugin_example.md @@ -6,16 +6,67 @@ This example shows how to use the `SnowflakeTask` to execute a query in Snowflak To clone and run the example code on this page, see the [Flytesnacks repo][flytesnacks]. ``` +To begin, import the required libraries: + ```{rli} https://raw.githubusercontent.com/flyteorg/flytesnacks/master/examples/snowflake_plugin/snowflake_plugin/snowflake_plugin_example.py :caption: snowflake_plugin/snowflake_plugin_example.py -:lines: 1-120 +:lines: 1-2 ``` Instantiate a {py:class}`~flytekitplugins.snowflake.SnowflakeTask` to execute a query. Incorporate {py:class}`~flytekitplugins.snowflake.SnowflakeConfig` within the task to define the appropriate configuration. +```{rli} https://raw.githubusercontent.com/flyteorg/flytesnacks/master/examples/snowflake_plugin/snowflake_plugin/snowflake_plugin_example.py +:caption: snowflake_plugin/snowflake_plugin_example.py +:lines: 4-15 +``` + :::{note} -Please give your Snowflake task different names. +For successful registration, ensure that your Snowflake task is assigned a unique +name within your project/domain for your Flyte installation. ::: +In practical applications, our primary focus is often on utilizing Snowflake to query datasets. +Here, we employ the `SNOWFLAKE_SAMPLE_DATA`, a default dataset in the Snowflake service. +You can find more details about it [here](https://docs.snowflake.com/en/user-guide/sample-data.html). +The data adheres to the following schema: + +```{eval-rst} ++----------------------------------------------+ +| C_CUSTKEY (int) | ++----------------------------------------------+ +| C_NAME (string) | ++----------------------------------------------+ +| C_ADDRESS (string) | ++----------------------------------------------+ +| C_NATIONKEY (int) | ++----------------------------------------------+ +| C_PHONE (string) | ++----------------------------------------------+ +| C_ACCTBAL (float) | ++----------------------------------------------+ +| C_MKTSEGMENT (string) | ++----------------------------------------------+ +| C_COMMENT (string) | ++----------------------------------------------+ +``` + +Let us explore how we can parameterize our query to filter results for a specific country. +This country will be provided as user input, using a nation key to specify it. + +```{rli} https://raw.githubusercontent.com/flyteorg/flytesnacks/master/examples/snowflake_plugin/snowflake_plugin/snowflake_plugin_example.py +:caption: snowflake_plugin/snowflake_plugin_example.py +:lines: 18-34 +``` + +To review the query results, access the Snowflake console at: +`https://.snowflakecomputing.com/console#/monitoring/queries/detail`. + +You can also execute the task and workflow locally. + +```{rli} https://raw.githubusercontent.com/flyteorg/flytesnacks/master/examples/snowflake_plugin/snowflake_plugin/snowflake_plugin_example.py +:caption: snowflake_plugin/snowflake_plugin_example.py +:lines: 41-43 +``` + [flytesnacks]: https://github.com/flyteorg/flytesnacks/tree/master/examples/snowflake_plugin