Skip to content

Apache DataFusion SQL Query Engine

ARROW-10188: [Rust] [DataFusion] Fixed DataFusion examples.

Jorge C. Leitao3b3b500247e4
diff --git a/rust/datafusion/examples/dataframe.rs b/rust/datafusion/examples/dataframe.rs
index 979768abfd..4144202609 100644
--- a/rust/datafusion/examples/dataframe.rs
+++ b/rust/datafusion/examples/dataframe.rs
@@ -35,8 +35,8 @@ async fn main() -> Result<()> {
// define the query using the DataFrame trait
let df = ctx
.read_parquet(filename)?
- .filter(col("id").gt(lit(1)))?
- .filter(col("tinyint_col").lt(col("tinyint_col")))?;
+ .select_columns(vec!["id", "bool_col", "timestamp_col"])?
+ .filter(col("id").gt(lit(1)))?;
// execute the query
let results = df.collect().await?;
diff --git a/rust/datafusion/examples/memory_table_api.rs b/rust/datafusion/examples/dataframe_in_memory.rs
similarity index 96%
rename from rust/datafusion/examples/memory_table_api.rs
rename to rust/datafusion/examples/dataframe_in_memory.rs
index 823ea019a9..5f5a3d272e 100644
--- a/rust/datafusion/examples/memory_table_api.rs
+++ b/rust/datafusion/examples/dataframe_in_memory.rs
@@ -27,7 +27,7 @@ use datafusion::datasource::MemTable;
use datafusion::error::Result;
use datafusion::prelude::*;
-/// This example demonstrates basic uses of the Table API on an in-memory table
+/// This example demonstrates how to use the DataFrame API against in-memory data.
#[tokio::main]
async fn main() -> Result<()> {
// define a schema.
diff --git a/rust/datafusion/examples/flight_client.rs b/rust/datafusion/examples/flight_client.rs
index 64103445a9..be3a4bdade 100644
--- a/rust/datafusion/examples/flight_client.rs
+++ b/rust/datafusion/examples/flight_client.rs
@@ -26,6 +26,9 @@ use arrow_flight::flight_service_client::FlightServiceClient;
use arrow_flight::utils::flight_data_to_arrow_batch;
use arrow_flight::{FlightDescriptor, Ticket};
+/// This example shows how to wrap DataFusion with `FlightService` to support looking up schema information for
+/// Parquet files and executing SQL queries against them on a remote server.
+/// This example is run along-side the example `flight_server`.
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let testdata =
diff --git a/rust/datafusion/examples/flight_server.rs b/rust/datafusion/examples/flight_server.rs
index 4cf32b7d88..1917a9e8a5 100644
--- a/rust/datafusion/examples/flight_server.rs
+++ b/rust/datafusion/examples/flight_server.rs
@@ -34,10 +34,6 @@ use arrow_flight::{
#[derive(Clone)]
pub struct FlightServiceImpl {}
-/**
- * Example Flight Server wrapping DataFusion that supports looking up schema information for
- * Parquet files and executing SQL queries against Parquet files.
- */
#[tonic::async_trait]
impl FlightService for FlightServiceImpl {
type HandshakeStream = Pin<
@@ -186,6 +182,9 @@ fn to_tonic_err(e: &datafusion::error::ExecutionError) -> Status {
Status::internal(format!("{:?}", e))
}
+/// This example shows how to wrap DataFusion with `FlightService` to support looking up schema information for
+/// Parquet files and executing SQL queries against them on a remote server.
+/// This example is run along-side the example `flight_client`.
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let addr = "0.0.0.0:50051".parse()?;
diff --git a/rust/datafusion/examples/simple_udaf.rs b/rust/datafusion/examples/simple_udaf.rs
index 5227ba07f9..4d3cc23696 100644
--- a/rust/datafusion/examples/simple_udaf.rs
+++ b/rust/datafusion/examples/simple_udaf.rs
@@ -164,6 +164,7 @@ async fn main() -> Result<()> {
// verify that the calculation is correct
assert_eq!(result.value(0), 8.0);
+ println!("The geometric mean of [2,4,8,64] is {}", result.value(0));
Ok(())
}