Skip to content

Commit

Permalink
Decommission BallistaContext ... (#1119)
Browse files Browse the repository at this point in the history
closes #1067
  • Loading branch information
milenkovicm authored Nov 19, 2024
1 parent d949e5f commit 36e7430
Show file tree
Hide file tree
Showing 15 changed files with 38 additions and 1,087 deletions.
32 changes: 14 additions & 18 deletions ballista-cli/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ use std::str::FromStr;
use std::sync::Arc;
use std::time::Instant;

use ballista::prelude::{BallistaError, Result};

use datafusion::arrow::array::{ArrayRef, StringArray};
use datafusion::arrow::datatypes::{DataType, Field, Schema};
use datafusion::arrow::record_batch::RecordBatch;
use datafusion::common::Result;
use datafusion::error::DataFusionError;
use datafusion::prelude::SessionContext;

use crate::functions::{display_all_functions, Function};
Expand Down Expand Up @@ -60,25 +60,23 @@ impl Command {
Self::Help =>
// TODO need to provide valid schema
{
print_options
.print_batches(Arc::new(Schema::empty()), &[all_commands_info()], now)
.map_err(BallistaError::DataFusionError)
print_options.print_batches(
Arc::new(Schema::empty()),
&[all_commands_info()],
now,
)
}
Self::ListTables => {
let df = ctx.sql("SHOW TABLES").await?;
let schema = Arc::new(df.schema().as_arrow().clone());
let batches = df.collect().await?;
print_options
.print_batches(schema, &batches, now)
.map_err(BallistaError::DataFusionError)
print_options.print_batches(schema, &batches, now)
}
Self::DescribeTable(name) => {
let df = ctx.sql(&format!("SHOW COLUMNS FROM {name}")).await?;
let schema = Arc::new(df.schema().as_arrow().clone());
let batches = df.collect().await?;
print_options
.print_batches(schema, &batches, now)
.map_err(BallistaError::DataFusionError)
print_options.print_batches(schema, &batches, now)
}
Self::QuietMode(quiet) => {
if let Some(quiet) = quiet {
Expand All @@ -95,23 +93,21 @@ impl Command {
}
Ok(())
}
Self::Quit => Err(BallistaError::Internal(
Self::Quit => Err(DataFusionError::Internal(
"Unexpected quit, this should be handled outside".to_string(),
)),
Self::ListFunctions => {
display_all_functions().map_err(BallistaError::DataFusionError)
}
Self::ListFunctions => display_all_functions(),
Self::SearchFunctions(function) => {
if let Ok(func) = function.parse::<Function>() {
let details = func.function_details()?;
println!("{details}");
Ok(())
} else {
let msg = format!("{function} is not a supported function");
Err(BallistaError::NotImplemented(msg))
Err(DataFusionError::NotImplemented(msg))
}
}
Self::OutputFormat(_) => Err(BallistaError::Internal(
Self::OutputFormat(_) => Err(DataFusionError::Internal(
"Unexpected change output format, this should be handled outside"
.to_string(),
)),
Expand Down Expand Up @@ -221,7 +217,7 @@ impl OutputFormat {
println!("Output format is {:?}.", print_options.format);
Ok(())
} else {
Err(BallistaError::General(format!(
Err(DataFusionError::Execution(format!(
"{:?} is not a valid format type [possible values: {:?}]",
format,
"TO BE FIXED", //PrintFormat::value_variants()
Expand Down
2 changes: 1 addition & 1 deletion ballista-cli/src/exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use std::io::BufReader;
use std::sync::Arc;
use std::time::Instant;

use ballista::prelude::Result;
use datafusion::common::Result;
use datafusion::prelude::SessionContext;
use rustyline::error::ReadlineError;
use rustyline::Editor;
Expand Down
6 changes: 2 additions & 4 deletions ballista-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,13 @@
use std::env;
use std::path::Path;

use ballista::{
extension::SessionConfigExt,
prelude::{Result, SessionContextExt},
};
use ballista::{extension::SessionConfigExt, prelude::SessionContextExt};
use ballista_cli::{
exec, print_format::PrintFormat, print_options::PrintOptions, BALLISTA_CLI_VERSION,
};
use clap::Parser;
use datafusion::{
common::Result,
execution::SessionStateBuilder,
prelude::{SessionConfig, SessionContext},
};
Expand Down
2 changes: 1 addition & 1 deletion ballista/client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,6 @@ object_store = { workspace = true, features = ["aws"] }
testcontainers-modules = { version = "0.11", features = ["minio"] }

[features]
default = []
default = ["standalone"]
standalone = ["ballista-executor", "ballista-scheduler"]
testcontainers = []
10 changes: 5 additions & 5 deletions ballista/client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,16 +92,16 @@ data set. Download the file and add it to the `testdata` folder before running t

```rust,no_run
use ballista::prelude::*;
use datafusion::prelude::{col, ParquetReadOptions};
use datafusion::common::Result;
use datafusion::prelude::{col, SessionContext, ParquetReadOptions};
use datafusion::functions_aggregate::{min_max::min, min_max::max, sum::sum, average::avg};
#[tokio::main]
async fn main() -> Result<()> {
// create configuration
let config = BallistaConfig::default();
// connect to Ballista scheduler
let ctx = BallistaContext::remote("localhost", 50050, &config).await?;
let ctx = SessionContext::remote("df://localhost:50050").await?;
let filename = "testdata/yellow_tripdata_2022-01.parquet";
Expand Down Expand Up @@ -154,4 +154,4 @@ The output should look similar to the following table.
+-----------------+--------------------------+--------------------------+--------------------------+--------------------------+
```

More [examples](https://github.com/apache/arrow-ballista/tree/main/examples) can be found in the arrow-ballista repository.
More [examples](../../examples/examples/) can be found in the arrow-ballista repository.
Loading

0 comments on commit 36e7430

Please sign in to comment.