djanand opened a new pull request, #1883:
URL: https://github.com/apache/datafusion-ballista/pull/1883

   # Which issue does this PR close?
   
   <!--
   We generally require a GitHub issue to be filed for all bug fixes and 
enhancements and this helps us generate change logs for our releases. You can 
link an issue to this PR using the GitHub syntax. For example `Closes #123` 
indicates that this PR will close issue #123.
   -->
   
   Closes #.
   
    # Rationale for this change
   <!--
    Why are you proposing this change? If this is already explained clearly in 
the issue then this section is not needed.
    Explaining clearly why changes are proposed helps reviewers understand your 
changes and offer better suggestions for fixes.  
   -->
   The `%%sql` Jupyter 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 
match
   the documented contract, including the `(default: 50)` already promised in 
the [help 
text](https://github.com/apache/datafusion-ballista/blob/main/python/python/ballista/jupyter.py#L490-L491).
   
   # What changes are included in this PR?
   <!--
   There is no need to duplicate the description in the issue here but it is 
sometimes worth providing a summary of the individual changes in this PR.
   -->
   In `python/python/ballista/jupyter.py`:
     - Added `_parse_cell_magic_args()`, which parses `--limit N` and 
`--no-display` plus the optional variable name, using the same hand-rolled 
`line.split()` convention as the other magics in this module (`%ballista`, 
`%register`). Invalid `--limit` values (missing / non-integer / non-positive) 
return a clear message instead of raising.
     - `--limit N` caps the **display** to N rows via datafusion's 
`configure_formatter(max_rows=N, min_rows=N)`. This is display-only — it never 
truncates the underlying data, so an in-query `LIMIT` always takes effect. When 
`--limit` is omitted, the display falls back to a default of 50.
     - `--no-display` runs the query, stores the result in the variable if one 
is given, and renders nothing.
     - Updated the `sql()` docstring and the `%ballista help` text.
     
    Docs: added a short `--limit` / `--no-display` example to the "SQL Magic 
Commands" section of `python/README.md`.
   
    Tests in `python/python/tests/test_jupyter.py`:
     - A cluster-free unit test for the argument parser (valid cases + invalid 
`--limit` rejection).
     - An integration test covering `--limit` (display cap set, data not 
truncated), the default cap, `--no-display`, and the invalid-`--limit` error 
path.
     
   # Are there any user-facing changes?
   <!--
   If there are user-facing changes then we may require documentation to be 
updated before approving the PR.
   -->
   Yes, the previously documented `--limit` and `--no-display` options on the 
`%%sql` cell magic now work. The README is updated accordingly.
   The only behavioral change to existing usage: a `%%sql` cell now renders up 
to **50** rows by default (the value the help text already documented 
[here](https://github.com/apache/datafusion-ballista/blob/main/python/python/ballista/jupyter.py#L490-L491))
 instead of datafusion's built-in default of 10. This affects rendered rows 
only. Query results are never truncated, and in-query `LIMIT` is unaffected.
   
   Note: `--limit` is implemented via datafusion's global HTML formatter, so 
each `%%sql` cell re-sets the display cap. The cap also applies to subsequent 
non-`%%sql`
     DataFrame displays in the same kernel until changed
   <!--
   If there are any breaking changes to public APIs, please add the `api 
change` label.
   -->
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to