francis-du commented on a change in pull request #923:
URL: https://github.com/apache/arrow-datafusion/pull/923#discussion_r693898063



##########
File path: datafusion/src/dataframe.rs
##########
@@ -223,6 +223,21 @@ pub trait DataFrame: Send + Sync {
     /// ```
     async fn collect(&self) -> Result<Vec<RecordBatch>>;
 
+    /// Print results.
+    ///
+    /// ```
+    /// # use datafusion::prelude::*;
+    /// # use datafusion::error::Result;
+    /// # #[tokio::main]
+    /// # async fn main() -> Result<()> {
+    /// let mut ctx = ExecutionContext::new();
+    /// let df = ctx.read_csv("tests/example.csv", CsvReadOptions::new())?;
+    /// df.show().await?;
+    /// # Ok(())
+    /// # }
+    /// ```
+    async fn show(&self) -> Result<()>;

Review comment:
       I think it can be inferred from the logical plan whether there is a 
limit number. If there is no limit, set it to the default value of 20. If there 
is, then the default limit value is not set.
   
   This is an implementation:
   
   ```rust
   async fn show(&self) -> Result<()> {
       let mut num = 20;
       if let LogicalPlan::Limit { n, input: _ } = self.to_logical_plan() {
           num = n;
       }
       let results = self.limit(num)?.collect().await?;
       Ok(pretty::print_batches(&results)?)
   }
   ```
   
   The user can call the limit function to pass in the number of lines, if 
limit is not used, only the default 20 lines will be printed.
   
   eg:
   
   ```rust
   df.limit(10)?.show().await?; // limit 10
   
   df.show().await?; // default limit 20
   ```




-- 
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