From 1b4217c01c590c51a3e80c8a11b28f78f109a110 Mon Sep 17 00:00:00 2001 From: eitsupi Date: Wed, 18 Jan 2023 09:58:38 +0000 Subject: [PATCH 01/14] feat: support old Rust versions --- prql-compiler/src/semantic/lowering.rs | 4 +++- prql-compiler/src/semantic/transforms.rs | 12 ++++++++++-- prql-compiler/src/sql/gen_expr.rs | 4 +++- prql-compiler/src/sql/gen_projection.rs | 24 +++++++++++++++++------- prql-compiler/src/sql/gen_query.rs | 4 +++- 5 files changed, 36 insertions(+), 12 deletions(-) diff --git a/prql-compiler/src/semantic/lowering.rs b/prql-compiler/src/semantic/lowering.rs index 8af12d6a2764..501ce1b4daa3 100644 --- a/prql-compiler/src/semantic/lowering.rs +++ b/prql-compiler/src/semantic/lowering.rs @@ -450,7 +450,9 @@ impl Lowerer { ) -> Result> { let mut r = Vec::with_capacity(exprs.len()); for expr in exprs { - let pl::ExprKind::All { except, .. } = expr.kind else { + let except = if let pl::ExprKind::All { except, .. } = expr.kind { + except + } else { // base case r.push(self.declare_as_column(expr, is_aggregation)?); continue; diff --git a/prql-compiler/src/semantic/transforms.rs b/prql-compiler/src/semantic/transforms.rs index 08a69fe37065..e2c6c6d0254e 100644 --- a/prql-compiler/src/semantic/transforms.rs +++ b/prql-compiler/src/semantic/transforms.rs @@ -300,8 +300,16 @@ pub fn cast_transform(resolver: &mut Resolver, closure: Closure) -> Result(closure); - let ExprKind::Literal(Literal::String(csv)) = csv_expr.kind else { - return Err(Error::new(Reason::Expected { who: Some("std.from_csv".to_string()), expected: "a string literal".to_string(), found: format!("`{csv_expr}`") }).with_span(csv_expr.span).into()) + let csv = if let ExprKind::Literal(Literal::String(csv)) = csv_expr.kind { + csv + } else { + return Err(Error::new(Reason::Expected { + who: Some("std.from_csv".to_string()), + expected: "a string literal".to_string(), + found: format!("`{}`", csv_expr), + }) + .with_span(csv_expr.span) + .into()); }; let res = parse_csv(&csv)?; diff --git a/prql-compiler/src/sql/gen_expr.rs b/prql-compiler/src/sql/gen_expr.rs index e1e3fd64dad3..2984c372404c 100644 --- a/prql-compiler/src/sql/gen_expr.rs +++ b/prql-compiler/src/sql/gen_expr.rs @@ -461,7 +461,9 @@ fn try_into_between( if !matches!(op, BinOp::And) { return Ok(None); } - let Some((a, b)) = a.kind.as_binary().zip(b.kind.as_binary()) else { + let (a, b) = if let Some((a, b)) = a.kind.as_binary().zip(b.kind.as_binary()) { + (a, b) + } else { return Ok(None); }; if !(matches!(a.1, BinOp::Gte) && matches!(b.1, BinOp::Lte)) { diff --git a/prql-compiler/src/sql/gen_projection.rs b/prql-compiler/src/sql/gen_projection.rs index 592b108fac1b..936ecc11fbed 100644 --- a/prql-compiler/src/sql/gen_projection.rs +++ b/prql-compiler/src/sql/gen_projection.rs @@ -27,9 +27,11 @@ pub(super) fn try_into_exprs( .map(|cid| { let decl = ctx.anchor.column_decls.get(&cid).unwrap(); - let ColumnDecl::RelationColumn(tiid, _, RelationColumn::Wildcard) = decl else { + let tiid = if let ColumnDecl::RelationColumn(tiid, _, RelationColumn::Wildcard) = decl { + tiid + } else { // base case - return translate_cid(cid, ctx) + return translate_cid(cid, ctx); }; // wildcard @@ -69,7 +71,11 @@ pub(super) fn translate_wildcards(ctx: &AnchorContext, cols: Vec) -> (Vec)>, excluded: &mut Excluded) { - let Some((cid, in_star)) = star.take() else { return }; + let (cid, in_star) = if let Some((cid, in_star)) = star.take() { + (cid, in_star) + } else { + return; + }; if in_star.is_empty() { return; } @@ -125,9 +131,11 @@ pub(super) fn translate_select_items( .map(|cid| { let decl = ctx.anchor.column_decls.get(&cid).unwrap(); - let ColumnDecl::RelationColumn(tiid, _, RelationColumn::Wildcard) = decl else { - // general case - return translate_select_item(cid, ctx) + let tiid = if let ColumnDecl::RelationColumn(tiid, _, RelationColumn::Wildcard) = decl { + tiid + } else { + // base case + return translate_select_item(cid, ctx); }; // wildcard case @@ -158,7 +166,9 @@ fn translate_exclude( ) -> Option { let excluded = as_col_names(&excluded, &ctx.anchor); - let Some(supported) = ctx.dialect.column_exclude() else { + let supported = if let Some(supported) = ctx.dialect.column_exclude() { + supported + } else { // TODO: eventually this should throw an error // I don't want to do this now, because we have no way around it. // We could also ask the user to add table definitions. diff --git a/prql-compiler/src/sql/gen_query.rs b/prql-compiler/src/sql/gen_query.rs index da051b15f10c..5a6a52895938 100644 --- a/prql-compiler/src/sql/gen_query.rs +++ b/prql-compiler/src/sql/gen_query.rs @@ -291,7 +291,9 @@ fn sql_union_of_pipeline( let append = pipeline.pluck(|t| t.into_append()).into_iter().next(); let unique = pipeline.iter().any(|t| matches!(t, Transform::Unique)); - let Some(bottom) = append else { + let bottom = if let Some(bottom) = append { + bottom + } else { return Ok(top); }; From 996a783b56186c3711e065a5b347e6489155085e Mon Sep 17 00:00:00 2001 From: eitsupi Date: Wed, 18 Jan 2023 13:28:39 +0000 Subject: [PATCH 02/14] fix: `version.workspace` was supported after Rust 1.64 --- prql-compiler/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/prql-compiler/Cargo.toml b/prql-compiler/Cargo.toml index d55d03c9ce26..d3841eb24b3b 100644 --- a/prql-compiler/Cargo.toml +++ b/prql-compiler/Cargo.toml @@ -5,7 +5,7 @@ license = "Apache-2.0" name = "prql-compiler" repository = "https://github.com/PRQL/prql" rust-version = "1.60.0" -version.workspace = true +version = "0.4.0" [features] cli = ["clio", "atty", "clap", "color-eyre"] From 4dad46fa36010cb429214bbc74cc0c9869d4f07c Mon Sep 17 00:00:00 2001 From: eitsupi Date: Wed, 18 Jan 2023 14:01:17 +0000 Subject: [PATCH 03/14] Revert "fix: `version.workspace` was supported after Rust 1.64" This reverts commit 996a783b56186c3711e065a5b347e6489155085e. --- prql-compiler/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/prql-compiler/Cargo.toml b/prql-compiler/Cargo.toml index d3841eb24b3b..d55d03c9ce26 100644 --- a/prql-compiler/Cargo.toml +++ b/prql-compiler/Cargo.toml @@ -5,7 +5,7 @@ license = "Apache-2.0" name = "prql-compiler" repository = "https://github.com/PRQL/prql" rust-version = "1.60.0" -version = "0.4.0" +version.workspace = true [features] cli = ["clio", "atty", "clap", "color-eyre"] From 2513cfe7e1929398ca935f88a1548492331d2273 Mon Sep 17 00:00:00 2001 From: eitsupi Date: Thu, 19 Jan 2023 13:13:07 +0000 Subject: [PATCH 04/14] fix: support install prql-compiler from GitHub by Rust 1.61 and 1.64 --- prql-compiler/Cargo.toml | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/prql-compiler/Cargo.toml b/prql-compiler/Cargo.toml index fb8538f0d829..6573226deb64 100644 --- a/prql-compiler/Cargo.toml +++ b/prql-compiler/Cargo.toml @@ -1,12 +1,10 @@ [package] description = "PRQL is a modern language for transforming data — a simple, powerful, pipelined SQL replacement." +edition = "2021" +license = "Apache-2.0" name = "prql-compiler" - -edition.workspace = true -license.workspace = true -repository.workspace = true -rust-version.workspace = true -version.workspace = true +repository = "https://github.com/PRQL/prql" +version = "0.4.1" # Manually updated to match the version in the root `Cargo.toml`, until # https://github.com/foresterre/cargo-msrv/issues/590 is resolved. From dcb61bab414d4005b9a83f0124eb09e1890b27a6 Mon Sep 17 00:00:00 2001 From: eitsupi Date: Thu, 19 Jan 2023 13:17:24 +0000 Subject: [PATCH 05/14] Revert "fix: support install prql-compiler from GitHub by Rust 1.61 and 1.64" This reverts commit 2513cfe7e1929398ca935f88a1548492331d2273. --- prql-compiler/Cargo.toml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/prql-compiler/Cargo.toml b/prql-compiler/Cargo.toml index 6573226deb64..fb8538f0d829 100644 --- a/prql-compiler/Cargo.toml +++ b/prql-compiler/Cargo.toml @@ -1,10 +1,12 @@ [package] description = "PRQL is a modern language for transforming data — a simple, powerful, pipelined SQL replacement." -edition = "2021" -license = "Apache-2.0" name = "prql-compiler" -repository = "https://github.com/PRQL/prql" -version = "0.4.1" + +edition.workspace = true +license.workspace = true +repository.workspace = true +rust-version.workspace = true +version.workspace = true # Manually updated to match the version in the root `Cargo.toml`, until # https://github.com/foresterre/cargo-msrv/issues/590 is resolved. From 7b3661150c71e4d92880d7d59b5c7506f147c1ad Mon Sep 17 00:00:00 2001 From: eitsupi Date: Thu, 26 Jan 2023 14:06:32 +0000 Subject: [PATCH 06/14] fix: support install prql-compiler from GitHub by Rust 1.61 and 1.64 --- prql-compiler/Cargo.toml | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/prql-compiler/Cargo.toml b/prql-compiler/Cargo.toml index 6ebb421291c7..1a3ef82c20bc 100644 --- a/prql-compiler/Cargo.toml +++ b/prql-compiler/Cargo.toml @@ -1,12 +1,10 @@ [package] description = "PRQL is a modern language for transforming data — a simple, powerful, pipelined SQL replacement." +edition = "2021" +license = "Apache-2.0" name = "prql-compiler" - -edition.workspace = true -license.workspace = true -repository.workspace = true -rust-version.workspace = true -version.workspace = true +repository = "https://github.com/PRQL/prql" +version = "0.4.2" # Manually updated to match the version in the root `Cargo.toml`, until # https://github.com/foresterre/cargo-msrv/issues/590 is resolved. From 7aae8c979117410f5036ddb35b01997f2e163d20 Mon Sep 17 00:00:00 2001 From: eitsupi Date: Thu, 26 Jan 2023 14:46:14 +0000 Subject: [PATCH 07/14] fix: support install prql-compiler from GitHub by Rust 1.61 and 1.64 --- prql-compiler/src/sql/preprocess.rs | 32 +++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/prql-compiler/src/sql/preprocess.rs b/prql-compiler/src/sql/preprocess.rs index 7c04c4cbf7cb..b6fa76e8ac01 100644 --- a/prql-compiler/src/sql/preprocess.rs +++ b/prql-compiler/src/sql/preprocess.rs @@ -232,7 +232,9 @@ pub(super) fn union(pipeline: Vec) -> Vec { let mut res = Vec::with_capacity(pipeline.len()); let mut pipeline = pipeline.into_iter().peekable(); while let Some(t) = pipeline.next() { - let Super(Append(bottom)) = t else { + let bottom = if let Super(Append(bottom)) = t { + bottom + } else { res.push(t); continue; }; @@ -264,8 +266,21 @@ pub(super) fn except(pipeline: Vec, ctx: &Context) -> Result, ctx: &Context) -> Result Date: Thu, 26 Jan 2023 15:05:24 +0000 Subject: [PATCH 08/14] Revert "fix: support install prql-compiler from GitHub by Rust 1.61 and 1.64" This reverts commit 7b3661150c71e4d92880d7d59b5c7506f147c1ad. --- prql-compiler/Cargo.toml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/prql-compiler/Cargo.toml b/prql-compiler/Cargo.toml index 1a3ef82c20bc..6ebb421291c7 100644 --- a/prql-compiler/Cargo.toml +++ b/prql-compiler/Cargo.toml @@ -1,10 +1,12 @@ [package] description = "PRQL is a modern language for transforming data — a simple, powerful, pipelined SQL replacement." -edition = "2021" -license = "Apache-2.0" name = "prql-compiler" -repository = "https://github.com/PRQL/prql" -version = "0.4.2" + +edition.workspace = true +license.workspace = true +repository.workspace = true +rust-version.workspace = true +version.workspace = true # Manually updated to match the version in the root `Cargo.toml`, until # https://github.com/foresterre/cargo-msrv/issues/590 is resolved. From c9a123336417629ffda8b435a11110bf1180d42d Mon Sep 17 00:00:00 2001 From: eitsupi Date: Sat, 18 Feb 2023 04:17:40 +0000 Subject: [PATCH 09/14] fix: support install prql-compiler from GitHub by Rust 1.61 and 1.64 --- prql-compiler/Cargo.toml | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/prql-compiler/Cargo.toml b/prql-compiler/Cargo.toml index 296cf5b954fe..01aaeb71a21c 100644 --- a/prql-compiler/Cargo.toml +++ b/prql-compiler/Cargo.toml @@ -1,16 +1,14 @@ [package] description = "PRQL is a modern language for transforming data — a simple, powerful, pipelined SQL replacement." +edition = "2021" +license = "Apache-2.0" name = "prql-compiler" - -edition.workspace = true -license.workspace = true -repository.workspace = true -rust-version.workspace = true -version.workspace = true +repository = "https://github.com/PRQL/prql" +version = "0.5.1" # Manually updated to match the version in the root `Cargo.toml`, until # https://github.com/foresterre/cargo-msrv/issues/590 is resolved. -metadata.msrv = "1.65.0" +metadata.msrv = "1.63.0" [dependencies] anyhow = {version = "1.0.57", features = ["backtrace"]} From 771004ec02f2eaddcbc966aef56eaadaa4c1072b Mon Sep 17 00:00:00 2001 From: eitsupi Date: Wed, 15 Mar 2023 23:04:59 +0900 Subject: [PATCH 10/14] Revert "fix: support install prql-compiler from GitHub by Rust 1.61 and 1.64" This reverts commit c9a123336417629ffda8b435a11110bf1180d42d. --- prql-compiler/Cargo.toml | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/prql-compiler/Cargo.toml b/prql-compiler/Cargo.toml index 01aaeb71a21c..296cf5b954fe 100644 --- a/prql-compiler/Cargo.toml +++ b/prql-compiler/Cargo.toml @@ -1,14 +1,16 @@ [package] description = "PRQL is a modern language for transforming data — a simple, powerful, pipelined SQL replacement." -edition = "2021" -license = "Apache-2.0" name = "prql-compiler" -repository = "https://github.com/PRQL/prql" -version = "0.5.1" + +edition.workspace = true +license.workspace = true +repository.workspace = true +rust-version.workspace = true +version.workspace = true # Manually updated to match the version in the root `Cargo.toml`, until # https://github.com/foresterre/cargo-msrv/issues/590 is resolved. -metadata.msrv = "1.63.0" +metadata.msrv = "1.65.0" [dependencies] anyhow = {version = "1.0.57", features = ["backtrace"]} From cf4603d78bc471862379a8681ea6ade6accf45c6 Mon Sep 17 00:00:00 2001 From: eitsupi Date: Wed, 15 Mar 2023 14:32:11 +0000 Subject: [PATCH 11/14] fix: support install prql-compiler from GitHub by old Rust version --- prql-compiler/Cargo.toml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/prql-compiler/Cargo.toml b/prql-compiler/Cargo.toml index 5cea1a4342f8..486872000614 100644 --- a/prql-compiler/Cargo.toml +++ b/prql-compiler/Cargo.toml @@ -1,12 +1,11 @@ [package] description = "PRQL is a modern language for transforming data — a simple, powerful, pipelined SQL replacement." +edition = "2021" +license = "Apache-2.0" name = "prql-compiler" -edition.workspace = true -license.workspace = true -repository.workspace = true -rust-version.workspace = true -version.workspace = true +repository = "https://github.com/PRQL/prql" +version = "0.6.1" # Manually updated to match the version in the root `Cargo.toml`, until # https://github.com/foresterre/cargo-msrv/issues/590 is resolved. From ddd2cacaf2a2fdaad9d8da8f3b9ce6864ca0cd00 Mon Sep 17 00:00:00 2001 From: eitsupi Date: Sun, 30 Apr 2023 03:48:39 +0000 Subject: [PATCH 12/14] Revert "fix: support install prql-compiler from GitHub by old Rust version" This reverts commit cf4603d78bc471862379a8681ea6ade6accf45c6. --- prql-compiler/Cargo.toml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/prql-compiler/Cargo.toml b/prql-compiler/Cargo.toml index 486872000614..5cea1a4342f8 100644 --- a/prql-compiler/Cargo.toml +++ b/prql-compiler/Cargo.toml @@ -1,11 +1,12 @@ [package] description = "PRQL is a modern language for transforming data — a simple, powerful, pipelined SQL replacement." -edition = "2021" -license = "Apache-2.0" name = "prql-compiler" -repository = "https://github.com/PRQL/prql" -version = "0.6.1" +edition.workspace = true +license.workspace = true +repository.workspace = true +rust-version.workspace = true +version.workspace = true # Manually updated to match the version in the root `Cargo.toml`, until # https://github.com/foresterre/cargo-msrv/issues/590 is resolved. From 8423beb17c33ae9ed7c318f3ae741fff0d418cf3 Mon Sep 17 00:00:00 2001 From: eitsupi Date: Sun, 30 Apr 2023 05:03:56 +0000 Subject: [PATCH 13/14] fix: let else -> let if let else --- prql-compiler/src/sql/gen_expr.rs | 19 ++++++++++++++----- prql-compiler/src/sql/preprocess.rs | 4 +++- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/prql-compiler/src/sql/gen_expr.rs b/prql-compiler/src/sql/gen_expr.rs index ab55a572cc18..869bae674c30 100644 --- a/prql-compiler/src/sql/gen_expr.rs +++ b/prql-compiler/src/sql/gen_expr.rs @@ -130,7 +130,9 @@ fn try_into_binary_op(expr: Expr, ctx: &mut Context) -> Result Result; 2] = [STD_NEG, STD_NOT]; const OPS: [UnaryOperator; 2] = [Minus, Not]; - let Some((decl, _)) = try_unpack(&expr, DECLS)? else { + let decl = if let Some((decl, _)) = try_unpack(&expr, DECLS)? { + decl + } else { return Ok(Err(expr)); }; + // this lookup is O(N), but 13 is not that big of a N let decl_index = DECLS.iter().position(|x| x == &decl).unwrap(); let op = OPS[decl_index]; @@ -191,7 +196,9 @@ fn try_into_concat_function(expr: Expr, ctx: &mut Context) -> Result Result, Expr>> { - let Some((_, _)) = try_unpack(&expr, [STD_CONCAT])? else { + let () = if let Some((_, _)) = try_unpack(&expr, [STD_CONCAT])? { + () + } else { return Ok(Err(expr)); }; let [left, right] = unpack(expr, STD_CONCAT); @@ -531,8 +538,10 @@ pub(super) fn translate_select_item(cid: CId, ctx: &mut Context) -> Result Result> { - let Some((decl, [a, b])) = try_unpack(&expr, [STD_EQ, STD_NE])? else { - return Ok(Err(expr)) + let (decl, a, b) = if let Some((decl, [a, b])) = try_unpack(&expr, [STD_EQ, STD_NE])? { + (decl, a, b) + } else { + return Ok(Err(expr)); }; let take_a = if matches!(a.kind, ExprKind::Literal(Literal::Null)) { diff --git a/prql-compiler/src/sql/preprocess.rs b/prql-compiler/src/sql/preprocess.rs index 4651716e01e2..966436ead4ed 100644 --- a/prql-compiler/src/sql/preprocess.rs +++ b/prql-compiler/src/sql/preprocess.rs @@ -538,7 +538,9 @@ impl RqFold for Normalizer { ..expr }; - let Some((decl, _)) = super::std::try_unpack(&expr, [super::std::STD_EQ])? else { + let decl = if let Some((decl, _)) = super::std::try_unpack(&expr, [super::std::STD_EQ])? { + decl + } else { return Ok(expr); }; let name = decl.name.to_string(); From a3841742ad740370896a695b97f0e9c3f2374261 Mon Sep 17 00:00:00 2001 From: eitsupi Date: Sun, 30 Apr 2023 05:04:03 +0000 Subject: [PATCH 14/14] fix: support install prql-compiler from GitHub by old Rust version --- prql-compiler/Cargo.toml | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/prql-compiler/Cargo.toml b/prql-compiler/Cargo.toml index 11781d5206ed..d5629b38e883 100644 --- a/prql-compiler/Cargo.toml +++ b/prql-compiler/Cargo.toml @@ -1,14 +1,13 @@ [package] description = "PRQL is a modern language for transforming data — a simple, powerful, pipelined SQL replacement." +edition = "2021" +license = "Apache-2.0" name = "prql-compiler" -edition.workspace = true -license.workspace = true -repository.workspace = true -rust-version.workspace = true -version.workspace = true +repository = "https://github.com/PRQL/prql" +version = "0.8.1" -metadata.msrv = "1.65.0" +metadata.msrv = "1.61.0" [dependencies] anyhow = {version = "1.0.57", features = ["backtrace"]}