feat: add %%sql --limit and --no-display support#1883
Open
djanand wants to merge 1 commit into
Open
Conversation
Contributor
Author
|
@coderfender @martin-g - ptal |
Contributor
Author
Design note: why not use
|
Contributor
Author
Why python release build fails ?python/ is a separate Cargo workspace (excluded from the main one) with its own Cargo.lock, and it path-depends on the main ballista crates. But:
So the lock goes stale on main itself every time deps move, and the next contributor inherits a red build. Kindly let me know your thoughts edit: Raised #1887 |
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.
Which issue does this PR close?
Closes #.
Rationale for this change
The
%%sqlJupyter cell magic advertises two options in its help text that were never actually implemented:--no-display - Don't display results
--limit N - Limit displayed rows (default: 50)
The argument-parsing loop only extracted a variable name, it scanned all tokens and kept the last non-flag, never breaking, silently dropping any
--flag. So the documented options were ignored. This PR makes the behavior matchthe documented contract, including the
(default: 50)already promised in the help text.What changes are included in this PR?
In
python/python/ballista/jupyter.py:_parse_cell_magic_args(), which parses--limit Nand--no-displayplus the optional variable name, using the same hand-rolledline.split()convention as the other magics in this module (%ballista,%register). Invalid--limitvalues (missing / non-integer / non-positive) return a clear message instead of raising.--limit Ncaps the display to N rows via datafusion'sconfigure_formatter(max_rows=N, min_rows=N). This is display-only — it never truncates the underlying data, so an in-queryLIMITalways takes effect. When--limitis omitted, the display falls back to a default of 50.--no-displayruns the query, stores the result in the variable if one is given, and renders nothing.sql()docstring and the%ballista helptext.Docs: added a short
--limit/--no-displayexample to the "SQL Magic Commands" section ofpython/README.md.Tests in
python/python/tests/test_jupyter.py:--limitrejection).--limit(display cap set, data not truncated), the default cap,--no-display, and the invalid---limiterror path.Are there any user-facing changes?
Yes, the previously documented
--limitand--no-displayoptions on the%%sqlcell magic now work. The README is updated accordingly.The only behavioral change to existing usage: a
%%sqlcell now renders up to 50 rows by default (the value the help text already documented here) instead of datafusion's built-in default of 10. This affects rendered rows only. Query results are never truncated, and in-queryLIMITis unaffected.Note:
--limitis implemented via datafusion's global HTML formatter, so each%%sqlcell re-sets the display cap. The cap also applies to subsequent non-%%sqlDataFrame displays in the same kernel until changed