snowflake-cloud-data-platform

Snowflake ext table with pattern case sensitive

Snowflake ext table with pattern case sensitive Question: create or replace external table table_namewith location = @abc/corpfiles pattern = ‘.folder1/subfolder/..csv$’ auto_refresh = true file_format = (Type=CSV,field_optionally_enclosed_by = ‘"’); Above ext table works fine but when file extension is uppercase such as abc.CVS then it doesn’t work. abc.csv works fine. How to account for case sensitivity …

Total answers: 1

How to parse a dataframe column having dynamic records and write it into different columns by maintaining the relation with the table

How to parse a dataframe column having dynamic records and write it into different columns by maintaining the relation with the table Question: cur = snow_connection.cursor() data = snow_connection.cursor().execute("SELECT x,y,z FROM abc.testing_view2").fetchall() df = pd.DataFrame(data) df.columns = [‘x’,’y’,’z’] print(df) temp_col=df.iloc[:,2] print(temp_col) for i in range (len(df.iloc[:,0])): for j in range(len(df.iloc[:,1])): for k in range(len(temp_col)): json_dict …

Total answers: 4

Invalid syntax when using the cursor.execute in python ( sagemaker notebook)

Invalid syntax when using the cursor.execute in python ( sagemaker notebook) Question: select * FROM HEVOPROD_DB.HEVOPROD_SCH.PRDNEW_METERING where REQUESTED_SERVICE = ‘["dsp"]’ and longitude is not null ; The above query works fine when i query this in snowflake while using this query in sagemaker notebook/ jupyter notebook it just fails stating invalid syntax important point here …

Total answers: 1

Error while connecting to snowflake via python "UnpicklingError: invalid load key, 'x00'"

Error while connecting to snowflake via python "UnpicklingError: invalid load key, 'x00'" Question: I am getting the following error while connecting to snowflake via python using snowflake.connector.connect import snowflake.connector #pip install snowflake-connector-python #i am getting the env from .env file i stored locally cnx = snowflake.connector.connect(user=os.getenv(‘USER’),password=os.getenv(‘PASSWORD’),account=os.getenv(‘ACCOUNT’),warehouse=os.getenv(‘WAREHOUSE’), database=db,schema=schema ) This was working fine until today when …

Total answers: 1

Snowflake – invoking Python code without creating UDF/Stored Procedure

Snowflake – invoking Python code without creating UDF/Stored Procedure Question: How to run Python code without defining pernament/temporary User Defined Function or stored procedure? The use case is to run the code one time inside a script and it should avoid creating/dropping additional database objects. I am searching for an equivalent of anonymous block (SQL) …

Total answers: 2

snowsql python load csv file to tempstorage using put

snowsql python load csv file to tempstorage using put Question: Using Python + Snowsql Am trying to load a CSV file using PUT command to copy the local file(s) into the Snowflake staging area for the table. file_path = ‘file://XXXXX/YYYYYY/ZZZZZZ/TEST/Final.csv’.format(os.getcwd()) con.execute("PUT ‘{0}’ @test_results".format(file_path)) The above command is not working so may be I have to …

Total answers: 2

How to implement Python UDF in dbt

How to implement Python UDF in dbt Question: Please I need some help with applying python UDF to run on my dbt models. I successfully created a python function in snowflake (DWH) and ran it against a table. This seems to work as expected, but implementing this on dbt seems to be a struggle. Some …

Total answers: 2

Write table from python to SNOWFLAKE database with specific ROLE

Write table from python to SNOWFLAKE database with specific ROLE Question: How can I change "ROLE". I need use pytohn code (write to table) as a ACCOUNTADMIN. But Im default as SYSADMIN. When I use role ACCOUNTADIM in "conn_string", its non function, Im still as SYSADMIN and doesnt see my target database. I mean I …

Total answers: 1

Binding data in type (dict) is not supported

Binding data in type (dict) is not supported Question: I am trying to write json object into a particular column of my sql table variant_str = response.json() print(con.cursor().execute(‘INSERT INTO TEST_TABLE (JSON_STR) VALUES (?)’, (variant_str,))) Here, the variant_str is of type dict. I get an error that: snowflake.connector.errors.ProgrammingError: 252004: Failed processing pyformat-parameters; 255001: Binding data in …

Total answers: 2

SQLAlchemy Core indexing from list within SQL

SQLAlchemy Core indexing from list within SQL Question: I’m currently trying to convert some of my Snowflake SQL code to SQLAlchemy Core python code and I can’t quite seem to figure out how to convert indexing an array within SQL to SQLAlchemy Core code. For example if I have the following SQL query, how could …

Total answers: 1