Using Snowflake with Rows
Learn how to use the QUERY_SNOWFLAKE() function to query your Snowflake databases, schemas, and views using SQL directly within Rows spreadsheets.
Rows' Snowflake integration allows you to access and manipulate your data stored in Snowflake using the
QUERY_SNOWFLAKE() function. This function lets you use SQL queries to retrieve data from your Snowflake databases, schemas, and views and display it in your Rows spreadsheets.
Connecting Snowflake to Rows
First and foremost, you will need to connect the Snowfalke integration so that you may use it wihtin Rows. This can be a complicated matter so we have outlined these steps in detail in another article. How to connect Snowflake with Rows
QUERY_BIGQUERY Function Syntax
QUERY_SNOWFLAKE(query, [warehouse], [database], [schema], [role])
query: The SQL query to apply. For example: "select * from analytics.monthly-sales".
[optional] warehouse: The name of the Snowflake warehouse. For example: "acme-prod".
[optional] database: The name of the Snowflake database. For example: "acme-sales-monthly".
[optional] schema: The name of the Snowflake schema. For example: "acme-prod-byregion".
[optional] role: The name of the role to use when executing the query. For example: "admin". By default, it will use the role from the user who connected the account.
1QUERY_SNOWFLAKE("SELECT name, email, phone FROM `analytics.users`", "acme-prod", "acme-sales-monthly", "acme-prod-by-region", "admin")
This example returns a list with name, email, and phone from the table users in the dataset analytics.
Follow these steps to use the QUERY_SNOWFLAKE function:
Make sure you have connected Rows to your Snowflake account. If you haven't done so already, you can follow our Snowflake integration guide for step-by-step instructions.
Open a Rows spreadsheet where you'd like to query your Snowflake data and enter the
QUERY_SNOWFLAKE() function in a cell, providing the required and optional parameters. For example:
1=QUERY_SNOWFLAKE("SELECT name, email, phone FROM `analytics.users`", "acme-prod", "acme-sales-monthly", "acme-prod-by-region", "admin")
The queried data will appear in the Rows spreadsheet. You can use the data in conjunction with Rows' other functions to analyze and manipulate the information further.
- This function retrieves only the output values from your Snowflake databases, schemas, and views. Formulas or calculations in Snowflake won't be imported.
- Always ensure that your SQL queries follow Snowflake's SQL syntax and best practices to avoid errors.
- When querying large datasets, keep in mind that the function may take longer to execute, depending on the complexity of the query and the size of the dataset.
- By using the function in Rows, you can seamlessly integrate your Snowflake data into your Rows spreadsheets, enabling powerful analysis and data manipulation.
Limitations and Best Practices
When using the QUERY_SNOWFLAKE function, keep the following limitations and best practices in mind:
Large datasets: Be mindful of the volume of data being imported, as large datasets can slow down the performance of your Rows spreadsheet. Consider using filters and aggregate functions within your SQL query to limit the data retrieved from Snowflake.
Data privacy and security: Ensure that sensitive data is protected by applying appropriate access controls to your Snowflake database, schema, or view and Rows spreadsheets.
Rate limits: Snowflake has rate limits and quotas that apply to queries. For more information, refer to Snowflake's Resource Monitors documentation.
Size limits: Snowflake has size limits and quotas that apply to queries. Be mindful of these limits when using the function. For more information, refer to Snowflake's Limits on Query Text Size documentation.
Error handling: In case of an error, the function will return an error message. Check your SQL query syntax and parameters to resolve any issues.
QUERY_SNOWFLAKE() function provides a powerful way to integrate your Snowflake data into Rows spreadsheets, enabling you to perform advanced analysis and data manipulation. By following the steps and best practices outlined in this article, you can effectively utilize this function to unlock the full potential of your Snowflake data within Rows.