Repository navigation
fix(to_sql): write empty datasets so if_exists="replace" replaces the… - #9293
Open
Sailaja-ASB wants to merge 1 commit into
Open
Sailaja-ASB wants to merge 1 commit into
Sailaja-ASB wants to merge 1 commit into
Conversation
… table Handle empty dataset case in SQL writing process.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #9289
An empty dataset never enters the batch loop in
SqlDatasetWriter._write, so the pandas writer never runs andDataset.to_sql(if_exists="replace")leaves an existing table (and its stale rows) untouched.This adds a guard at the start of
_write: for an empty dataset, it calls_batch_sqlonce with offset 0, which keeps the originalto_sql_kwargs(soif_exists="replace"is preserved) and lets pandas create/replace an empty table with the correct columns. This single direct call covers both the serial and parallel paths without spawning a pool for an empty dataset.No test suite was run.