update sql-parser crate and all the files it touches (#6566)

* update sql-parser crate and all the files it touches

* undo adding extra as a default feature
This commit is contained in:
Darren Schroeder 2022-09-15 18:03:43 -05:00 committed by GitHub
parent 10b9c65cb7
commit f0ae6ffe12
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 47 additions and 23 deletions

4
Cargo.lock generated
View File

@ -4774,9 +4774,9 @@ dependencies = [
[[package]] [[package]]
name = "sqlparser" name = "sqlparser"
version = "0.16.0" version = "0.23.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7e9a527b68048eb95495a1508f6c8395c8defcff5ecdbe8ad4106d08a2ef2a3c" checksum = "0beb13adabbdda01b63d595f38c8bfd19a361e697fd94ce0098a634077bc5b25"
dependencies = [ dependencies = [
"log", "log",
"serde", "serde",

View File

@ -79,9 +79,9 @@ winres = "0.1"
[features] [features]
plugin = ["nu-plugin", "nu-cli/plugin", "nu-parser/plugin", "nu-command/plugin", "nu-protocol/plugin", "nu-engine/plugin"] plugin = ["nu-plugin", "nu-cli/plugin", "nu-parser/plugin", "nu-command/plugin", "nu-protocol/plugin", "nu-engine/plugin"]
extra = ["default", "dataframe", "database"]
default = ["plugin", "which-support", "trash-support"] default = ["plugin", "which-support", "trash-support"]
stable = ["default"] stable = ["default"]
extra = ["default", "dataframe", "database"]
wasi = [] wasi = []
# Enable to statically link OpenSSL; otherwise the system version will be used. Not enabled by default because it takes a while to build # Enable to statically link OpenSSL; otherwise the system version will be used. Not enabled by default because it takes a while to build
static-link-openssl = ["dep:openssl"] static-link-openssl = ["dep:openssl"]

View File

@ -90,7 +90,7 @@ which = { version = "4.3.0", optional = true }
reedline = { version = "0.11.0", features = ["bashisms", "sqlite"]} reedline = { version = "0.11.0", features = ["bashisms", "sqlite"]}
wax = { version = "0.5.0", features = ["diagnostics"] } wax = { version = "0.5.0", features = ["diagnostics"] }
rusqlite = { version = "0.28.0", features = ["bundled"], optional = true } rusqlite = { version = "0.28.0", features = ["bundled"], optional = true }
sqlparser = { version = "0.16.0", features = ["serde"], optional = true } sqlparser = { version = "0.23.0", features = ["serde"], optional = true }
[target.'cfg(unix)'.dependencies] [target.'cfg(unix)'.dependencies]
umask = "2.0.0" umask = "2.0.0"

View File

@ -125,7 +125,7 @@ impl Command for AndDb {
} }
fn modify_query(query: &mut Box<Query>, expression: Expr, span: Span) -> Result<(), ShellError> { fn modify_query(query: &mut Box<Query>, expression: Expr, span: Span) -> Result<(), ShellError> {
match query.body { match *query.body {
SetExpr::Select(ref mut select) => modify_select(select, expression, span)?, SetExpr::Select(ref mut select) => modify_select(select, expression, span)?,
_ => { _ => {
return Err(ShellError::GenericError( return Err(ShellError::GenericError(

View File

@ -113,7 +113,7 @@ fn alias_db(
Vec::new(), Vec::new(),
)), )),
Some(statement) => match statement { Some(statement) => match statement {
Statement::Query(query) => match &mut query.body { Statement::Query(query) => match &mut *query.body {
SetExpr::Select(select) => { SetExpr::Select(select) => {
select.as_mut().from.iter_mut().for_each(|table| { select.as_mut().from.iter_mut().for_each(|table| {
let new_alias = Some(TableAlias { let new_alias = Some(TableAlias {

View File

@ -17,7 +17,7 @@ pub fn value_into_table_factor(
Ok(TableFactor::Table { Ok(TableFactor::Table {
name: ObjectName(vec![ident]), name: ObjectName(vec![ident]),
alias, alias,
args: Vec::new(), args: None,
with_hints: Vec::new(), with_hints: Vec::new(),
}) })
} }

View File

@ -96,12 +96,12 @@ fn create_statement(
) -> Result<Statement, ShellError> { ) -> Result<Statement, ShellError> {
let query = Query { let query = Query {
with: None, with: None,
body: SetExpr::Select(Box::new(create_select( body: Box::new(SetExpr::Select(Box::new(create_select(
connection, connection,
engine_state, engine_state,
stack, stack,
call, call,
)?)), )?))),
order_by: Vec::new(), order_by: Vec::new(),
limit: None, limit: None,
offset: None, offset: None,
@ -121,18 +121,18 @@ fn modify_statement(
) -> Result<Statement, ShellError> { ) -> Result<Statement, ShellError> {
match statement { match statement {
Statement::Query(ref mut query) => { Statement::Query(ref mut query) => {
match query.body { match *query.body {
SetExpr::Select(ref mut select) => { SetExpr::Select(ref mut select) => {
let table = create_table(connection, engine_state, stack, call)?; let table = create_table(connection, engine_state, stack, call)?;
select.from.push(table); select.from.push(table);
} }
_ => { _ => {
query.as_mut().body = SetExpr::Select(Box::new(create_select( query.as_mut().body = Box::new(SetExpr::Select(Box::new(create_select(
connection, connection,
engine_state, engine_state,
stack, stack,
call, call,
)?)); )?)));
} }
}; };
@ -167,6 +167,7 @@ fn create_select(
distribute_by: Vec::new(), distribute_by: Vec::new(),
sort_by: Vec::new(), sort_by: Vec::new(),
having: None, having: None,
qualify: None,
}) })
} }

View File

@ -104,7 +104,7 @@ impl Command for GroupByDb {
let mut db = SQLiteDatabase::try_from_pipeline(input, call.head)?; let mut db = SQLiteDatabase::try_from_pipeline(input, call.head)?;
match db.statement.as_mut() { match db.statement.as_mut() {
Some(statement) => match statement { Some(statement) => match statement {
Statement::Query(ref mut query) => match &mut query.body { Statement::Query(ref mut query) => match &mut *query.body {
SetExpr::Select(ref mut select) => select.group_by = expressions, SetExpr::Select(ref mut select) => select.group_by = expressions,
s => { s => {
return Err(ShellError::GenericError( return Err(ShellError::GenericError(

View File

@ -146,7 +146,7 @@ fn modify_statement(
) -> Result<Statement, ShellError> { ) -> Result<Statement, ShellError> {
match statement { match statement {
Statement::Query(ref mut query) => { Statement::Query(ref mut query) => {
match &mut query.body { match &mut *query.body {
SetExpr::Select(ref mut select) => { SetExpr::Select(ref mut select) => {
modify_from(connection, select, engine_state, stack, call)? modify_from(connection, select, engine_state, stack, call)?
} }

View File

@ -125,7 +125,7 @@ impl Command for OrDb {
} }
fn modify_query(query: &mut Box<Query>, expression: Expr, span: Span) -> Result<(), ShellError> { fn modify_query(query: &mut Box<Query>, expression: Expr, span: Span) -> Result<(), ShellError> {
match query.body { match *query.body {
SetExpr::Select(ref mut select) => modify_select(select, expression, span)?, SetExpr::Select(ref mut select) => modify_select(select, expression, span)?,
_ => { _ => {
return Err(ShellError::GenericError( return Err(ShellError::GenericError(

View File

@ -108,7 +108,7 @@ impl Command for ProjectionDb {
fn create_statement(expressions: Vec<SelectItem>) -> Statement { fn create_statement(expressions: Vec<SelectItem>) -> Statement {
let query = Query { let query = Query {
with: None, with: None,
body: SetExpr::Select(Box::new(create_select(expressions))), body: Box::new(SetExpr::Select(Box::new(create_select(expressions)))),
order_by: Vec::new(), order_by: Vec::new(),
limit: None, limit: None,
offset: None, offset: None,
@ -126,10 +126,11 @@ fn modify_statement(
) -> Result<Statement, ShellError> { ) -> Result<Statement, ShellError> {
match statement { match statement {
Statement::Query(ref mut query) => { Statement::Query(ref mut query) => {
match query.body { match *query.body {
SetExpr::Select(ref mut select) => select.as_mut().projection = expressions, SetExpr::Select(ref mut select) => select.as_mut().projection = expressions,
_ => { _ => {
query.as_mut().body = SetExpr::Select(Box::new(create_select(expressions))); query.as_mut().body =
Box::new(SetExpr::Select(Box::new(create_select(expressions))));
} }
}; };
@ -159,6 +160,7 @@ fn create_select(projection: Vec<SelectItem>) -> Select {
distribute_by: Vec::new(), distribute_by: Vec::new(),
sort_by: Vec::new(), sort_by: Vec::new(),
having: None, having: None,
qualify: None,
} }
} }

View File

@ -99,10 +99,10 @@ impl Command for WhereDb {
} }
fn modify_query(query: &mut Box<Query>, expression: Expr) { fn modify_query(query: &mut Box<Query>, expression: Expr) {
match query.body { match *query.body {
SetExpr::Select(ref mut select) => modify_select(select, expression), SetExpr::Select(ref mut select) => modify_select(select, expression),
_ => { _ => {
query.as_mut().body = SetExpr::Select(Box::new(create_select(expression))); query.as_mut().body = Box::new(SetExpr::Select(Box::new(create_select(expression))));
} }
}; };
} }
@ -125,6 +125,7 @@ fn create_select(expression: Expr) -> Select {
distribute_by: Vec::new(), distribute_by: Vec::new(),
sort_by: Vec::new(), sort_by: Vec::new(),
having: None, having: None,
qualify: None,
} }
} }

View File

@ -132,6 +132,7 @@ impl Command for FunctionExpr {
args, args,
over: None, over: None,
distinct: call.has_flag("distinct"), distinct: call.has_flag("distinct"),
special: false,
}) })
.into(); .into();

View File

@ -249,7 +249,7 @@ impl ExtractedExpr {
impl ExprDb { impl ExprDb {
pub fn expr_to_value(expr: &Expr, span: Span) -> Value { pub fn expr_to_value(expr: &Expr, span: Span) -> Value {
match expr { match &*expr {
Expr::Identifier(ident) => { Expr::Identifier(ident) => {
let cols = vec!["value".into(), "quoted_style".into()]; let cols = vec!["value".into(), "quoted_style".into()];
let val = Value::String { let val = Value::String {
@ -339,7 +339,7 @@ impl ExprDb {
Expr::TypedString { .. } => todo!(), Expr::TypedString { .. } => todo!(),
Expr::MapAccess { .. } => todo!(), Expr::MapAccess { .. } => todo!(),
Expr::Case { .. } => todo!(), Expr::Case { .. } => todo!(),
Expr::Exists(_) => todo!(), Expr::Exists { .. } => todo!(),
Expr::Subquery(_) => todo!(), Expr::Subquery(_) => todo!(),
Expr::ListAgg(_) => todo!(), Expr::ListAgg(_) => todo!(),
Expr::GroupingSets(_) => todo!(), Expr::GroupingSets(_) => todo!(),
@ -348,6 +348,25 @@ impl ExprDb {
Expr::Tuple(_) => todo!(), Expr::Tuple(_) => todo!(),
Expr::ArrayIndex { .. } => todo!(), Expr::ArrayIndex { .. } => todo!(),
Expr::Array(_) => todo!(), Expr::Array(_) => todo!(),
Expr::JsonAccess { .. } => todo!(),
Expr::CompositeAccess { .. } => todo!(),
Expr::IsFalse(_) => todo!(),
Expr::IsNotFalse(_) => todo!(),
Expr::IsTrue(_) => todo!(),
Expr::IsNotTrue(_) => todo!(),
Expr::IsUnknown(_) => todo!(),
Expr::IsNotUnknown(_) => todo!(),
Expr::Like { .. } => todo!(),
Expr::ILike { .. } => todo!(),
Expr::SimilarTo { .. } => todo!(),
Expr::AnyOp(_) => todo!(),
Expr::AllOp(_) => todo!(),
Expr::SafeCast { .. } => todo!(),
Expr::AtTimeZone { .. } => todo!(),
Expr::Position { .. } => todo!(),
Expr::Overlay { .. } => todo!(),
Expr::AggregateExpressionWithFilter { .. } => todo!(),
Expr::ArraySubquery(_) => todo!(),
} }
} }
} }

View File

@ -184,7 +184,7 @@ impl SQLContext {
.ok_or_else(|| PolarsError::NotFound("No statement found".to_string()))?; .ok_or_else(|| PolarsError::NotFound("No statement found".to_string()))?;
Ok(match ast { Ok(match ast {
Statement::Query(query) => { Statement::Query(query) => {
let rs = match &query.body { let rs = match &*query.body {
SetExpr::Select(select_stmt) => self.execute_select(&*select_stmt)?, SetExpr::Select(select_stmt) => self.execute_select(&*select_stmt)?,
_ => { _ => {
return Err(PolarsError::ComputeError( return Err(PolarsError::ComputeError(