-
Notifications
You must be signed in to change notification settings - Fork 76
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
%sqlplot bar and pie charts #508
Conversation
hey @jorisroovers, wanna take a look at this and share your feedback? you can see an interactive demo here: https://binder.ploomber.io/v2/gh/mehtamohit013/jupysql/plot?urlpath=lab/tree/doc/api/magic-plot.md (scroll down to see the bar and pie chart examples) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mehtamohit013
added some comments.
also, please rebase.
Looking pretty good. Some feedback from spending a few mins...
|
You can test out the above changes on binder
|
Waiting for #486 to merge |
doc/api/magic-plot.md
Outdated
|
||
`-sn`/`--show_num` Show number on top of the bar | ||
|
||
Barplot does not support NULL values, so let's remove them: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we add support for NULL values? you can run a query to filter them first
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should I raise some warning when there is NULL?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good point. not a warnings.warn, but printing a message saying that we're removing NULLs makes sense
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should the message be printed only when there is NULL or a generic message?
Currently added a general message:
print(f"Removing NULLs, if there exists any from {column}")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i didn't think about this. we have two options
- check if there is a null (by querying the table). if so, show a message and filter them out
- embed the null filter in the existing SQL queries as a subquery - this will impact performance but I'm guessing most SQL engines are smart enough to just pass the data once
let's implement 2. this implies that we won't show any message to the user since we'll filter out NULLs all the time - so there's no point in showing a message. we can later optimize.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@edublancas
Implemented 2
option + Generic null Message for info :
Sample SQL query:
select "{{x_}}" as x,
"{{height_}}" as height
from "{{table}}"
where "{{x_}}" is not null
and "{{height_}}" is not null;
@mehtamohit013 We shouldn't wait for the merge. Also, I see you addressed some of the issues. Please mark the issues you have fixed as "resolved" so that it will be easier to review them again. P.S please rebase |
Removed print statement
@yafimvo @edublancas Any idea why this is happening? |
this has happened before. usually fonts are the problem (even if you have the same matplotlib version, the fonts might be different). there's an option to ignore text while testing, if this doesn't fix the issue, it'll be a bit challenging to debug because we don't have access to the failed images (I just opened this: #543) see if you can quickly fix this, @mehtamohit013. if not, let me know and we can block this, you can work on #543 and then we can resume this work |
@mehtamohit013 Try to use these images |
Thanks, @yafimvo, matplotlib tests are now working. |
@edublancas |
@mehtamohit013 The images failed due to minor font-weight differences so I just created new base images with the expected font-weights. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is almost ready. just implement the NULL support and show a message to the user
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
address the NULLs comment and add a unit test with some dataset that has NULLs
@edublancas |
@edublancas |
awesome work! |
Describe your changes
Added bar and pie chart to sqlplot
Issue number
Closes #417
Checklist before requesting a review
pkgmt format
📚 Documentation preview 📚: https://jupysql--508.org.readthedocs.build/en/508/