Skip to content

Commit

Permalink
Apply some linting to the changes
Browse files Browse the repository at this point in the history
  • Loading branch information
gruuya committed Nov 21, 2023
1 parent 1038fef commit 73e5790
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ bytes = "1.4.0"
chrono = { version = "0.4", default_features = false }
clap = { version = "3.2.19", features = [ "derive" ] }
config = "0.13.3"
rustyline = "12.0"

# PG wire protocol support
convergence = { git = "https://github.com/splitgraph/convergence", branch = "datafusion-32-upgrade", optional = true }
Expand Down Expand Up @@ -78,6 +77,7 @@ reqwest = { version = "0.11.14", features = [ "stream" ] }
rmp = "0.8.11"
rmp-serde = "1.1.1"
rmpv = { version = "1.0.0", features = ["with-serde"] }
rustyline = "12.0"
serde = "1.0.156"
serde_json = "1.0.93"
sha2 = ">=0.10.1"
Expand Down
3 changes: 1 addition & 2 deletions src/cli/commands.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use std::str::FromStr;


/// Commands available inside the CLI
#[derive(Debug)]
pub enum Command {
Expand All @@ -27,4 +26,4 @@ impl FromStr for Command {
_ => return Err(()),
})
}
}
}
2 changes: 1 addition & 1 deletion src/cli/helper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ pub struct CliHelper {}
// The accompanying helper for SeafowlCli.
// For now only supports multi-line statements through the `Validator` override.
impl CliHelper {
#[allow(clippy::if_same_then_else)]
fn validate_input(&self, input: &str) -> Result<ValidationResult> {
if input.ends_with(';') {
// TODO: actually perform validation here
Expand All @@ -32,7 +33,6 @@ impl Hinter for CliHelper {
type Hint = String;
}


impl Completer for CliHelper {
type Candidate = Pair;
}
Expand Down
25 changes: 16 additions & 9 deletions src/cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,15 @@ mod helper;

use crate::context::{DefaultSeafowlContext, SeafowlContext};
use arrow::util::pretty::pretty_format_batches_with_options;
use commands::Command;
use datafusion_common::Result;
use helper::CliHelper;
use rustyline::{error::ReadlineError, Editor};
use std::sync::Arc;
use std::time::Instant;
use commands::Command;
use helper::CliHelper;


pub struct SeafowlCli {
ctx: Arc<DefaultSeafowlContext>
ctx: Arc<DefaultSeafowlContext>,
}

impl SeafowlCli {
Expand Down Expand Up @@ -62,7 +61,7 @@ impl SeafowlCli {
break;
}
Err(err) => {
eprintln!("Error while reading input: {err:?}", );
eprintln!("Error while reading input: {err:?}",);
break;
}
}
Expand All @@ -76,8 +75,13 @@ impl SeafowlCli {
match cmd {
Command::Help => todo!(),
Command::ListTables => self.exec_and_print("SHOW TABLES").await,
Command::DescribeTable(name) => self.exec_and_print(&format!("SHOW COLUMNS FROM {name}")).await,
Command::Quit => panic!("Unexpected quit, this should be handled in the repl loop"),
Command::DescribeTable(name) => {
self.exec_and_print(&format!("SHOW COLUMNS FROM {name}"))
.await
}
Command::Quit => {
panic!("Unexpected quit, this should be handled in the repl loop")
}
}
}

Expand All @@ -90,7 +94,10 @@ impl SeafowlCli {
// Generate physical plans from the statements
let mut plans = vec![];
for statement in statements {
let logical = self.ctx.create_logical_plan_from_statement(statement).await?;
let logical = self
.ctx
.create_logical_plan_from_statement(statement)
.await?;
plans.push(self.ctx.create_physical_plan(&logical).await?);
}

Expand All @@ -108,4 +115,4 @@ impl SeafowlCli {

Ok(())
}
}
}

0 comments on commit 73e5790

Please sign in to comment.