I have created this basic stored procedure to query a Snowflake table based on a customer id: It works fine but I would like my sproc to return a JSON object for the whole result set. I modified it thusly: It compiles without errors but fails at runtime with this error: What am I missing here? Answer You need to
Tag: snowflake-cloud-data-platform
How to execute sql query with python variables null or empty
Hi I’m using python 3 and snowflake. Example: I tried with this: I’m getting TypeError: not enough arguments for format string. I would like to run this query for all schemas if I dont have defined MY_SCHEMA variable and also for all tables if MY_TABLE variable is null or empty. I would be grateful for any advice. Answer I found
How to write a scalar Snowflake Python UDF with variable number of arguments?
I’d like to write a Snowflake scalar UDF in Python which takes a variable number of string arguments. The idea I had was to use array type for this (i.e. array can handle variable number of elements) but the issue I had with this was that as soon as a single element of array argument was NULL, Snowflake threw an
Read run_id in airflow operator for non templated fields
I am trying to read run_id for DAG in SnowflakeOperator to set a session parameter, query_tag. But it seems like the session parameter is not templated. How can I reference run_id and use it as an input here? Answer You need to make the non-templated field templated. Then you can use it as:
Snowflake table created with SQLAlchemy requires quotes (“”) to query
I am ingesting data into Snowflake tables using Python and SQLAlchemy. These tables that I have created all require quotations to query both the table name and the column names. For example, select * from “database”.”schema”.”table” where “column” = 2; Will run, while select * from database.schema.table where column = 2; will not run. The difference being the quotes. I
Single Quote in Cursor Execute for Snowflake Connector
I am trying to update a table from the Snowflake Connector in python to a Snowflake table; To escape the single quote in the Snowflake UI, I would format the “where” clause to be Also tried: However, no fix that I have tried is succeeding to workaround this error in python. Is there a way to do this from python,
Can’t append to an existing table. Fails silently
I’m trying to dump a pandas DataFrame into an existing Snowflake table (via a jupyter notebook). When I run the code below no errors are raised, but no data is written to the destination SF table (df has ~800 rows). If I check the SF History, I can see that the queries apparently ran without issue: If I pull the
SQLAlchemy engine.connect() fails for Snowflake using keypair authentication
My goal is to be able to write a pandas dataframe to Snowflake using the to_sql() function. I am able to successfuly query from Snowflake using read_sql() with no problems. It appears that to_sql() requires a slightly different configuration I can’t figure out. I’ve tried two different approaches that I’ve outlined below. I’m guessing, but could be wrong that the