Skip to content

Apache DataFusion SQL Query Engine

fix: flight examples (#9335)

Chris O'Donnellc56840734c14
diff --git a/ci/scripts/rust_example.sh b/ci/scripts/rust_example.sh
index fe3696f208..18a7306b52 100755
--- a/ci/scripts/rust_example.sh
+++ b/ci/scripts/rust_example.sh
@@ -20,6 +20,7 @@
set -ex
cd datafusion-examples/examples/
cargo fmt --all -- --check
+cargo check --examples
files=$(ls .)
for filename in $files
diff --git a/datafusion-examples/Cargo.toml b/datafusion-examples/Cargo.toml
index 0fb49a20a8..b1a9cbcad5 100644
--- a/datafusion-examples/Cargo.toml
+++ b/datafusion-examples/Cargo.toml
@@ -29,6 +29,30 @@ license = { workspace = true }
authors = { workspace = true }
rust-version = { workspace = true }
+[[example]]
+name = "flight_sql_server"
+path = "examples/flight/flight_sql_server.rs"
+
+[[example]]
+name = "flight_server"
+path = "examples/flight/flight_server.rs"
+
+[[example]]
+name = "flight_client"
+path = "examples/flight/flight_client.rs"
+
+[[example]]
+name = "catalog"
+path = "examples/external_dependency/catalog.rs"
+
+[[example]]
+name = "dataframe_to_s3"
+path = "examples/external_dependency/dataframe-to-s3.rs"
+
+[[example]]
+name = "query_aws_s3"
+path = "examples/external_dependency/query-aws-s3.rs"
+
[dev-dependencies]
arrow = { workspace = true }
arrow-flight = { workspace = true }
@@ -54,6 +78,7 @@ serde = { version = "1.0.136", features = ["derive"] }
serde_json = { workspace = true }
tempfile = { workspace = true }
tokio = { workspace = true, features = ["rt-multi-thread", "parking_lot"] }
-tonic = "0.11"
+# 0.10 and 0.11 are incompatible. Need to upgrade tonic to 0.11 when upgrading to arrow 51
+tonic = "0.10"
url = { workspace = true }
uuid = "1.2"
diff --git a/datafusion-examples/examples/external_dependency/catalog.rs b/datafusion-examples/examples/external_dependency/catalog.rs
index 29e505fb1d..a623eafdf3 100644
--- a/datafusion-examples/examples/external_dependency/catalog.rs
+++ b/datafusion-examples/examples/external_dependency/catalog.rs
@@ -24,7 +24,7 @@ use datafusion::{
arrow::util::pretty,
catalog::{
schema::SchemaProvider,
- {CatalogProviderList, CatalogProvider},
+ {CatalogProvider, CatalogProviderList},
},
datasource::{
file_format::{csv::CsvFormat, parquet::ParquetFormat, FileFormat},
@@ -53,7 +53,7 @@ async fn main() -> Result<()> {
.unwrap();
let mut ctx = SessionContext::new();
let state = ctx.state();
- let catlist = Arc::new(CustomCatalogProvderList::new());
+ let catlist = Arc::new(CustomCatalogProviderList::new());
// use our custom catalog list for context. each context has a single catalog list.
// context will by default have [`MemoryCatalogProviderList`]
ctx.register_catalog_list(catlist.clone());
diff --git a/datafusion-examples/examples/flight/flight_sql_server.rs b/datafusion-examples/examples/flight/flight_sql_server.rs
index ed5b86d0b6..35d4756230 100644
--- a/datafusion-examples/examples/flight/flight_sql_server.rs
+++ b/datafusion-examples/examples/flight/flight_sql_server.rs
@@ -231,7 +231,7 @@ impl FlightSqlService for FlightSqlServiceImpl {
info!("getting results for {handle}");
let result = self.get_result(&handle)?;
// if we get an empty result, create an empty schema
- let (schema, batches) = match result.get(0) {
+ let (schema, batches) = match result.first() {
None => (Arc::new(Schema::empty()), vec![]),
Some(batch) => (batch.schema(), result.clone()),
};
@@ -287,7 +287,7 @@ impl FlightSqlService for FlightSqlServiceImpl {
.map_err(|e| status!("Error executing query", e))?;
// if we get an empty result, create an empty schema
- let schema = match result.get(0) {
+ let schema = match result.first() {
None => Schema::empty(),
Some(batch) => (*batch.schema()).clone(),
};