-
Notifications
You must be signed in to change notification settings - Fork 7
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
Fix chart cell to handle empty data sets #20
Fix chart cell to handle empty data sets #20
Conversation
Hi @rliebling! The third element is not guaranteed to be a list, so perhaps the alternative fix is the way to go? Thank you! |
211d864
to
f4215aa
Compare
@josevalim Thanks for pointing that out! I updated the code, and the description of the PR. This feels clean, but I realized after that maybe one would still want to choose the empty dataset or at least you might get bug reports if they are not offered as choices. I'm fine changing to allow that, if you prefer. Just please let me know what |
@rliebling ah, that's another great idea. We could show empty datasets but we rule out any dataset without columns, and that will remove silly false positives such as empty lists (or empty maps). |
A list of |
Sounds good - thanks! will get to this in a couple days. I assume nobody else is urgently waiting on this so the delay is fine. |
343aa02
to
f610644
Compare
Ok - thinks this should be good now. |
Issue is `infer_types({:rows, _, _})` assumes that there is at least 1 row so that it can `Enum.map` over the columns. We will check in `columns_for` that the list of columns is not empty. If so, and the dataset is empty, then the new implementation of `infer_types()` will return a list of `nil`s to allow the scan to succeed but without inferred types.
f610644
to
b445214
Compare
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.
Great, thank you!
Thank you both for your patience! You set a terrific example for the community (and open source) - when it undoubtedly would have been easier for you to just fix my initial attempts and commit it than to give me the feedback. |
If you create a Chart smart cell while some of your bindings are for datasets with no results then the Chart cell fails to work. That is, you cannot choose any dataset in the "Data" input field. The problem is that the private function
infer_types
encounters an error because for the :rows case because it assumes there is at least one row.The solution here is to explicitly check for whether the dataset has data. This does mean that a result set with no data won't be offered as a choice in the Chart smart cell. I could see instead having
infer_types()
return a list matching the length of the columns, but with eithernil
or"nominal"
for each value so that the dataset would be allowed when empty.