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

--persist-replace argument #440

Conversation

tonykploomber
Copy link

@tonykploomber tonykploomber commented Apr 24, 2023

Describe your changes

Add --persist-replace argument

Issue number

Closes #154

Checklist before requesting a review


📚 Documentation preview 📚: https://jupysql--440.org.readthedocs.build/en/440/

@tonykploomber tonykploomber requested a review from yafimvo April 24, 2023 07:53
Copy link

@yafimvo yafimvo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added some comments.

Question - can we detect if the user tries to use --persist for the 2nd time and suggest him to use --persist-replace instead?

doc/integrations/pandas.md Show resolved Hide resolved
src/tests/test_magic.py Show resolved Hide resolved
src/tests/test_magic.py Show resolved Hide resolved
src/sql/magic.py Show resolved Hide resolved
src/sql/magic.py Outdated Show resolved Hide resolved
src/sql/magic.py Outdated Show resolved Hide resolved
src/tests/test_magic.py Outdated Show resolved Hide resolved
@tonykploomber
Copy link
Author

@yafimvo

I checked the preview doc, somehow there is the empty cell in the original --persist section, do you think our PR affect this?

Screenshot 2023-04-26 at 12 19 48 AM

@tonykploomber
Copy link
Author

@idomic

Now if we use --persist twice it will suggest to use --persist-replace

Screenshot 2023-04-26 at 12 16 07 AM

Copy link

@yafimvo yafimvo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added some minor comments

src/sql/magic.py Outdated Show resolved Hide resolved
src/tests/test_magic.py Outdated Show resolved Hide resolved
src/tests/test_magic.py Outdated Show resolved Hide resolved
src/tests/test_magic.py Outdated Show resolved Hide resolved
src/tests/test_magic.py Outdated Show resolved Hide resolved
src/tests/test_magic.py Outdated Show resolved Hide resolved
src/tests/test_magic.py Outdated Show resolved Hide resolved
src/tests/test_magic.py Show resolved Hide resolved
src/tests/test_magic.py Outdated Show resolved Hide resolved
@idomic
Copy link

idomic commented Apr 26, 2023

Now if we use --persist twice it will suggest to use --persist-replace

I assume this isn't an expected behavior? If not fix it, if yes document it
Also I didn't get your point on the empty cell, we shouldn't have empty cells, if it's like that in the docs we should fix it.

@tonykploomber
Copy link
Author

Still figuring out why the empty cell was generated...

@yafimvo
Copy link

yafimvo commented Apr 27, 2023

checked the preview doc, somehow there is the empty cell in the original --persist section, do you think our PR affect this?

I don't think it's related to your changes in this PR, but it might be a good idea to remove it since it's a small and simple change that will make the documentation cleaner without affecting anything else.

@idomic
Copy link

idomic commented Apr 28, 2023

@tonykploomber please fix and resolve comments.

Copy link

@yafimvo yafimvo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we're missing the most important part of the test. We need to make sure --persist-replace overrides the previous data. To do it, we need to use 2 different datasets.

saved_df_name = get_table_rows_as_dataframe(ip, table_name=test_table)
ip.run_cell(f"%sql --persist sqlite:// {saved_df_name}")
saved_df_name = get_table_rows_as_dataframe(ip, table_name=test_table)
ip.run_cell(f"%sql --persist-replace sqlite:// {saved_df_name}")
assert out.result == expected_result

even if --persist-replace doesn't work, it will return True.
Please note, this is valid for the contrapositive tests as well (i.e. test_persist_replace_no_override). If you are using the same data, it will be difficult to determine whether it was not overridden.

src/sql/magic.py Outdated Show resolved Hide resolved
src/tests/test_magic.py Show resolved Hide resolved
src/tests/test_magic.py Show resolved Hide resolved
src/tests/test_magic.py Outdated Show resolved Hide resolved
@tonykploomber
Copy link
Author

tonykploomber commented May 16, 2023

@yafimvo
Actually we've discussed this about this is previous comment. That's why previous query_and_save_as_dataframe function has limit parameter to generate a different dataset to test the override effect.

We can also just get the different dataframe by putting different table_name to get_table_rows_as_dataframe.

Please review again

@tonykploomber tonykploomber requested a review from yafimvo May 16, 2023 08:08
Copy link

@yafimvo yafimvo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually we've discussed this about this is previous comment. That's why previous query_and_save_as_dataframe function has limit parameter to generate a different dataset to test the override effect.

Since we didn't check for different lengths, I suggested setting the limit parameter as optional and making this function return X rows of a given table as a dataframe.

We can also just get the different dataframe by putting different table_name to get_table_rows_as_dataframe.

I see you implemented something like this.

LGTM. just minor fixes.

src/tests/test_magic.py Outdated Show resolved Hide resolved
src/tests/test_magic.py Outdated Show resolved Hide resolved
src/tests/test_magic.py Outdated Show resolved Hide resolved
@tonykploomber
Copy link
Author

This is blocked by CI test failing issue

…persist-replace-argument-if-there-is-existing-table
@tonykploomber
Copy link
Author

@yafimvo This is ready for review again

Copy link

@edublancas edublancas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it looks good overall, added some minor comments

CHANGELOG.md Outdated Show resolved Hide resolved
src/sql/magic.py Show resolved Hide resolved
src/sql/magic.py Outdated Show resolved Hide resolved
src/sql/magic.py Outdated Show resolved Hide resolved
src/sql/magic.py Outdated Show resolved Hide resolved
Copy link

@edublancas edublancas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just show a proper warning

@tonykploomber tonykploomber requested a review from edublancas May 26, 2023 19:09
@tonykploomber
Copy link
Author

Please review again

CHANGELOG.md Outdated
Comment on lines 12 to 10
* [Feature] Better error messages when function used in plotting API unsupported by DB driver (#159)
* [Fix] Fix the default value of %config SqlMagic.displaylimit to 10 (#462)
* [Feature] Detailed error messages when syntax error in SQL query, postgres connection password missing or inaccessible, invalid DuckDB connection string (#229)
* [Feature] Adds `--persist-replace` argument (#440)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like some rebase went bad? I see some entries in the changelog are deleted

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you check again? I rebase again
Screenshot 2023-05-27 at 4 31 35 AM

…persist-replace-argument-if-there-is-existing-table
@tonykploomber tonykploomber requested a review from edublancas May 27, 2023 08:32
@edublancas edublancas removed the request for review from idomic May 27, 2023 16:36
@edublancas edublancas merged commit 0aea053 into ploomber:master May 27, 2023
edublancas pushed a commit that referenced this pull request May 27, 2023
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 this pull request may close these issues.

Proposal: Add --persist-replace argument if there is existing table
4 participants