Open AidanShipperley opened 4 weeks ago
Small update, this is also affecting all date and time data types as well. The complete list of data types that this issue appears to be affecting currently is:
[
"NUMBER",
"DECIMAL",
"NUMERIC",
"INT",
"INTEGER",
"BIGINT",
"SMALLINT",
"TINYINT",
"BYTEINT",
"FLOAT",
"FLOAT4",
"FLOAT8",
"DOUBLE",
"DOUBLE PRECISION",
"REAL",
"DATE",
"DATETIME",
"TIME",
"TIMESTAMP",
"TIMESTAMP_LTZ",
"TIMESTAMP_NTZ",
"TIMESTAMP_TZ"
]
Hello @AidanShipperley ,
Thanks for raising the issue, we are looking into it, will update.
Regards, Sujan
Hello @AidanShipperley ,
The same code works in Jupyter with snowpark. session.sql("insert into TEST_TABLE_NULLABILITY (ID) VALUES (?)", params=[None]).collect()
It seems the issue with Python worksheet where it's not treating the query as Direct SQL Embedding Example: INSERT INTO TEST_TABLE_NULLABILITY (ID) VALUES (NULL)
Snowpark for Python expects direct SQL syntax with the appropriate values embedded directly or bound using Snowflake's DataFrame API.
Example:
data = [(None,)] schema = StructType([StructField("ID", IntegerType())]) df = session.create_dataframe(data, schema=schema) df.write.save_as_table("TEST_TABLE_NULLABILITY", mode="append") result = session.table("TEST_TABLE_NULLABILITY").collect() for row in result: print(row)
`
We are checking and will update further.
Regards, Sujan
Output: `Row(ID=None)
Description of Issue
Any attempt to insert a value of
None
into a column with any of the numeric data types in Snowflake via the .sql Snowpark function and qmark parameter bindings results in the following error:How to Reproduce
I am running my Python code inside of a Python Worksheet that I am accessing on Snowflake itself (app.snowflake.com), my account is through my job. I apologize if that makes reproducing results difficult, and I am using
snowflake-snowpark-python==1.16.0
because that is the latest that is available to me on my Snowflake worksheets.What version of Python are you using?
3.11
What operating system and processor architecture are you using?
Linux-5.4.181-99.354.amzn2.aarch64-aarch64-with-glibc2.34
What are the component versions in the environment (
pip freeze
)?What did you do?
Below is the simplest code snippet I could create to reproduce the error, and it will run inside of a Snowflake worksheet as soon as you change the
my_db
andmy_schema
parameters at the top to point to your Database and Schema. I've written a comment so you can see which line triggers the error.What did you expect to see?
All numeric data types (
NUMBER
,FLOAT
,INT
,DOUBLE
) result in the code erroring out, but this should not be happening. Running the exact same script withVARCHAR
as the data type instead ofNUMBER
results in the code succeeding and successfully inserting a null value into the table for the ID column. Additionally, if you just hardcodeNULL
instead of using the safe qmark parameter bindings for the.sql
call, the code does not error and successfully inserts a null value into the table for theID
column:Can you set logging to DEBUG and collect the logs?
I've attached a log from the execution of my above script that errors out:
Please let me know if there is anything else that I can provide.