yuribudilov commented on issue #769:
URL: 
https://github.com/apache/arrow-datafusion/issues/769#issuecomment-885293375


   thank you. 
   
   One compilation error is now gone but replaced by another 2 compilation 
errors, one step forward, two steps back.
   
   Repro:
   
   on https://github.com/apache/arrow-datafusion there is Rust code sample 
given (quote), which does not compile:
   
   use arrow::record_batch::RecordBatch;
   use arrow::util::pretty::print_batches;
   use datafusion::prelude::*;
   
   #[tokio::main]
   async fn main() -> datafusion::error::Result<()> {
       // register the table
       let mut ctx = ExecutionContext::new();
       ctx.register_csv("example", "tests/example.csv", CsvReadOptions::new())?;
   
       // create a plan to run a SQL query
       let df = ctx.sql("SELECT a, MIN(b) FROM example GROUP BY a LIMIT 100")?;
   
       // execute and print results
       let results: Vec<RecordBatch> = df.collect().await?; // error 1 here
       print_batches(&results)?; // error 2 here
       Ok(())
   }
   
   The TOML on the link only shows one line: datafusion = "4.0.0-SNAPSHOT"
   
   This TOML does not work because there is no arrow and no tokio dependency in 
TOML.
   So I added those myself.
   
   Here is what I have now, which still does not work:
   [package]
   name = "test_arrow"
   version = "0.1.0"
   edition = "2018"
   [dependencies]
   # arrow = "5.0.0"
   datafusion = "4.0.0"
   tokio = "1.8.2"
   arrow = { version = "5.0", features = ["prettyprint"] }
   
   
   I still have 2 compilation errors based on above:
   
   15 |     let results: Vec<RecordBatch> = df.collect().await?; // error 1
      |                                     ^^^^^^^^^^^^^^^^^^^ expected struct 
`arrow::record_batch::RecordBatch`, found a different struct 
`arrow::record_batch::RecordBatch`
      |
      = note: expected struct `Vec<arrow::record_batch::RecordBatch>` (struct 
`arrow::record_batch::RecordBatch`)
                 found struct `Vec<arrow::record_batch::RecordBatch>` (struct 
`arrow::record_batch::RecordBatch`)
      = note: perhaps two different versions of crate `arrow` are being used?
   note: return type inferred to be `Vec<arrow::record_batch::RecordBatch>` here
     --> src\main.rs:9:5
      |
   9  |     ctx.register_csv("example", "tests/example.csv", 
CsvReadOptions::new())?;
      |     
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   
   error[E0277]: `?` couldn't convert the error to `DataFusionError`
     --> src\main.rs:16:28
      |
   16 |     print_batches(&results)?; // error 2
      |                            ^ the trait `From<arrow::error::ArrowError>` 
is not implemented for `DataFusionError`
      |
      = note: the question mark operation (`?`) implicitly performs a 
conversion on the error value using the `From` trait
      = help: the following implementations were found:
                <DataFusionError as From<arrow::error::ArrowError>>
                <DataFusionError as From<parquet::errors::ParquetError>>
                <DataFusionError as From<sqlparser::parser::ParserError>>
                <DataFusionError as From<std::io::Error>>
      = note: required by `from`
   
   error: aborting due to 2 previous errors
   
   First one can be "covered up" by letting Rust infer data type like so (which 
is very odd given it infers the same Vec<RecordBatch> !
   let results = df.collect().await?;
   
   The second error indicated something is wrong with TOML documentation:
   print_batches(&results)?;
   
   Can you please point me to documentation how to use this product from Rust? 
   Many thanks.
   


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