You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by yj...@apache.org on 2022/06/20 02:58:17 UTC

[arrow-datafusion] branch master updated: remove legacy CLI context enum (#2748)

This is an automated email from the ASF dual-hosted git repository.

yjshen pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow-datafusion.git


The following commit(s) were added to refs/heads/master by this push:
     new 2b7d8dbbe remove legacy CLI context enum (#2748)
2b7d8dbbe is described below

commit 2b7d8dbbe84a050733c41d7d1e97124b3de2694b
Author: Andy Grove <ag...@apache.org>
AuthorDate: Sun Jun 19 20:58:13 2022 -0600

    remove legacy CLI context enum (#2748)
---
 datafusion-cli/Cargo.lock     | 51 ++++++++++++++++++-------------------------
 datafusion-cli/src/command.rs |  4 ++--
 datafusion-cli/src/context.rs | 43 ------------------------------------
 datafusion-cli/src/exec.rs    | 10 ++++-----
 datafusion-cli/src/lib.rs     |  1 -
 datafusion-cli/src/main.rs    |  6 ++---
 6 files changed, 31 insertions(+), 84 deletions(-)

diff --git a/datafusion-cli/Cargo.lock b/datafusion-cli/Cargo.lock
index f307c0264..decca7346 100644
--- a/datafusion-cli/Cargo.lock
+++ b/datafusion-cli/Cargo.lock
@@ -57,9 +57,9 @@ checksum = "8da52d66c7071e2e3fa2a1e5c6d088fec47b593032b254f5e980de8ea54454d6"
 
 [[package]]
 name = "arrow"
-version = "15.0.0"
+version = "16.0.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6510d919fa4c27880f54430510d09327d7c86699c3692664bc0bb7c314f71385"
+checksum = "1cdc4456252b8108b914f41450a754d23b8d21299322f24f81fc46a834fa0293"
 dependencies = [
  "bitflags",
  "chrono",
@@ -247,7 +247,7 @@ version = "3.1.18"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "25320346e922cffe59c0bbc5410c8d8784509efb321488971081313cb1e1a33c"
 dependencies = [
- "heck 0.4.0",
+ "heck",
  "proc-macro-error",
  "proc-macro2",
  "quote",
@@ -276,9 +276,9 @@ dependencies = [
 
 [[package]]
 name = "comfy-table"
-version = "5.0.1"
+version = "6.0.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b103d85ca6e209388771bfb7aa6b68a7aeec4afbf6f0a0264bfbf50360e5212e"
+checksum = "121d8a5b0346092c18a4b2fd6f620d7a06f0eb7ac0a45860939a0884bc579c56"
 dependencies = [
  "strum",
  "strum_macros",
@@ -343,7 +343,7 @@ dependencies = [
 
 [[package]]
 name = "datafusion"
-version = "8.0.0"
+version = "9.0.0"
 dependencies = [
  "ahash",
  "arrow",
@@ -380,7 +380,7 @@ dependencies = [
 
 [[package]]
 name = "datafusion-cli"
-version = "8.0.0"
+version = "9.0.0"
 dependencies = [
  "arrow",
  "clap",
@@ -394,7 +394,7 @@ dependencies = [
 
 [[package]]
 name = "datafusion-common"
-version = "8.0.0"
+version = "9.0.0"
 dependencies = [
  "arrow",
  "ordered-float 3.0.0",
@@ -404,7 +404,7 @@ dependencies = [
 
 [[package]]
 name = "datafusion-data-access"
-version = "8.0.0"
+version = "9.0.0"
 dependencies = [
  "async-trait",
  "chrono",
@@ -416,7 +416,7 @@ dependencies = [
 
 [[package]]
 name = "datafusion-expr"
-version = "8.0.0"
+version = "9.0.0"
 dependencies = [
  "ahash",
  "arrow",
@@ -426,7 +426,7 @@ dependencies = [
 
 [[package]]
 name = "datafusion-optimizer"
-version = "8.0.0"
+version = "9.0.0"
 dependencies = [
  "arrow",
  "async-trait",
@@ -440,7 +440,7 @@ dependencies = [
 
 [[package]]
 name = "datafusion-physical-expr"
-version = "8.0.0"
+version = "9.0.0"
 dependencies = [
  "ahash",
  "arrow",
@@ -463,7 +463,7 @@ dependencies = [
 
 [[package]]
 name = "datafusion-row"
-version = "8.0.0"
+version = "9.0.0"
 dependencies = [
  "arrow",
  "datafusion-common",
@@ -473,7 +473,7 @@ dependencies = [
 
 [[package]]
 name = "datafusion-sql"
-version = "8.0.0"
+version = "9.0.0"
 dependencies = [
  "ahash",
  "arrow",
@@ -780,15 +780,6 @@ dependencies = [
  "ahash",
 ]
 
-[[package]]
-name = "heck"
-version = "0.3.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6d621efb26863f0e9924c6ac577e8275e5e6b77455db64ffa6c65c904e9e132c"
-dependencies = [
- "unicode-segmentation",
-]
-
 [[package]]
 name = "heck"
 version = "0.4.0"
@@ -1249,9 +1240,9 @@ dependencies = [
 
 [[package]]
 name = "parquet"
-version = "15.0.0"
+version = "16.0.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "94d31dde60b151ef88ec2c847e3a8f66d42d7dbdaeefd05d13d79db676b0b56f"
+checksum = "f11444503e702853d52a612828e238a8d0072f85f9a0427b5e2009da4ce61594"
 dependencies = [
  "arrow",
  "base64",
@@ -1586,17 +1577,17 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
 
 [[package]]
 name = "strum"
-version = "0.23.0"
+version = "0.24.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "cae14b91c7d11c9a851d3fbc80a963198998c2a64eec840477fa92d8ce9b70bb"
+checksum = "063e6045c0e62079840579a7e47a355ae92f60eb74daaf156fb1e84ba164e63f"
 
 [[package]]
 name = "strum_macros"
-version = "0.23.1"
+version = "0.24.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5bb0dc7ee9c15cea6199cde9a127fa16a4c5819af85395457ad72d68edc85a38"
+checksum = "6878079b17446e4d3eba6192bb0a2950d5b14f0ed8424b852310e5a94345d0ef"
 dependencies = [
- "heck 0.3.3",
+ "heck",
  "proc-macro2",
  "quote",
  "rustversion",
diff --git a/datafusion-cli/src/command.rs b/datafusion-cli/src/command.rs
index 0fd43a307..aaebf64fb 100644
--- a/datafusion-cli/src/command.rs
+++ b/datafusion-cli/src/command.rs
@@ -17,7 +17,6 @@
 
 //! Command within CLI
 
-use crate::context::Context;
 use crate::functions::{display_all_functions, Function};
 use crate::print_format::PrintFormat;
 use crate::print_options::PrintOptions;
@@ -26,6 +25,7 @@ use datafusion::arrow::array::{ArrayRef, StringArray};
 use datafusion::arrow::datatypes::{DataType, Field, Schema};
 use datafusion::arrow::record_batch::RecordBatch;
 use datafusion::error::{DataFusionError, Result};
+use datafusion::prelude::SessionContext;
 use std::str::FromStr;
 use std::sync::Arc;
 use std::time::Instant;
@@ -50,7 +50,7 @@ pub enum OutputFormat {
 impl Command {
     pub async fn execute(
         &self,
-        ctx: &mut Context,
+        ctx: &mut SessionContext,
         print_options: &mut PrintOptions,
     ) -> Result<()> {
         let now = Instant::now();
diff --git a/datafusion-cli/src/context.rs b/datafusion-cli/src/context.rs
deleted file mode 100644
index 85e94cfb0..000000000
--- a/datafusion-cli/src/context.rs
+++ /dev/null
@@ -1,43 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-//! Context (remote or local)
-
-use datafusion::dataframe::DataFrame;
-use datafusion::error::Result;
-use datafusion::execution::context::{SessionConfig, SessionContext};
-use std::sync::Arc;
-
-/// The CLI supports using a local DataFusion context or a distributed BallistaContext
-pub enum Context {
-    /// In-process execution with DataFusion
-    Local(SessionContext),
-}
-
-impl Context {
-    /// create a local context using the given config
-    pub fn new_local(config: &SessionConfig) -> Context {
-        Context::Local(SessionContext::with_config(config.clone()))
-    }
-
-    /// execute an SQL statement against the context
-    pub async fn sql(&mut self, sql: &str) -> Result<Arc<DataFrame>> {
-        match self {
-            Context::Local(datafusion) => datafusion.sql(sql).await,
-        }
-    }
-}
diff --git a/datafusion-cli/src/exec.rs b/datafusion-cli/src/exec.rs
index dc3c73e5a..9fd3f16f2 100644
--- a/datafusion-cli/src/exec.rs
+++ b/datafusion-cli/src/exec.rs
@@ -19,11 +19,11 @@
 
 use crate::{
     command::{Command, OutputFormat},
-    context::Context,
     helper::CliHelper,
     print_options::PrintOptions,
 };
 use datafusion::error::Result;
+use datafusion::prelude::SessionContext;
 use rustyline::error::ReadlineError;
 use rustyline::Editor;
 use std::fs::File;
@@ -33,7 +33,7 @@ use std::time::Instant;
 
 /// run and execute SQL statements and commands from a file, against a context with the given print options
 pub async fn exec_from_lines(
-    ctx: &mut Context,
+    ctx: &mut SessionContext,
     reader: &mut BufReader<File>,
     print_options: &PrintOptions,
 ) {
@@ -74,7 +74,7 @@ pub async fn exec_from_lines(
 
 pub async fn exec_from_files(
     files: Vec<String>,
-    ctx: &mut Context,
+    ctx: &mut SessionContext,
     print_options: &PrintOptions,
 ) {
     let files = files
@@ -88,7 +88,7 @@ pub async fn exec_from_files(
 }
 
 /// run and execute SQL statements and commands against a context with the given print options
-pub async fn exec_from_repl(ctx: &mut Context, print_options: &mut PrintOptions) {
+pub async fn exec_from_repl(ctx: &mut SessionContext, print_options: &mut PrintOptions) {
     let mut rl = Editor::<CliHelper>::new();
     rl.set_helper(Some(CliHelper::default()));
     rl.load_history(".history").ok();
@@ -157,7 +157,7 @@ pub async fn exec_from_repl(ctx: &mut Context, print_options: &mut PrintOptions)
 }
 
 async fn exec_and_print(
-    ctx: &mut Context,
+    ctx: &mut SessionContext,
     print_options: &PrintOptions,
     sql: String,
 ) -> Result<()> {
diff --git a/datafusion-cli/src/lib.rs b/datafusion-cli/src/lib.rs
index b75be3312..743556533 100644
--- a/datafusion-cli/src/lib.rs
+++ b/datafusion-cli/src/lib.rs
@@ -19,7 +19,6 @@
 pub const DATAFUSION_CLI_VERSION: &str = env!("CARGO_PKG_VERSION");
 
 pub mod command;
-pub mod context;
 pub mod exec;
 pub mod functions;
 pub mod helper;
diff --git a/datafusion-cli/src/main.rs b/datafusion-cli/src/main.rs
index 0702ff447..23d8c74c1 100644
--- a/datafusion-cli/src/main.rs
+++ b/datafusion-cli/src/main.rs
@@ -18,9 +18,9 @@
 use clap::Parser;
 use datafusion::error::Result;
 use datafusion::execution::context::SessionConfig;
+use datafusion::prelude::SessionContext;
 use datafusion_cli::{
-    context::Context, exec, print_format::PrintFormat, print_options::PrintOptions,
-    DATAFUSION_CLI_VERSION,
+    exec, print_format::PrintFormat, print_options::PrintOptions, DATAFUSION_CLI_VERSION,
 };
 use mimalloc::MiMalloc;
 use std::env;
@@ -98,7 +98,7 @@ pub async fn main() -> Result<()> {
         session_config = session_config.with_batch_size(batch_size);
     };
 
-    let mut ctx: Context = Context::new_local(&session_config);
+    let mut ctx = SessionContext::with_config(session_config.clone());
 
     let mut print_options = PrintOptions {
         format: args.format,