update sqlparser dep to 0.34 (#9549)

# Description

This PR updates the sqlparser dep to 0.34.0.

closes #9525

# User-Facing Changes
<!-- List of all changes that impact the user experience here. This
helps us keep track of breaking 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 -A clippy::result_large_err` to check that
you're using the standard code style
- `cargo test --workspace` to check that all tests pass
- `cargo run -- crates/nu-std/tests/run.nu` to run the tests for the
standard library

> **Note**
> from `nushell` you can also use the `toolkit` as follows
> ```bash
> use toolkit.nu # or use an `env_change` hook to activate it
automatically
> toolkit check pr
> ```
-->

# 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.
-->
This commit is contained in:
Darren Schroeder 2023-06-28 09:54:08 -05:00 committed by GitHub
parent 3ed44992e6
commit 9d247387ea
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 33 additions and 37 deletions

17
Cargo.lock generated
View file

@ -2768,7 +2768,7 @@ dependencies = [
"num 0.4.0", "num 0.4.0",
"polars", "polars",
"serde", "serde",
"sqlparser 0.33.0", "sqlparser",
] ]
[[package]] [[package]]
@ -2894,7 +2894,7 @@ dependencies = [
"serde_urlencoded", "serde_urlencoded",
"serde_yaml", "serde_yaml",
"sha2", "sha2",
"sqlparser 0.33.0", "sqlparser",
"sysinfo", "sysinfo",
"tabled", "tabled",
"terminal_size 0.2.6", "terminal_size 0.2.6",
@ -3991,7 +3991,7 @@ dependencies = [
"polars-plan", "polars-plan",
"serde", "serde",
"serde_json", "serde_json",
"sqlparser 0.34.0", "sqlparser",
] ]
[[package]] [[package]]
@ -4989,16 +4989,6 @@ dependencies = [
"lock_api", "lock_api",
] ]
[[package]]
name = "sqlparser"
version = "0.33.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "355dc4d4b6207ca8a3434fc587db0a8016130a574dbcdbfb93d7f7b5bc5b211a"
dependencies = [
"log",
"serde",
]
[[package]] [[package]]
name = "sqlparser" name = "sqlparser"
version = "0.34.0" version = "0.34.0"
@ -5006,6 +4996,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "37d3706eefb17039056234df6b566b0014f303f867f2656108334a55b8096f59" checksum = "37d3706eefb17039056234df6b566b0014f303f867f2656108334a55b8096f59"
dependencies = [ dependencies = [
"log", "log",
"serde",
] ]
[[package]] [[package]]

View file

@ -18,15 +18,12 @@ nu-parser = { path = "../nu-parser", version = "0.82.1" }
nu-protocol = { path = "../nu-protocol", version = "0.82.1" } nu-protocol = { path = "../nu-protocol", version = "0.82.1" }
# Potential dependencies for extras # Potential dependencies for extras
chrono = { version = "0.4", features = [ chrono = { version = "0.4", features = ["std", "unstable-locales"], default-features = false }
"std",
"unstable-locales",
], default-features = false }
fancy-regex = "0.11" fancy-regex = "0.11"
indexmap = { version = "1.7", features = ["serde-1"] } indexmap = { version = "1.7", features = ["serde-1"] }
num = { version = "0.4", optional = true } num = { version = "0.4", optional = true }
serde = { version = "1.0", features = ["derive"] } serde = { version = "1.0", features = ["derive"] }
sqlparser = { version = "0.33", features = ["serde"], optional = true } sqlparser = { version = "0.34", features = ["serde"], optional = true }
[dependencies.polars] [dependencies.polars]
features = [ features = [

View file

@ -3,7 +3,7 @@ use polars::prelude::{col, lit, DataType, Expr, LiteralValue, PolarsResult as Re
use sqlparser::ast::{ use sqlparser::ast::{
BinaryOperator as SQLBinaryOperator, DataType as SQLDataType, Expr as SqlExpr, BinaryOperator as SQLBinaryOperator, DataType as SQLDataType, Expr as SqlExpr,
Function as SQLFunction, Value as SqlValue, WindowSpec, Function as SQLFunction, Value as SqlValue, WindowType,
}; };
fn map_sql_polars_datatype(data_type: &SQLDataType) -> Result<DataType> { fn map_sql_polars_datatype(data_type: &SQLDataType) -> Result<DataType> {
@ -125,9 +125,10 @@ pub fn parse_sql_expr(expr: &SqlExpr) -> Result<Expr> {
}) })
} }
fn apply_window_spec(expr: Expr, window_spec: &Option<WindowSpec>) -> Result<Expr> { fn apply_window_spec(expr: Expr, window_type: &Option<WindowType>) -> Result<Expr> {
Ok(match &window_spec { Ok(match &window_type {
Some(window_spec) => { Some(wtype) => match wtype {
WindowType::WindowSpec(window_spec) => {
// Process for simple window specification, partition by first // Process for simple window specification, partition by first
let partition_by = window_spec let partition_by = window_spec
.partition_by .partition_by
@ -137,6 +138,13 @@ fn apply_window_spec(expr: Expr, window_spec: &Option<WindowSpec>) -> Result<Exp
expr.over(partition_by) expr.over(partition_by)
// Order by and Row range may not be supported at the moment // Order by and Row range may not be supported at the moment
} }
// TODO: make NamedWindow work
WindowType::NamedWindow(_named) => {
return Err(PolarsError::ComputeError(
format!("Expression: {expr:?} was not supported in polars-sql yet!").into(),
))
}
},
None => expr, None => expr,
}) })
} }

View file

@ -13,6 +13,7 @@ version = "0.82.1"
bench = false bench = false
[dependencies] [dependencies]
nu-ansi-term = "0.47.0"
nu-cmd-base = { path = "../nu-cmd-base", version = "0.82.1" } nu-cmd-base = { path = "../nu-cmd-base", version = "0.82.1" }
nu-color-config = { path = "../nu-color-config", version = "0.82.1" } nu-color-config = { path = "../nu-color-config", version = "0.82.1" }
nu-engine = { path = "../nu-engine", version = "0.82.1" } nu-engine = { path = "../nu-engine", version = "0.82.1" }
@ -26,15 +27,15 @@ nu-system = { path = "../nu-system", version = "0.82.1" }
nu-table = { path = "../nu-table", version = "0.82.1" } nu-table = { path = "../nu-table", version = "0.82.1" }
nu-term-grid = { path = "../nu-term-grid", version = "0.82.1" } nu-term-grid = { path = "../nu-term-grid", version = "0.82.1" }
nu-utils = { path = "../nu-utils", version = "0.82.1" } nu-utils = { path = "../nu-utils", version = "0.82.1" }
nu-ansi-term = "0.47.0"
Inflector = "0.11"
alphanumeric-sort = "1.5" alphanumeric-sort = "1.5"
atty = "0.2" atty = "0.2"
base64 = "0.21" base64 = "0.21"
byteorder = "1.4" byteorder = "1.4"
bytesize = "1.2" bytesize = "1.2"
calamine = "0.19" calamine = "0.19"
chrono = { version = "0.4", features = [ "std", "unstable-locales", ], default-features = false } chrono = { version = "0.4", features = ["std", "unstable-locales"], default-features = false }
chrono-humanize = "0.2" chrono-humanize = "0.2"
chrono-tz = "0.8" chrono-tz = "0.8"
crossterm = "0.26" crossterm = "0.26"
@ -50,7 +51,6 @@ fs_extra = "1.3"
htmlescape = "0.3" htmlescape = "0.3"
indexmap = { version = "1.7", features = ["serde-1"] } indexmap = { version = "1.7", features = ["serde-1"] }
indicatif = "0.17" indicatif = "0.17"
Inflector = "0.11"
is-root = "0.1" is-root = "0.1"
itertools = "0.10" itertools = "0.10"
log = "0.4" log = "0.4"
@ -59,6 +59,7 @@ md5 = { package = "md-5", version = "0.10" }
miette = { version = "5.9", features = ["fancy-no-backtrace"] } miette = { version = "5.9", features = ["fancy-no-backtrace"] }
mime = "0.3" mime = "0.3"
mime_guess = "2.0" mime_guess = "2.0"
native-tls = "0.2"
notify = "4.0" notify = "4.0"
num = { version = "0.4", optional = true } num = { version = "0.4", optional = true }
num-format = { version = "0.4" } num-format = { version = "0.4" }
@ -83,15 +84,14 @@ serde_json = "1.0"
serde_urlencoded = "0.7" serde_urlencoded = "0.7"
serde_yaml = "0.9" serde_yaml = "0.9"
sha2 = "0.10" sha2 = "0.10"
sqlparser = { version = "0.33", features = ["serde"], optional = true } sqlparser = { version = "0.34", features = ["serde"], optional = true }
sysinfo = "0.29" sysinfo = "0.29"
tabled = { version = "0.12.2", features = ["color"], default-features = false } tabled = { version = "0.12.2", features = ["color"], default-features = false }
terminal_size = "0.2" terminal_size = "0.2"
titlecase = "2.0" titlecase = "2.0"
toml = "0.7" toml = "0.7"
unicode-segmentation = "1.10" unicode-segmentation = "1.10"
ureq = { version = "2.6", default-features = false, features = [ "json", "charset", "native-tls", "gzip", ] } ureq = { version = "2.6", default-features = false, features = ["charset", "gzip", "json", "native-tls"] }
native-tls = "0.2"
url = "2.2" url = "2.2"
uuid = { version = "1.3", features = ["v4"] } uuid = { version = "1.3", features = ["v4"] }
wax = { version = "0.5" } wax = { version = "0.5" }