Skip to content

Commit

Permalink
Update sqlparser + pep compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
ngrislain committed Oct 28, 2023
1 parent 40a6ab4 commit 4b1f48e
Show file tree
Hide file tree
Showing 10 changed files with 266 additions and 91 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.4.3] - 2023-10-27
### Fixed
- added rewrite_as_pep [MR169](https://github.com/Qrlew/qrlew/pull/169)
- Updates sqlparser version

## [0.4.2] - 2023-10-27
### Fixed
- gaussian noise [MR169](https://github.com/Qrlew/qrlew/pull/169)
Expand Down
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
authors = ["Nicolas Grislain <ng@sarus.tech>"]
name = "qrlew"
version = "0.4.2"
version = "0.4.3"
edition = "2021"
description = "Sarus Qrlew Engine"
documentation = "https://docs.rs/qrlew"
Expand All @@ -24,7 +24,7 @@ paste = "1.0.7"
serde = { version = "1.0", features = ["derive", "rc"] }
serde_json = "1.0"
chrono = { version = "0.4", features = ["serde"] }
sqlparser = "0.38.0"
sqlparser = "0.39.0"
dot = "0.1"
base64 = "0.21"
rusqlite = { version = "0.29", features = ["chrono"], optional = true }
Expand Down
1 change: 1 addition & 0 deletions examples/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ fn build_ast() -> Result<(), &'static str> {
offset: None,
fetch: None,
locks: vec![],
limit_by: vec![],
};
println!("{}\n", query);
// A CTE
Expand Down
17 changes: 17 additions & 0 deletions src/expr/sql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,8 @@ impl<'a> expr::Visitor<'a, ast::Expr> for FromExprVisitor {
distinct: false,
special: false,
order_by: vec![],
filter: None,
null_treatment: None,
}),
expr::function::Function::Case => ast::Expr::Case {
operand: None,
Expand All @@ -215,6 +217,7 @@ impl<'a> expr::Visitor<'a, ast::Expr> for FromExprVisitor {
expr::function::Function::CastAsText => ast::Expr::Cast {
expr: arguments[0].clone().into(),
data_type: DataType::text().into(),
format: None,
},
expr::function::Function::CastAsFloat => todo!(),
expr::function::Function::CastAsInteger => todo!(),
Expand All @@ -240,6 +243,8 @@ impl<'a> expr::Visitor<'a, ast::Expr> for FromExprVisitor {
distinct: false,
special: false,
order_by: vec![],
filter: None,
null_treatment: None,
}),
expr::aggregate::Aggregate::Max => ast::Expr::Function(ast::Function {
name: ast::ObjectName(vec![ast::Ident {
Expand All @@ -253,6 +258,8 @@ impl<'a> expr::Visitor<'a, ast::Expr> for FromExprVisitor {
distinct: false,
special: false,
order_by: vec![],
filter: None,
null_treatment: None,
}),
expr::aggregate::Aggregate::Median => todo!(),
expr::aggregate::Aggregate::NUnique => todo!(),
Expand All @@ -272,6 +279,8 @@ impl<'a> expr::Visitor<'a, ast::Expr> for FromExprVisitor {
distinct: false,
special: false,
order_by: vec![],
filter: None,
null_treatment: None,
}),
expr::aggregate::Aggregate::List => todo!(),
expr::aggregate::Aggregate::Count => ast::Expr::Function(ast::Function {
Expand All @@ -286,6 +295,8 @@ impl<'a> expr::Visitor<'a, ast::Expr> for FromExprVisitor {
distinct: false,
special: false,
order_by: vec![],
filter: None,
null_treatment: None,
}),
expr::aggregate::Aggregate::Quantile(_) => todo!(),
expr::aggregate::Aggregate::Quantiles(_) => todo!(),
Expand All @@ -301,6 +312,8 @@ impl<'a> expr::Visitor<'a, ast::Expr> for FromExprVisitor {
distinct: false,
special: false,
order_by: vec![],
filter: None,
null_treatment: None,
}),
expr::aggregate::Aggregate::AggGroups => todo!(),
expr::aggregate::Aggregate::Std => ast::Expr::Function(ast::Function {
Expand All @@ -315,6 +328,8 @@ impl<'a> expr::Visitor<'a, ast::Expr> for FromExprVisitor {
distinct: false,
special: false,
order_by: vec![],
filter: None,
null_treatment: None,
}),
expr::aggregate::Aggregate::Var => ast::Expr::Function(ast::Function {
name: ast::ObjectName(vec![ast::Ident {
Expand All @@ -328,6 +343,8 @@ impl<'a> expr::Visitor<'a, ast::Expr> for FromExprVisitor {
distinct: false,
special: false,
order_by: vec![],
filter: None,
null_treatment: None,
}),
}
}
Expand Down
8 changes: 7 additions & 1 deletion src/relation/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ impl Error {
pub fn invalid_conversion(from: impl fmt::Display, to: impl fmt::Display) -> Error {
Error::InvalidConversion(format!("Invalid conversion from {} to {}", from, to))
}
pub fn other(value: impl fmt::Display) -> Error {
Error::Other(format!("Error with {}", value))
}
}

impl fmt::Display for Error {
Expand Down Expand Up @@ -1131,6 +1134,7 @@ pub enum SetQuantifier {
None,
ByName,
AllByName,
DistinctByName,
}

impl fmt::Display for SetQuantifier {
Expand All @@ -1144,6 +1148,7 @@ impl fmt::Display for SetQuantifier {
SetQuantifier::None => "NONE",
SetQuantifier::ByName => "BY NAME",
SetQuantifier::AllByName => "ALL BY NAME",
SetQuantifier::DistinctByName => "DISTINCT BY NAME",
}
)
}
Expand Down Expand Up @@ -1266,7 +1271,8 @@ impl fmt::Display for Set {
SetQuantifier::All
| SetQuantifier::Distinct
| SetQuantifier::ByName
| SetQuantifier::AllByName => {
| SetQuantifier::AllByName
| SetQuantifier::DistinctByName => {
format!("{} {}", self.operator, self.quantifier)
}
SetQuantifier::None => format!("{}", self.operator),
Expand Down
6 changes: 6 additions & 0 deletions src/relation/sql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ impl From<SetQuantifier> for ast::SetQuantifier {
SetQuantifier::None => ast::SetQuantifier::None,
SetQuantifier::ByName => ast::SetQuantifier::ByName,
SetQuantifier::AllByName => ast::SetQuantifier::AllByName,
SetQuantifier::DistinctByName => ast::SetQuantifier::DistinctByName,
}
}
}
Expand Down Expand Up @@ -129,6 +130,7 @@ fn query(
offset: None,
fetch: None,
locks: vec![],
limit_by: vec![],
}
}

Expand All @@ -144,6 +146,7 @@ fn values_query(rows: Vec<Vec<ast::Expr>>) -> ast::Query {
offset: None,
fetch: None,
locks: vec![],
limit_by: vec![],
}
}

Expand Down Expand Up @@ -225,6 +228,7 @@ fn set_operation(
offset: None,
fetch: None,
locks: vec![],
limit_by: vec![],
}
}

Expand Down Expand Up @@ -558,12 +562,14 @@ impl Table {
offset: None,
fetch: None,
locks: vec![],
limit_by: vec![],
}),
partitioned: None,
after_columns: vec![],
table: false,
on: None,
returning: None,
ignore: false,
}
}
}
Expand Down
Loading

0 comments on commit 4b1f48e

Please sign in to comment.