From 26e6516626360ddb5afa337fe8d5a6d767460485 Mon Sep 17 00:00:00 2001 From: Darren Schroeder <343840+fdncred@users.noreply.github.com> Date: Sun, 15 Jan 2023 21:30:39 -0600 Subject: [PATCH] update sqlparser dependency (#7772) # Description This PR updates the `sqlparser` dependency and updates code to the latest api changes. # User-Facing Changes # Tests + Formatting Don't forget to add tests that cover your changes. Make sure you've run and fixed any issues with these commands: - `cargo fmt --all -- --check` to check standard code formatting (`cargo fmt --all` applies these changes) - `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A clippy::needless_collect` to check that you're using the standard code style - `cargo test --workspace` to check that all tests pass # After Submitting If your PR had any user-facing changes, update [the documentation](https://github.com/nushell/nushell.github.io) after the PR is merged, if necessary. This will help us keep the docs up to date. --- Cargo.lock | 4 ++-- crates/nu-command/Cargo.toml | 2 +- .../nu-command/src/dataframe/eager/sql_context.rs | 2 +- crates/nu-command/src/dataframe/eager/sql_expr.rs | 15 ++++++++++----- 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6a45d67914..baffa08870 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4825,9 +4825,9 @@ dependencies = [ [[package]] name = "sqlparser" -version = "0.23.0" +version = "0.30.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0beb13adabbdda01b63d595f38c8bfd19a361e697fd94ce0098a634077bc5b25" +checksum = "db67dc6ef36edb658196c3fef0464a80b53dbbc194a904e81f9bd4190f9ecc5b" dependencies = [ "log", "serde", diff --git a/crates/nu-command/Cargo.toml b/crates/nu-command/Cargo.toml index ce6d426315..91b2cf3d78 100644 --- a/crates/nu-command/Cargo.toml +++ b/crates/nu-command/Cargo.toml @@ -100,7 +100,7 @@ which = { version = "4.3.0", optional = true } reedline = { version = "0.14.0", features = ["bashisms", "sqlite"] } wax = { version = "0.5.0" } rusqlite = { version = "0.28.0", features = ["bundled"], optional = true } -sqlparser = { version = "0.23.0", features = ["serde"], optional = true } +sqlparser = { version = "0.30.0", features = ["serde"], optional = true } [target.'cfg(windows)'.dependencies] winreg = "0.10.1" diff --git a/crates/nu-command/src/dataframe/eager/sql_context.rs b/crates/nu-command/src/dataframe/eager/sql_context.rs index 4ae2b77849..a75694232f 100644 --- a/crates/nu-command/src/dataframe/eager/sql_context.rs +++ b/crates/nu-command/src/dataframe/eager/sql_context.rs @@ -85,7 +85,7 @@ impl SQLContext { raw_projection_before_alias.insert(format!("{:?}", expr), i); expr.alias(&alias.value) } - SelectItem::QualifiedWildcard(_) | SelectItem::Wildcard => { + SelectItem::QualifiedWildcard(_, _) | SelectItem::Wildcard(_) => { contain_wildcard = true; col("*") } diff --git a/crates/nu-command/src/dataframe/eager/sql_expr.rs b/crates/nu-command/src/dataframe/eager/sql_expr.rs index 5a7f6aadae..978582ea18 100644 --- a/crates/nu-command/src/dataframe/eager/sql_expr.rs +++ b/crates/nu-command/src/dataframe/eager/sql_expr.rs @@ -28,12 +28,17 @@ fn map_sql_polars_datatype(data_type: &SQLDataType) -> Result { SQLDataType::Boolean => DataType::Boolean, SQLDataType::Date => DataType::Date, - SQLDataType::Time => DataType::Time, - SQLDataType::Timestamp => DataType::Datetime(TimeUnit::Milliseconds, None), + SQLDataType::Time(_, _) => DataType::Time, + SQLDataType::Timestamp(_, _) => DataType::Datetime(TimeUnit::Milliseconds, None), SQLDataType::Interval => DataType::Duration(TimeUnit::Milliseconds), - SQLDataType::Array(inner_type) => { - DataType::List(Box::new(map_sql_polars_datatype(inner_type)?)) - } + SQLDataType::Array(inner_type) => match inner_type { + Some(inner_type) => DataType::List(Box::new(map_sql_polars_datatype(inner_type)?)), + None => { + return Err(PolarsError::ComputeError( + "SQL Datatype Array(None) was not supported in polars-sql yet!".into(), + )) + } + }, _ => { return Err(PolarsError::ComputeError( format!(