Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SNOW-617426: Ability to overwrite tables when using write_pandas() #1175

Closed
iamontheinet opened this issue Jun 23, 2022 · 5 comments · Fixed by #1186
Closed

SNOW-617426: Ability to overwrite tables when using write_pandas() #1175

iamontheinet opened this issue Jun 23, 2022 · 5 comments · Fixed by #1186

Comments

@iamontheinet
Copy link
Member

What is the current behavior?

Using the write_pandas() API there is no way to overwrite contents of a Snowflake table with that of a Pandas DataFrame without first executing a truncate SQL statement.

What is the desired behavior?

Using the write_pandas() API there should be a way to optionally overwrite contents of a Snowflake table with that of a Pandas DataFrame.

How would this improve snowflake-connector-python?

Better user experience for Python developers and especially those devs that are not familiar with truncate SQL statement or know how to write SQL.

References, Other Background

Similar to overwriting contents of a Snowflake table when writing contents of Snowpark DataFrames using df.write.mode('overwrite')

@github-actions github-actions bot changed the title Ability to overwrite tables when using write_pandas() SNOW-617426: Ability to overwrite tables when using write_pandas() Jun 23, 2022
@mhconradt
Copy link

Under the hood, write_pandas runs a COPY statement which is append-only. I recommend using TRUNCATE TABLE tbl IF EXISTS if you want to overwrite the rows in the table, or DROP TABLE IF EXISTS if you want to replace the table itself.

@iamontheinet
Copy link
Member Author

Yes, I am looking into DROP TABLE IF EXIST which will account for any schema change(s) in the Pandas DataFrame. Thanks!

@simonwardjones
Copy link

I have made a similar issue here with a proposed solution: #1141

@simonwardjones
Copy link

@mhconradt would it be worth me making the PR I suggested or better to implement a work around in our application code?

@iamontheinet
Copy link
Member Author

I am working on a solution as described in my comment above and will be creating a PR pretty soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants