Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make DataFrame API consuming (#4621) #4624

Merged
merged 5 commits into from
Dec 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion datafusion-examples/examples/custom_datasource.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ async fn search_accounts(
)?
.build()?;

let mut dataframe = DataFrame::new(ctx.state, &logical_plan)
let mut dataframe = DataFrame::new(ctx.state, logical_plan)
.select_columns(&["id", "bank_account"])?;

if let Some(f) = filter {
Expand Down
5 changes: 2 additions & 3 deletions datafusion-examples/examples/dataframe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ use datafusion::arrow::datatypes::{DataType, Field, Schema};
use datafusion::error::Result;
use datafusion::prelude::*;
use std::fs;
use std::sync::Arc;

/// This example demonstrates executing a simple query against an Arrow data source (Parquet) and
/// fetching results, using the DataFrame trait
Expand Down Expand Up @@ -64,7 +63,7 @@ a2,"08 9, 2013",2,1376006400,4.5"#;
}

// Example to read data from a csv file with inferred schema
async fn example_read_csv_file_with_inferred_schema() -> Arc<DataFrame> {
async fn example_read_csv_file_with_inferred_schema() -> DataFrame {
let path = "example.csv";
// Create a csv file using the predefined function
create_csv_file(path.to_string());
Expand All @@ -75,7 +74,7 @@ async fn example_read_csv_file_with_inferred_schema() -> Arc<DataFrame> {
}

// Example to read csv file with a defined schema for the csv file
async fn example_read_csv_file_with_schema() -> Arc<DataFrame> {
async fn example_read_csv_file_with_schema() -> DataFrame {
let path = "example.csv";
// Create a csv file using the predefined function
create_csv_file(path.to_string());
Expand Down
2 changes: 1 addition & 1 deletion datafusion-examples/examples/deserialize_to_struct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ impl Data {
.sql("SELECT int_col, double_col FROM alltypes_plain")
.await?;

df.show().await?;
df.clone().show().await?;

df.collect().await?
};
Expand Down
4 changes: 2 additions & 2 deletions datafusion-examples/examples/flight_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,15 @@ impl FlightService for FlightServiceImpl {
let df = ctx.sql(sql).await.map_err(to_tonic_err)?;

// execute the query
let schema = df.schema().clone().into();
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 = datafusion::arrow::ipc::writer::IpcWriteOptions::default();
let schema_flight_data =
SchemaAsIpc::new(&df.schema().clone().into(), &options).into();
let schema_flight_data = SchemaAsIpc::new(&schema, &options).into();

let mut flights: Vec<Result<FlightData, Status>> =
vec![Ok(schema_flight_data)];
Expand Down
Loading