snowflakedb / snowflakedb/snowflake-connector-python
SNOW-649836: insert null into a variant column
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 730
- Forks
- 574
- Avg merge
- 5h 45m
- Merged PRs (30d)
- 16
Description
What is the current behavior?
I have a variant column with multiple fields inside it, whenever there is a None, it doesnt insert that particular key in variant column and just skips it -
df2 = pd.DataFrame([('Mark', {'K': 2,'Z':None}), ('Luke', {'K': 4,'Z':'bla'})], columns=['ID', 'V'])
when i do write_pandas on it using this
# Write the data from the DataFrame to the table named "customers".
success, nchunks, nrows, _ = write_pandas(ctx, df2, 'customers')
This is how it inserts in snowflake now.
row ID V
1 Mark { "K": 2 }
2 Luke { "K": 4, "Z": "bla" }
What is the desired behavior?
It should look in snowflake table like this.
row ID V
1 Mark { "K": 2 ,"Z":NULL}
2 Luke { "K": 4, "Z": "bla" }
How would this improve snowflake-connector-python?
There is no option available to insert null value for a key in variant columns, snowflake allows it thought it interface, but its not possible to do it using write_pandas
References, Other Background
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the write_pandas entry point and reproduce the DataFrame example with a variant column containing a None value. Trace how nested dictionaries are serialized before insertion, then verify that the resulting row preserves the Z key with a NULL value while the existing non-null row remains unchanged.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- pandas, python
- Domain
- data, database
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100