You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2021/03/06 10:18:55 UTC

[GitHub] [arrow] Dandandan opened a new pull request #9645: ARROW-11894: Change flight server example to use DataFrame API

Dandandan opened a new pull request #9645:
URL: https://github.com/apache/arrow/pull/9645


   Before this PR, it uses the logical plan / optimization / physical plan more directly.
   As it is meant as example, I think it's better to use the more higher level `sql` and `collect` functions.


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] github-actions[bot] commented on pull request #9645: ARROW-11894: Change flight server example to use DataFrame API

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on pull request #9645:
URL: https://github.com/apache/arrow/pull/9645#issuecomment-791907730


   https://issues.apache.org/jira/browse/ARROW-11894


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] alamb closed pull request #9645: ARROW-11894: [Rust][DataFusion] Change flight server example to use DataFrame API

Posted by GitBox <gi...@apache.org>.
alamb closed pull request #9645:
URL: https://github.com/apache/arrow/pull/9645


   


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] alamb commented on a change in pull request #9645: ARROW-11894: [Rust][DataFusion] Change flight server example to use DataFrame API

Posted by GitBox <gi...@apache.org>.
alamb commented on a change in pull request #9645:
URL: https://github.com/apache/arrow/pull/9645#discussion_r590786673



##########
File path: rust/datafusion/examples/flight_server.rs
##########
@@ -94,28 +94,26 @@ impl FlightService for FlightServiceImpl {
                     "alltypes_plain",
                     &format!("{}/alltypes_plain.parquet", testdata),
                 )
-                .map_err(|e| to_tonic_err(&e))?;
+                .map_err(to_tonic_err)?;
 
-                // create the query plan
-                let plan = ctx
-                    .create_logical_plan(&sql)
-                    .and_then(|plan| ctx.optimize(&plan))
-                    .and_then(|plan| ctx.create_physical_plan(&plan))
-                    .map_err(|e| to_tonic_err(&e))?;
+                // create the DataFrame
+                let df = ctx.sql(sql).map_err(to_tonic_err)?;
 
                 // execute the query
-                let results =
-                    collect(plan.clone()).await.map_err(|e| to_tonic_err(&e))?;
+                let results = df.collect().await.map_err(to_tonic_err)?;
                 if results.is_empty() {
                     return Err(Status::internal("There were no results from ticket"));
                 }
 
+                let physical_plan = ctx

Review comment:
       @Dandandan  I gave this another look prior to merging, and something that looks like a pretty strange example now (where we run the query and get results but then build a second plan to get the schema).
   
   I wonder what you would think about using something more like `let schema = batches[0].schema()` instead?




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] codecov-io commented on pull request #9645: ARROW-11894: [Rust][DataFusion] Change flight server example to use DataFrame API

Posted by GitBox <gi...@apache.org>.
codecov-io commented on pull request #9645:
URL: https://github.com/apache/arrow/pull/9645#issuecomment-792361661


   # [Codecov](https://codecov.io/gh/apache/arrow/pull/9645?src=pr&el=h1) Report
   > Merging [#9645](https://codecov.io/gh/apache/arrow/pull/9645?src=pr&el=desc) (b86061b) into [master](https://codecov.io/gh/apache/arrow/commit/bfa99d98e6f0b49aed079d9f99668390f84a933f?el=desc) (bfa99d9) will **decrease** coverage by `0.06%`.
   > The diff coverage is `0.00%`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/arrow/pull/9645/graphs/tree.svg?width=650&height=150&src=pr&token=LpTCFbqVT1)](https://codecov.io/gh/apache/arrow/pull/9645?src=pr&el=tree)
   
   ```diff
   @@            Coverage Diff             @@
   ##           master    #9645      +/-   ##
   ==========================================
   - Coverage   82.49%   82.43%   -0.07%     
   ==========================================
     Files         245      245              
     Lines       57347    57643     +296     
   ==========================================
   + Hits        47311    47517     +206     
   - Misses      10036    10126      +90     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/arrow/pull/9645?src=pr&el=tree) | Coverage Δ | |
   |---|---|---|
   | [rust/datafusion/examples/flight\_server.rs](https://codecov.io/gh/apache/arrow/pull/9645/diff?src=pr&el=tree#diff-cnVzdC9kYXRhZnVzaW9uL2V4YW1wbGVzL2ZsaWdodF9zZXJ2ZXIucnM=) | `0.00% <0.00%> (ø)` | |
   | [rust/parquet/src/basic.rs](https://codecov.io/gh/apache/arrow/pull/9645/diff?src=pr&el=tree#diff-cnVzdC9wYXJxdWV0L3NyYy9iYXNpYy5ycw==) | `87.22% <0.00%> (-10.04%)` | :arrow_down: |
   | [rust/parquet/src/arrow/array\_reader.rs](https://codecov.io/gh/apache/arrow/pull/9645/diff?src=pr&el=tree#diff-cnVzdC9wYXJxdWV0L3NyYy9hcnJvdy9hcnJheV9yZWFkZXIucnM=) | `77.53% <0.00%> (-0.08%)` | :arrow_down: |
   | [rust/parquet/src/schema/parser.rs](https://codecov.io/gh/apache/arrow/pull/9645/diff?src=pr&el=tree#diff-cnVzdC9wYXJxdWV0L3NyYy9zY2hlbWEvcGFyc2VyLnJz) | `90.20% <0.00%> (ø)` | |
   | [rust/parquet/src/file/footer.rs](https://codecov.io/gh/apache/arrow/pull/9645/diff?src=pr&el=tree#diff-cnVzdC9wYXJxdWV0L3NyYy9maWxlL2Zvb3Rlci5ycw==) | `96.26% <0.00%> (+0.03%)` | :arrow_up: |
   | [rust/parquet/src/file/writer.rs](https://codecov.io/gh/apache/arrow/pull/9645/diff?src=pr&el=tree#diff-cnVzdC9wYXJxdWV0L3NyYy9maWxlL3dyaXRlci5ycw==) | `95.32% <0.00%> (+0.21%)` | :arrow_up: |
   | [rust/parquet/src/schema/types.rs](https://codecov.io/gh/apache/arrow/pull/9645/diff?src=pr&el=tree#diff-cnVzdC9wYXJxdWV0L3NyYy9zY2hlbWEvdHlwZXMucnM=) | `89.79% <0.00%> (+0.25%)` | :arrow_up: |
   | [rust/parquet/src/file/metadata.rs](https://codecov.io/gh/apache/arrow/pull/9645/diff?src=pr&el=tree#diff-cnVzdC9wYXJxdWV0L3NyYy9maWxlL21ldGFkYXRhLnJz) | `92.96% <0.00%> (+0.74%)` | :arrow_up: |
   | [rust/arrow/src/array/equal/utils.rs](https://codecov.io/gh/apache/arrow/pull/9645/diff?src=pr&el=tree#diff-cnVzdC9hcnJvdy9zcmMvYXJyYXkvZXF1YWwvdXRpbHMucnM=) | `76.47% <0.00%> (+0.98%)` | :arrow_up: |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/arrow/pull/9645?src=pr&el=continue).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/arrow/pull/9645?src=pr&el=footer). Last update [bfa99d9...b86061b](https://codecov.io/gh/apache/arrow/pull/9645?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
   


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] alamb commented on pull request #9645: ARROW-11894: [Rust][DataFusion] Change flight server example to use DataFrame API

Posted by GitBox <gi...@apache.org>.
alamb commented on pull request #9645:
URL: https://github.com/apache/arrow/pull/9645#issuecomment-792263737


   BTW the test workspace check is also failing on master, so it may not be related to this PR. See more details on https://issues.apache.org/jira/browse/ARROW-11896


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] alamb commented on pull request #9645: ARROW-11894: [Rust][DataFusion] Change flight server example to use DataFrame API

Posted by GitBox <gi...@apache.org>.
alamb commented on pull request #9645:
URL: https://github.com/apache/arrow/pull/9645#issuecomment-792324979


   FYI I merged https://github.com/apache/arrow/pull/9653 / [ARROW-11896](https://issues.apache.org/jira/browse/ARROW-11896) for the Rust CI checks which may affect this PR. If you see "Rust / AMD64 Debian 10 Rust stable test workspace" failing  with a linker error or no logs, rebasing against master will hopefully fix the problem


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] alamb commented on a change in pull request #9645: ARROW-11894: [Rust][DataFusion] Change flight server example to use DataFrame API

Posted by GitBox <gi...@apache.org>.
alamb commented on a change in pull request #9645:
URL: https://github.com/apache/arrow/pull/9645#discussion_r593885249



##########
File path: rust/datafusion/examples/flight_server.rs
##########
@@ -94,28 +94,22 @@ impl FlightService for FlightServiceImpl {
                     "alltypes_plain",
                     &format!("{}/alltypes_plain.parquet", testdata),
                 )
-                .map_err(|e| to_tonic_err(&e))?;
+                .map_err(to_tonic_err)?;
 
-                // create the query plan
-                let plan = ctx
-                    .create_logical_plan(&sql)
-                    .and_then(|plan| ctx.optimize(&plan))
-                    .and_then(|plan| ctx.create_physical_plan(&plan))
-                    .map_err(|e| to_tonic_err(&e))?;
+                // create the DataFrame
+                let df = ctx.sql(sql).map_err(to_tonic_err)?;
 
                 // execute the query
-                let results =
-                    collect(plan.clone()).await.map_err(|e| to_tonic_err(&e))?;
+                let results = df.collect().await.map_err(to_tonic_err)?;
                 if results.is_empty() {
                     return Err(Status::internal("There were no results from ticket"));
                 }
 
                 // add an initial FlightData message that sends schema
                 let options = arrow::ipc::writer::IpcWriteOptions::default();
-                let schema = plan.schema();
                 let schema_flight_data =
                     arrow_flight::utils::flight_data_from_arrow_schema(
-                        schema.as_ref(),
+                        &df.schema().clone().into(),

Review comment:
       ❤️  -- looks great @Dandandan 




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] Dandandan commented on a change in pull request #9645: ARROW-11894: [Rust][DataFusion] Change flight server example to use DataFrame API

Posted by GitBox <gi...@apache.org>.
Dandandan commented on a change in pull request #9645:
URL: https://github.com/apache/arrow/pull/9645#discussion_r592744922



##########
File path: rust/datafusion/examples/flight_server.rs
##########
@@ -94,28 +94,26 @@ impl FlightService for FlightServiceImpl {
                     "alltypes_plain",
                     &format!("{}/alltypes_plain.parquet", testdata),
                 )
-                .map_err(|e| to_tonic_err(&e))?;
+                .map_err(to_tonic_err)?;
 
-                // create the query plan
-                let plan = ctx
-                    .create_logical_plan(&sql)
-                    .and_then(|plan| ctx.optimize(&plan))
-                    .and_then(|plan| ctx.create_physical_plan(&plan))
-                    .map_err(|e| to_tonic_err(&e))?;
+                // create the DataFrame
+                let df = ctx.sql(sql).map_err(to_tonic_err)?;
 
                 // execute the query
-                let results =
-                    collect(plan.clone()).await.map_err(|e| to_tonic_err(&e))?;
+                let results = df.collect().await.map_err(to_tonic_err)?;
                 if results.is_empty() {
                     return Err(Status::internal("There were no results from ticket"));
                 }
 
+                let physical_plan = ctx

Review comment:
       Agree, your comment makes sense. Will have a look later.




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] Dandandan commented on a change in pull request #9645: ARROW-11894: [Rust][DataFusion] Change flight server example to use DataFrame API

Posted by GitBox <gi...@apache.org>.
Dandandan commented on a change in pull request #9645:
URL: https://github.com/apache/arrow/pull/9645#discussion_r593884833



##########
File path: rust/datafusion/examples/flight_server.rs
##########
@@ -94,28 +94,26 @@ impl FlightService for FlightServiceImpl {
                     "alltypes_plain",
                     &format!("{}/alltypes_plain.parquet", testdata),
                 )
-                .map_err(|e| to_tonic_err(&e))?;
+                .map_err(to_tonic_err)?;
 
-                // create the query plan
-                let plan = ctx
-                    .create_logical_plan(&sql)
-                    .and_then(|plan| ctx.optimize(&plan))
-                    .and_then(|plan| ctx.create_physical_plan(&plan))
-                    .map_err(|e| to_tonic_err(&e))?;
+                // create the DataFrame
+                let df = ctx.sql(sql).map_err(to_tonic_err)?;
 
                 // execute the query
-                let results =
-                    collect(plan.clone()).await.map_err(|e| to_tonic_err(&e))?;
+                let results = df.collect().await.map_err(to_tonic_err)?;
                 if results.is_empty() {
                     return Err(Status::internal("There were no results from ticket"));
                 }
 
+                let physical_plan = ctx

Review comment:
       I "discovered" you can make a `DFSchema` an arrow `Schema` again with `df.schema().clone().into()` which I think is maybe even better?
   
   The approach to use `batches[0]` here doesn't work as the batches have type `Result<FlightData, Status>`, so that would probable need some more "extraction" to retrieve the schema.




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] alamb commented on pull request #9645: ARROW-11894: [Rust][DataFusion] Change flight server example to use DataFrame API

Posted by GitBox <gi...@apache.org>.
alamb commented on pull request #9645:
URL: https://github.com/apache/arrow/pull/9645#issuecomment-793120678


   I tried to retrigger the jobs on this PR as I think `integration` is failing due to https://issues.apache.org/jira/browse/ARROW-11908


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org