2010YOUY01 opened a new pull request, #7617:
URL: https://github.com/apache/arrow-datafusion/pull/7617

   ## 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.
   -->
   
   NA
   
   ## Rationale for this change
   
   If a query outputs a large number of lines, currently datafusion-cli will 
display them all and flood the terminal.
   This PR added a `--maxrows` option to limit max number of rows for output 
display.
   ```bash
   --maxrows <MAXROWS>
               The max number of rows to display for 'Table' format
               [default: 40] [possible values: numbers(0/10/...), inf(no limit)]
   ```
   ```
   arrow-datafusion/datafusion-cli|cli-large-output🌝| >>> cargo run --release 
-- --maxrows 5
       Finished release [optimized] target(s) in 0.30s
        Running `target/release/datafusion-cli --maxrows 5`
   DataFusion CLI v31.0.0
   ❯ CREATE EXTERNAL TABLE lineitem STORED AS PARQUET LOCATION 
'/Users/yongting/Desktop/code/my_datafusion/arrow-datafusion/benchmarks/data/tpch_sf10/lineitem/part-0.parquet';
   0 rows in set. Query took 0.041 seconds.
   
   ❯ select l_orderkey, l_partkey from lineitem;
   +------------+-----------+
   | l_orderkey | l_partkey |
   +------------+-----------+
   | 1          | 1551894   |
   | 1          | 673091    |
   | 1          | 636998    |
   | 1          | 21315     |
   | 1          | 240267    |
   | .                      |
   | .                      |
   | .                      |
   +------------+-----------+
   59986052 rows in set (5 shown). Query took 2.451 seconds.
   ```
   <!--
    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.  
   -->
   
   ## What changes are included in this PR?
   
   1. Change elapsed time measurement in CLI to (query start -> all result 
ready in memory in `[RecordBatch]`), before it also counts the time for 
formatting and printing the results.
   2. Add `--maxrows` option, now only `Table` CLI display format is supported.
   <!--
   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.
   -->
   
   ## Are these changes tested?
   
   Unit tests
   <!--
   We typically require tests for all PRs in order to:
   1. Prevent the code from being accidentally broken by subsequent changes
   3. Serve as another way to document the expected behavior of the code
   
   If tests are not included in your PR, please explain why (for example, are 
they covered by existing tests)?
   -->
   
   ## Are there any user-facing changes?
   
   No
   <!--
   If there are user-facing changes then we may require documentation to be 
updated before approving the PR.
   -->
   
   <!--
   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]

Reply via email to