Skip to content

Instantly share code, notes, and snippets.

@joshuarobinson
Created February 8, 2022 16:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joshuarobinson/413536d5affd751eb9d8958a970e8b04 to your computer and use it in GitHub Desktop.
Save joshuarobinson/413536d5affd751eb9d8958a970e8b04 to your computer and use it in GitHub Desktop.
use std::env;
use datafusion::arrow::util::pretty;
use datafusion::error::Result;
use datafusion::prelude::*;
/// This example demonstrates executing a simple query against an Arrow data source (Avro) and
/// fetching results
#[tokio::main]
async fn main() -> Result<()> {
let args: Vec<String> = env::args().collect();
let avro_file = &args[1];
// create local execution context
let mut ctx = ExecutionContext::new();
// register avro file with the execution context
let df = ctx.read_avro(avro_file, AvroReadOptions::default()).await?;
let results = df.collect().await?;
// print the results
pretty::print_batches(&results)?;
Ok(())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment