Repository: prql/prql
Pull request #370 (2022-04-16 04:13:58)

Add (brief) docs on ranges

max-sixty: I removed this part, since I doesn't yet work on dates. I would be up for implementing dates as something more than implicit strings (!), like Malloy's approach of `@2020-01-01`, and then we could get this to work,

````md
This can be used with dates, too:

```prql_no_test
from employees
filter (dob | in '1980-01-01'..'1990-01-01')
```
````

Patch:
diff --git a/Cargo.lock b/Cargo.lock
index 25f36b74..b69f30d7 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -769,7 +769,7 @@ dependencies = [
  "itertools",
  "mdbook",
  "mdbook-preprocessor-boilerplate",
- "prql",
+ "prql-compiler",
  "pulldown-cmark",
  "pulldown-cmark-to-cmark",
  "semver",
@@ -1071,7 +1071,7 @@ dependencies = [
 ]
 
 [[package]]
-name = "prql"
+name = "prql-compiler"
 version = "0.1.1"
 dependencies = [
  "anyhow",
@@ -1103,7 +1103,7 @@ name = "prql-js"
 version = "0.1.2"
 dependencies = [
  "console_error_panic_hook",
- "prql",
+ "prql-compiler",
  "wasm-bindgen",
  "wasm-bindgen-test 0.3.30",
  "wee_alloc",
@@ -1117,7 +1117,7 @@ dependencies = [
  "globset",
  "insta",
  "itertools",
- "prql",
+ "prql-compiler",
  "pulldown-cmark",
  "pulldown-cmark-to-cmark",
  "similar",
@@ -1135,7 +1135,7 @@ dependencies = [
  "insta",
  "log",
  "monaco",
- "prql",
+ "prql-compiler",
  "similar",
  "wasm-bindgen",
  "wasm-bindgen-test 0.2.50",
diff --git a/Cargo.toml b/Cargo.toml
index 3ef7338a..5872af3e 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,7 +1,7 @@
 [workspace]
 
 members = [
-  "prql",
+  "prql-compiler",
   "prql-web",
   "prql-js",
   "reference",
diff --git a/prql/Cargo.toml b/prql-compiler/Cargo.toml
similarity index 98%
rename from prql/Cargo.toml
rename to prql-compiler/Cargo.toml
index 3b201008..ff4c5f61 100644
--- a/prql/Cargo.toml
+++ b/prql-compiler/Cargo.toml
@@ -2,7 +2,7 @@
 description = "PRQL is a modern language for transforming data — a simpler and more powerful SQL."
 edition = "2021"
 license = "Apache-2.0"
-name = "prql"
+name = "prql-compiler"
 repository = "https://github.com/prql/prql"
 rust-version = "1.59.0"
 version = "0.1.1"
diff --git a/prql/src/ast_fold.rs b/prql-compiler/src/ast/ast_fold.rs
similarity index 99%
rename from prql/src/ast_fold.rs
rename to prql-compiler/src/ast/ast_fold.rs
index e81fb038..6bc381f0 100644
--- a/prql/src/ast_fold.rs
+++ b/prql-compiler/src/ast/ast_fold.rs
@@ -1,7 +1,7 @@
 /// A trait to "fold" a PRQL AST (similiar to a visitor), so we can transitively
 /// apply some logic to a whole tree by just defining how we want to handle each
 /// type.
-use super::ast::*;
+use super::*;
 use anyhow::Result;
 use itertools::Itertools;
 
diff --git a/prql/src/ast.rs b/prql-compiler/src/ast/mod.rs
similarity index 99%
rename from prql/src/ast.rs
rename to prql-compiler/src/ast/mod.rs
index b79bd130..7b78dacc 100644
--- a/prql/src/ast.rs
+++ b/prql-compiler/src/ast/mod.rs
@@ -6,6 +6,8 @@ use strum::{self, Display, EnumString};
 use crate::error::{Error, Reason, Span};
 use crate::utils::*;
 
+pub mod ast_fold;
+
 /// A name. Generally columns, tables, functions, variables.
 pub type Ident = String;
 pub type Pipeline = Vec<Transform>;
diff --git a/prql/src/cli.rs b/prql-compiler/src/cli.rs
similarity index 100%
rename from prql/src/cli.rs
rename to prql-compiler/src/cli.rs
diff --git a/prql/src/error.rs b/prql-compiler/src/error.rs
similarity index 100%
rename from prql/src/error.rs
rename to prql-compiler/src/error.rs
diff --git a/prql/src/lib.rs b/prql-compiler/src/lib.rs
similarity index 94%
rename from prql/src/lib.rs
rename to prql-compiler/src/lib.rs
index 16e78a5b..8557179f 100644
--- a/prql/src/lib.rs
+++ b/prql-compiler/src/lib.rs
@@ -1,5 +1,4 @@
 mod ast;
-mod ast_fold;
 #[cfg(feature = "cli")]
 mod cli;
 mod error;
@@ -30,7 +29,7 @@ pub fn compile(prql: &str) -> Result<String> {
 /// the exported items without items they rely on — feel free to request
 /// associated items be made public if required.
 pub mod internals {
+    pub use crate::ast::ast_fold::AstFold;
     pub use crate::ast::Node;
-    pub use crate::ast_fold::AstFold;
     pub use crate::utils::{IntoOnly, Only};
 }
diff --git a/prql/src/main.rs b/prql-compiler/src/main.rs
similarity index 93%
rename from prql/src/main.rs
rename to prql-compiler/src/main.rs
index 01bc0238..b48d9135 100644
--- a/prql/src/main.rs
+++ b/prql-compiler/src/main.rs
@@ -3,7 +3,7 @@ use std::process::exit;
 #[cfg(feature = "cli")]
 fn main() -> color_eyre::eyre::Result<()> {
     use clap::Parser;
-    use prql::Cli;
+    use prql_compiler::Cli;
 
     color_eyre::install()?;
     let mut cli = Cli::parse();
diff --git a/prql/src/parser.rs b/prql-compiler/src/parser.rs
similarity index 100%
rename from prql/src/parser.rs
rename to prql-compiler/src/parser.rs
diff --git a/prql/src/prql.pest b/prql-compiler/src/prql.pest
similarity index 100%
rename from prql/src/prql.pest
rename to prql-compiler/src/prql.pest
diff --git a/prql/src/semantic/context.rs b/prql-compiler/src/semantic/context.rs
similarity index 100%
rename from prql/src/semantic/context.rs
rename to prql-compiler/src/semantic/context.rs
diff --git a/prql/src/semantic/materializer.rs b/prql-compiler/src/semantic/materializer.rs
similarity index 99%
rename from prql/src/semantic/materializer.rs
rename to prql-compiler/src/semantic/materializer.rs
index c3b02ce5..be5fa3df 100644
--- a/prql/src/semantic/materializer.rs
+++ b/prql-compiler/src/semantic/materializer.rs
@@ -3,8 +3,8 @@
 //! contains no query-specific logic.
 use std::collections::HashMap;
 
+use crate::ast::ast_fold::*;
 use crate::ast::*;
-use crate::ast_fold::*;
 use crate::error::{Error, Reason};
 
 use anyhow::{anyhow, bail, Result};
diff --git a/prql/src/semantic/mod.rs b/prql-compiler/src/semantic/mod.rs
similarity index 100%
rename from prql/src/semantic/mod.rs
rename to prql-compiler/src/semantic/mod.rs
diff --git a/prql/src/semantic/reporting.rs b/prql-compiler/src/semantic/reporting.rs
similarity index 100%
rename from prql/src/semantic/reporting.rs
rename to prql-compiler/src/semantic/reporting.rs
diff --git a/prql/src/semantic/resolver.rs b/prql-compiler/src/semantic/resolver.rs
similarity index 99%
rename from prql/src/semantic/resolver.rs
rename to prql-compiler/src/semantic/resolver.rs
index c3ee1a00..c77e7ee5 100644
--- a/prql/src/semantic/resolver.rs
+++ b/prql-compiler/src/semantic/resolver.rs
@@ -2,8 +2,8 @@ use anyhow::anyhow;
 use anyhow::Result;
 use itertools::Itertools;
 
+use crate::ast::ast_fold::*;
 use crate::ast::*;
-use crate::ast_fold::*;
 use crate::error::{Error, Reason};
 
 use super::context::{Context, Frame};
diff --git a/prql/tests/integration/main.rs b/prql-compiler/tests/integration/main.rs
similarity index 100%
rename from prql/tests/integration/main.rs
rename to prql-compiler/tests/integration/main.rs
diff --git a/prql-js/Cargo.toml b/prql-js/Cargo.toml
index 8fd31179..57b59b61 100644
--- a/prql-js/Cargo.toml
+++ b/prql-js/Cargo.toml
@@ -14,7 +14,7 @@ default = ["console_error_panic_hook"]
 
 [dependencies]
 wasm-bindgen = "0.2.63"
-prql = { path = "../prql" }
+prql-compiler = { path = "../prql-compiler" }
 
 # The `console_error_panic_hook` crate provides better debugging of panics by
 # logging them with `console.error`. This is great for development, but requires
diff --git a/prql-js/src/lib.rs b/prql-js/src/lib.rs
index 2c951766..f4673347 100644
--- a/prql-js/src/lib.rs
+++ b/prql-js/src/lib.rs
@@ -1,7 +1,7 @@
 #![allow(clippy::unused_unit)]
 mod utils;
 
-use prql::format_error;
+use prql_compiler::format_error;
 use wasm_bindgen::prelude::*;
 
 // When the `wee_alloc` feature is enabled, use `wee_alloc` as the global
@@ -18,7 +18,7 @@ static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT;
 
 #[wasm_bindgen]
 pub fn compile(s: &str) -> CompileResult {
-    let result = prql::compile(s).map_err(|e| format_error(e, "", s, false));
+    let result = prql_compiler::compile(s).map_err(|e| format_error(e, "", s, false));
 
     // I had to make new CompileResult struct, because I couldn't make wasm_bindgen
     // accept it as a function return value. I also had to implement a few getters. Yuck.
diff --git a/prql-web/Cargo.toml b/prql-web/Cargo.toml
index c0c548ee..309889ab 100644
--- a/prql-web/Cargo.toml
+++ b/prql-web/Cargo.toml
@@ -14,7 +14,7 @@ crate-type = ["cdylib"]
 default = ["wee_alloc"]
 
 [dependencies]
-prql = {path = "../prql"}
+prql-compiler = {path = "../prql-compiler"}
 
 [target.'cfg(target_family="wasm")'.dependencies]
 console_error_panic_hook = {version = "0.1.1"}
diff --git a/prql-web/src/lib.rs b/prql-web/src/lib.rs
index 0c9c7c07..5bb6e853 100644
--- a/prql-web/src/lib.rs
+++ b/prql-web/src/lib.rs
@@ -8,7 +8,7 @@ use monaco::{
     sys::editor::{IEditorMinimapOptions, IStandaloneEditorConstructionOptions},
     yew::CodeEditor,
 };
-use prql::*;
+use prql_compiler::*;
 use wasm_bindgen::prelude::wasm_bindgen;
 use yew::{classes, html, Component, Context, Html, Properties};
 
diff --git a/reference/Cargo.toml b/reference/Cargo.toml
index 0b7b0251..b435aaf5 100644
--- a/reference/Cargo.toml
+++ b/reference/Cargo.toml
@@ -9,7 +9,7 @@ version = "0.1.1"
 [dependencies]
 anyhow = "^1.0"
 itertools = "^0.10"
-prql = {path = "../prql"}
+prql-compiler = {path = "../prql-compiler"}
 
 [dev-dependencies]
 globset = "0.4.8"
diff --git a/reference/mdbook-prql/Cargo.toml b/reference/mdbook-prql/Cargo.toml
index 30232074..f9641336 100644
--- a/reference/mdbook-prql/Cargo.toml
+++ b/reference/mdbook-prql/Cargo.toml
@@ -14,7 +14,7 @@ insta = {version = "^1.13", features = ["colors", "glob"]}
 itertools = "^0.10"
 mdbook = {version = "0.4.14", default-features = false}
 mdbook-preprocessor-boilerplate = "0.1.1"
-prql = {path = "../../prql"}
+prql-compiler = {path = "../../prql-compiler"}
 pulldown-cmark = "0.9.1"
 pulldown-cmark-to-cmark = "10"
 semver = "1.0"
diff --git a/reference/mdbook-prql/src/main.rs b/reference/mdbook-prql/src/main.rs
index f8f3569a..ea5be96b 100644
--- a/reference/mdbook-prql/src/main.rs
+++ b/reference/mdbook-prql/src/main.rs
@@ -6,7 +6,7 @@ use clap::{App, Arg, ArgMatches, SubCommand};
 use mdbook::preprocess::PreprocessorContext;
 use mdbook::preprocess::{CmdPreprocessor, Preprocessor};
 use mdbook::{book::Book, BookItem};
-use prql::compile;
+use prql_compiler::compile;
 use pulldown_cmark::{CodeBlockKind, Event, Parser, Tag};
 use pulldown_cmark_to_cmark::cmark;
 use semver::{Version, VersionReq};
diff --git a/reference/src/SUMMARY.md b/reference/src/SUMMARY.md
index 5c3262a2..67964dd0 100644
--- a/reference/src/SUMMARY.md
+++ b/reference/src/SUMMARY.md
@@ -6,8 +6,7 @@
 - [Language features](./language-features/README.md)
 
   - [F-Strings](./language-features/f-strings.md)
-    <!-- - Ranges — `BETWEEN 1 AND 3` -> `in 1..3`? -->
-  - [Ranges]()
+  - [Ranges](./language-features/ranges.md)
     <!-- - - Dates — `"2021-01-01"` -> `@2021-01-01`? And `DATE_TRUNC(foo_date, YEAR)` -> `foo_date.year`? Or -> `foo_date | as year`? Or `foo_date | to year`? -->
     <!-- - Offsets — `DATE_ADD(DATE "2008-12-25", INTERVAL 5 DAY)` -> `@2008-12-25 - 5day`? -->
   - [Dates]()
diff --git a/reference/src/language-features/ranges.md b/reference/src/language-features/ranges.md
new file mode 100644
index 00000000..7f0b300d
--- /dev/null
+++ b/reference/src/language-features/ranges.md
@@ -0,0 +1,10 @@
+# Ranges
+
+PRQL has a concise range syntax `start..end`, which can be accessed with the `in` function:
+
+```prql
+from employees
+filter (age | in 18..40)
+```
+
+Like in SQL, ranges are inclusive.


Test patch:
diff --git a/prql/src/semantic/snapshots/prql__semantic__materializer__test__materialize_2.snap b/prql-compiler/src/semantic/snapshots/prql_compiler__semantic__materializer__test__materialize_2.snap
similarity index 95%
rename from prql/src/semantic/snapshots/prql__semantic__materializer__test__materialize_2.snap
rename to prql-compiler/src/semantic/snapshots/prql_compiler__semantic__materializer__test__materialize_2.snap
index 89414aab..26f237e3 100644
--- a/prql/src/semantic/snapshots/prql__semantic__materializer__test__materialize_2.snap
+++ b/prql-compiler/src/semantic/snapshots/prql_compiler__semantic__materializer__test__materialize_2.snap
@@ -1,5 +1,5 @@
 ---
-source: prql/src/semantic/materializer.rs
+source: prql-compiler/src/semantic/materializer.rs
 expression: mat
 ---
 - Pipeline:
diff --git a/prql/src/semantic/snapshots/prql__semantic__materializer__test__materialize_3.snap b/prql-compiler/src/semantic/snapshots/prql_compiler__semantic__materializer__test__materialize_3.snap
similarity index 51%
rename from prql/src/semantic/snapshots/prql__semantic__materializer__test__materialize_3.snap
rename to prql-compiler/src/semantic/snapshots/prql_compiler__semantic__materializer__test__materialize_3.snap
index dc0b112e..cd18b490 100644
--- a/prql/src/semantic/snapshots/prql__semantic__materializer__test__materialize_3.snap
+++ b/prql-compiler/src/semantic/snapshots/prql_compiler__semantic__materializer__test__materialize_3.snap
@@ -1,6 +1,6 @@
 ---
-source: prql/src/semantic/materializer.rs
-expression: mat.nodes
+source: prql-compiler/src/semantic/materializer.rs
+expression: mat
 ---
 - Pipeline:
     - From:
diff --git a/prql/src/semantic/snapshots/prql__semantic__materializer__test__replace_variables_2.snap b/prql-compiler/src/semantic/snapshots/prql_compiler__semantic__materializer__test__replace_variables_2.snap
similarity index 95%
rename from prql/src/semantic/snapshots/prql__semantic__materializer__test__replace_variables_2.snap
rename to prql-compiler/src/semantic/snapshots/prql_compiler__semantic__materializer__test__replace_variables_2.snap
index 74d6a414..2b574804 100644
--- a/prql/src/semantic/snapshots/prql__semantic__materializer__test__replace_variables_2.snap
+++ b/prql-compiler/src/semantic/snapshots/prql_compiler__semantic__materializer__test__replace_variables_2.snap
@@ -1,5 +1,5 @@
 ---
-source: prql/src/semantic/materializer.rs
+source: prql-compiler/src/semantic/materializer.rs
 expression: "&mat"
 ---
 - Pipeline:
diff --git a/prql/src/snapshots/prql__parser__test__inline_pipeline.snap b/prql-compiler/src/snapshots/prql_compiler__parser__test__inline_pipeline.snap
similarity index 98%
rename from prql/src/snapshots/prql__parser__test__inline_pipeline.snap
rename to prql-compiler/src/snapshots/prql_compiler__parser__test__inline_pipeline.snap
index 8a632f09..edbc48e9 100644
--- a/prql/src/snapshots/prql__parser__test__inline_pipeline.snap
+++ b/prql-compiler/src/snapshots/prql_compiler__parser__test__inline_pipeline.snap
@@ -1,5 +1,5 @@
 ---
-source: prql/src/parser.rs
+source: prql-compiler/src/parser.rs
 expression: "parse_tree_of_str(\"(salary | percentile 50)\", Rule::inline_pipeline)?"
 ---
 [
diff --git a/prql/src/snapshots/prql__parser__test__parse_function.snap b/prql-compiler/src/snapshots/prql_compiler__parser__test__parse_function.snap
similarity index 98%
rename from prql/src/snapshots/prql__parser__test__parse_function.snap
rename to prql-compiler/src/snapshots/prql_compiler__parser__test__parse_function.snap
index a9667b75..3b23962b 100644
--- a/prql/src/snapshots/prql__parser__test__parse_function.snap
+++ b/prql-compiler/src/snapshots/prql_compiler__parser__test__parse_function.snap
@@ -1,5 +1,5 @@
 ---
-source: prql/src/parser.rs
+source: prql-compiler/src/parser.rs
 expression: "parse_tree_of_str(\"func plus_one x = x + 1\", Rule::func_def)?"
 ---
 [
diff --git a/prql/src/snapshots/prql__parser__test__parse_into_parse_tree-10.snap b/prql-compiler/src/snapshots/prql_compiler__parser__test__parse_into_parse_tree-10.snap
similarity index 96%
rename from prql/src/snapshots/prql__parser__test__parse_into_parse_tree-10.snap
rename to prql-compiler/src/snapshots/prql_compiler__parser__test__parse_into_parse_tree-10.snap
index d332549f..154f7ba5 100644
--- a/prql/src/snapshots/prql__parser__test__parse_into_parse_tree-10.snap
+++ b/prql-compiler/src/snapshots/prql_compiler__parser__test__parse_into_parse_tree-10.snap
@@ -1,5 +1,5 @@
 ---
-source: src/parser.rs
+source: prql-compiler/src/parser.rs
 expression: "parse_tree_of_str(\"1  + 2\", Rule::expr)?"
 ---
 [
diff --git a/prql/src/snapshots/prql__parser__test__parse_into_parse_tree-2.snap b/prql-compiler/src/snapshots/prql_compiler__parser__test__parse_into_parse_tree-2.snap
similarity index 99%
rename from prql/src/snapshots/prql__parser__test__parse_into_parse_tree-2.snap
rename to prql-compiler/src/snapshots/prql_compiler__parser__test__parse_into_parse_tree-2.snap
index e5d545f1..138d9fc7 100644
--- a/prql/src/snapshots/prql__parser__test__parse_into_parse_tree-2.snap
+++ b/prql-compiler/src/snapshots/prql_compiler__parser__test__parse_into_parse_tree-2.snap
@@ -1,5 +1,5 @@
 ---
-source: src/parser.rs
+source: prql-compiler/src/parser.rs
 expression: "parse_tree_of_str(\"select [a, b, c]\", Rule::transformation)?"
 ---
 [
diff --git a/prql/src/snapshots/prql__parser__test__parse_into_parse_tree-3.snap b/prql-compiler/src/snapshots/prql_compiler__parser__test__parse_into_parse_tree-3.snap
similarity index 99%
rename from prql/src/snapshots/prql__parser__test__parse_into_parse_tree-3.snap
rename to prql-compiler/src/snapshots/prql_compiler__parser__test__parse_into_parse_tree-3.snap
index 3a7c5ba3..54cc245c 100644
--- a/prql/src/snapshots/prql__parser__test__parse_into_parse_tree-3.snap
+++ b/prql-compiler/src/snapshots/prql_compiler__parser__test__parse_into_parse_tree-3.snap
@@ -1,5 +1,5 @@
 ---
-source: prql/src/parser.rs
+source: prql-compiler/src/parser.rs
 expression: "parse_tree_of_str(\"aggregate by:[title, country] [sum salary]\",\n                  Rule::transformation)?"
 ---
 [
diff --git a/prql/src/snapshots/prql__parser__test__parse_into_parse_tree-4.snap b/prql-compiler/src/snapshots/prql_compiler__parser__test__parse_into_parse_tree-4.snap
similarity index 98%
rename from prql/src/snapshots/prql__parser__test__parse_into_parse_tree-4.snap
rename to prql-compiler/src/snapshots/prql_compiler__parser__test__parse_into_parse_tree-4.snap
index 77f57547..811e4aa8 100644
--- a/prql/src/snapshots/prql__parser__test__parse_into_parse_tree-4.snap
+++ b/prql-compiler/src/snapshots/prql_compiler__parser__test__parse_into_parse_tree-4.snap
@@ -1,5 +1,5 @@
 ---
-source: src/parser.rs
+source: prql-compiler/src/parser.rs
 expression: "parse_tree_of_str(r#\"    filter country = \"USA\"\"#, Rule::transformation)?"
 ---
 [
diff --git a/prql/src/snapshots/prql__parser__test__parse_into_parse_tree-5.snap b/prql-compiler/src/snapshots/prql_compiler__parser__test__parse_into_parse_tree-5.snap
similarity index 98%
rename from prql/src/snapshots/prql__parser__test__parse_into_parse_tree-5.snap
rename to prql-compiler/src/snapshots/prql_compiler__parser__test__parse_into_parse_tree-5.snap
index 8e2be910..7d9b9c3f 100644
--- a/prql/src/snapshots/prql__parser__test__parse_into_parse_tree-5.snap
+++ b/prql-compiler/src/snapshots/prql_compiler__parser__test__parse_into_parse_tree-5.snap
@@ -1,5 +1,5 @@
 ---
-source: src/parser.rs
+source: prql-compiler/src/parser.rs
 expression: "parse_tree_of_str(\"[a, b, c,]\", Rule::list)?"
 ---
 [
diff --git a/prql/src/snapshots/prql__parser__test__parse_into_parse_tree-6.snap b/prql-compiler/src/snapshots/prql_compiler__parser__test__parse_into_parse_tree-6.snap
similarity index 99%
rename from prql/src/snapshots/prql__parser__test__parse_into_parse_tree-6.snap
rename to prql-compiler/src/snapshots/prql_compiler__parser__test__parse_into_parse_tree-6.snap
index b414bc2a..68f0f9f2 100644
--- a/prql/src/snapshots/prql__parser__test__parse_into_parse_tree-6.snap
+++ b/prql-compiler/src/snapshots/prql_compiler__parser__test__parse_into_parse_tree-6.snap
@@ -1,5 +1,5 @@
 ---
-source: prql/src/parser.rs
+source: prql-compiler/src/parser.rs
 expression: "parse_tree_of_str(r#\"[\n  gross_salary: salary + payroll_tax,\n  gross_cost  : gross_salary + benefits_cost\n]\"#,\n                  Rule::list)?"
 ---
 [
diff --git a/prql/src/snapshots/prql__parser__test__parse_into_parse_tree-7.snap b/prql-compiler/src/snapshots/prql_compiler__parser__test__parse_into_parse_tree-7.snap
similarity index 71%
rename from prql/src/snapshots/prql__parser__test__parse_into_parse_tree-7.snap
rename to prql-compiler/src/snapshots/prql_compiler__parser__test__parse_into_parse_tree-7.snap
index f1043135..fddbba05 100644
--- a/prql/src/snapshots/prql__parser__test__parse_into_parse_tree-7.snap
+++ b/prql-compiler/src/snapshots/prql_compiler__parser__test__parse_into_parse_tree-7.snap
@@ -1,6 +1,5 @@
 ---
-source: src/parser.rs
-assertion_line: 798
+source: prql-compiler/src/parser.rs
 expression: "parse_tree_of_str(r#\"# this is a comment\n        select a\"#, Rule::COMMENT)?"
 ---
 []
diff --git a/prql/src/snapshots/prql__parser__test__parse_into_parse_tree-8.snap b/prql-compiler/src/snapshots/prql_compiler__parser__test__parse_into_parse_tree-8.snap
similarity index 99%
rename from prql/src/snapshots/prql__parser__test__parse_into_parse_tree-8.snap
rename to prql-compiler/src/snapshots/prql_compiler__parser__test__parse_into_parse_tree-8.snap
index 1b9a3c69..5797ef9f 100644
--- a/prql/src/snapshots/prql__parser__test__parse_into_parse_tree-8.snap
+++ b/prql-compiler/src/snapshots/prql_compiler__parser__test__parse_into_parse_tree-8.snap
@@ -1,5 +1,5 @@
 ---
-source: src/parser.rs
+source: prql-compiler/src/parser.rs
 expression: "parse_tree_of_str(\"join country [id=employee_id]\", Rule::transformation)?"
 ---
 [
diff --git a/prql/src/snapshots/prql__parser__test__parse_into_parse_tree-9.snap b/prql-compiler/src/snapshots/prql_compiler__parser__test__parse_into_parse_tree-9.snap
similarity index 99%
rename from prql/src/snapshots/prql__parser__test__parse_into_parse_tree-9.snap
rename to prql-compiler/src/snapshots/prql_compiler__parser__test__parse_into_parse_tree-9.snap
index af706efe..5bd97357 100644
--- a/prql/src/snapshots/prql__parser__test__parse_into_parse_tree-9.snap
+++ b/prql-compiler/src/snapshots/prql_compiler__parser__test__parse_into_parse_tree-9.snap
@@ -1,5 +1,5 @@
 ---
-source: prql/src/parser.rs
+source: prql-compiler/src/parser.rs
 expression: "parse_tree_of_str(\"join side:left country [id=employee_id]\",\n                  Rule::transformation)?"
 ---
 [
diff --git a/prql/src/snapshots/prql__parser__test__parse_into_parse_tree.snap b/prql-compiler/src/snapshots/prql_compiler__parser__test__parse_into_parse_tree.snap
similarity index 97%
rename from prql/src/snapshots/prql__parser__test__parse_into_parse_tree.snap
rename to prql-compiler/src/snapshots/prql_compiler__parser__test__parse_into_parse_tree.snap
index 85331916..5d67d038 100644
--- a/prql/src/snapshots/prql__parser__test__parse_into_parse_tree.snap
+++ b/prql-compiler/src/snapshots/prql_compiler__parser__test__parse_into_parse_tree.snap
@@ -1,5 +1,5 @@
 ---
-source: src/parser.rs
+source: prql-compiler/src/parser.rs
 expression: "parse_tree_of_str(r#\"country = \"USA\"\"#, Rule::expr)?"
 ---
 [
diff --git a/prql/src/snapshots/prql__parser__test__parse_list.snap b/prql-compiler/src/snapshots/prql_compiler__parser__test__parse_list.snap
similarity index 98%
rename from prql/src/snapshots/prql__parser__test__parse_list.snap
rename to prql-compiler/src/snapshots/prql_compiler__parser__test__parse_list.snap
index b69742e3..bec2b21c 100644
--- a/prql/src/snapshots/prql__parser__test__parse_list.snap
+++ b/prql-compiler/src/snapshots/prql_compiler__parser__test__parse_list.snap
@@ -1,5 +1,5 @@
 ---
-source: src/parser.rs
+source: prql-compiler/src/parser.rs
 expression: "parse_tree_of_str(r#\"[1 + 1, 2]\"#, Rule::list)?"
 ---
 [
diff --git a/prql/src/snapshots/prql__parser__test__parse_number-2.snap b/prql-compiler/src/snapshots/prql_compiler__parser__test__parse_number-2.snap
similarity index 96%
rename from prql/src/snapshots/prql__parser__test__parse_number-2.snap
rename to prql-compiler/src/snapshots/prql_compiler__parser__test__parse_number-2.snap
index bff5e258..b204dc0f 100644
--- a/prql/src/snapshots/prql__parser__test__parse_number-2.snap
+++ b/prql-compiler/src/snapshots/prql_compiler__parser__test__parse_number-2.snap
@@ -1,5 +1,5 @@
 ---
-source: src/parser.rs
+source: prql-compiler/src/parser.rs
 expression: "parse_tree_of_str(r#\"2 + 2\"#, Rule::expr)?"
 ---
 [
diff --git a/prql/src/snapshots/prql__parser__test__parse_pipeline_parse_tree-2.snap b/prql-compiler/src/snapshots/prql_compiler__parser__test__parse_pipeline_parse_tree-2.snap
similarity index 99%
rename from prql/src/snapshots/prql__parser__test__parse_pipeline_parse_tree-2.snap
rename to prql-compiler/src/snapshots/prql_compiler__parser__test__parse_pipeline_parse_tree-2.snap
index 92dd2866..af2a6d9f 100644
--- a/prql/src/snapshots/prql__parser__test__parse_pipeline_parse_tree-2.snap
+++ b/prql-compiler/src/snapshots/prql_compiler__parser__test__parse_pipeline_parse_tree-2.snap
@@ -1,5 +1,5 @@
 ---
-source: src/parser.rs
+source: prql-compiler/src/parser.rs
 expression: "parse_tree_of_str(r#\"\n    from employees\n    filter country = \"USA\"\n    \"#.trim(),\n                  Rule::pipeline)?"
 ---
 [
diff --git a/prql/src/snapshots/prql__parser__test__parse_pipeline_parse_tree-3.snap b/prql-compiler/src/snapshots/prql_compiler__parser__test__parse_pipeline_parse_tree-3.snap
similarity index 99%
rename from prql/src/snapshots/prql__parser__test__parse_pipeline_parse_tree-3.snap
rename to prql-compiler/src/snapshots/prql_compiler__parser__test__parse_pipeline_parse_tree-3.snap
index da398028..9ed0e2e8 100644
--- a/prql/src/snapshots/prql__parser__test__parse_pipeline_parse_tree-3.snap
+++ b/prql-compiler/src/snapshots/prql_compiler__parser__test__parse_pipeline_parse_tree-3.snap
@@ -1,5 +1,5 @@
 ---
-source: prql/src/parser.rs
+source: prql-compiler/src/parser.rs
 expression: "parse_tree_of_str(r#\"\nfrom employees\nfilter country = \"USA\"                           # Each line transforms the previous result.\nderive [                                         # This adds columns / variables.\n  gross_salary: salary + payroll_tax,\n  gross_cost  : gross_salary + benefits_cost    # Variables can use other variables.\n]\nfilter gross_cost > 0\naggregate by:[title, country] [                  # `by` are the columns to group by.\n    average salary,                              # These are aggregation calcs run on each group.\n    sum     salary,\n    average gross_salary,\n    sum     gross_salary,\n    average gross_cost,\n    sum_gross_cost: sum gross_cost,\n    count: count,\n]\nsort sum_gross_cost\nfilter count > 200\ntake 20\n    \"#.trim(),\n                  Rule::pipeline)?"
 ---
 [
diff --git a/prql/src/snapshots/prql__parser__test__parse_pipeline_parse_tree.snap b/prql-compiler/src/snapshots/prql_compiler__parser__test__parse_pipeline_parse_tree.snap
similarity index 99%
rename from prql/src/snapshots/prql__parser__test__parse_pipeline_parse_tree.snap
rename to prql-compiler/src/snapshots/prql_compiler__parser__test__parse_pipeline_parse_tree.snap
index b9e4232a..bf9e37f0 100644
--- a/prql/src/snapshots/prql__parser__test__parse_pipeline_parse_tree.snap
+++ b/prql-compiler/src/snapshots/prql_compiler__parser__test__parse_pipeline_parse_tree.snap
@@ -1,5 +1,5 @@
 ---
-source: src/parser.rs
+source: prql-compiler/src/parser.rs
 expression: "parse_tree_of_str(r#\"\n    from employees\n    select [a, b]\n    \"#.trim(),\n                  Rule::pipeline)?"
 ---
 [
diff --git a/prql/src/snapshots/prql__parser__test__parse_query.snap b/prql-compiler/src/snapshots/prql_compiler__parser__test__parse_query.snap
similarity index 98%
rename from prql/src/snapshots/prql__parser__test__parse_query.snap
rename to prql-compiler/src/snapshots/prql_compiler__parser__test__parse_query.snap
index ccf11116..2ccafc4a 100644
--- a/prql/src/snapshots/prql__parser__test__parse_query.snap
+++ b/prql-compiler/src/snapshots/prql_compiler__parser__test__parse_query.snap
@@ -1,5 +1,5 @@
 ---
-source: prql/src/parser.rs
+source: prql-compiler/src/parser.rs
 expression: "ast_of_string(r#\"\nfrom employees\nfilter country = \"USA\"                        # Each line transforms the previous result.\nderive [                                      # This adds columns / variables.\n  gross_salary: salary + payroll_tax,\n  gross_cost:   gross_salary + benefits_cost # Variables can use other variables.\n]\nfilter gross_cost > 0\naggregate by:[title, country] [               # `by` are the columns to group by.\n                   average salary,            # These are aggregation calcs run on each group.\n                   sum salary,\n                   average gross_salary,\n                   sum gross_salary,\n                   average gross_cost,\n  sum_gross_cost: sum gross_cost,\n  ct            : count,\n]\nsort sum_gross_cost\nfilter ct > 200\ntake 20\n    \"#.trim(),\n              Rule::query)?"
 ---
 Query:
diff --git a/prql/src/snapshots/prql__parser__test__parse_s_string.snap b/prql-compiler/src/snapshots/prql_compiler__parser__test__parse_s_string.snap
similarity index 97%
rename from prql/src/snapshots/prql__parser__test__parse_s_string.snap
rename to prql-compiler/src/snapshots/prql_compiler__parser__test__parse_s_string.snap
index 1d689b70..37f0d977 100644
--- a/prql/src/snapshots/prql__parser__test__parse_s_string.snap
+++ b/prql-compiler/src/snapshots/prql_compiler__parser__test__parse_s_string.snap
@@ -1,5 +1,5 @@
 ---
-source: prql/src/parser.rs
+source: prql-compiler/src/parser.rs
 expression: "parse_tree_of_str(r#\"s\"SUM({col})\"\"#, Rule::s_string)?"
 ---
 [
diff --git a/prql/src/snapshots/prql__translator__test__prql_to_sql_2.snap b/prql-compiler/src/snapshots/prql_compiler__translator__test__prql_to_sql_2.snap
similarity index 91%
rename from prql/src/snapshots/prql__translator__test__prql_to_sql_2.snap
rename to prql-compiler/src/snapshots/prql_compiler__translator__test__prql_to_sql_2.snap
index ca55d65e..76578aea 100644
--- a/prql/src/snapshots/prql__translator__test__prql_to_sql_2.snap
+++ b/prql-compiler/src/snapshots/prql_compiler__translator__test__prql_to_sql_2.snap
@@ -1,5 +1,5 @@
 ---
-source: prql/src/translator.rs
+source: prql-compiler/src/translator.rs
 expression: sql
 ---
 SELECT
diff --git a/prql/src/stdlib.prql b/prql-compiler/src/stdlib.prql
similarity index 100%
rename from prql/src/stdlib.prql
rename to prql-compiler/src/stdlib.prql
diff --git a/prql/src/translator.rs b/prql-compiler/src/translator.rs
similarity index 100%
rename from prql/src/translator.rs
rename to prql-compiler/src/translator.rs
diff --git a/prql/src/utils.rs b/prql-compiler/src/utils.rs
similarity index 100%
rename from prql/src/utils.rs
rename to prql-compiler/src/utils.rs
diff --git a/prql/tests/integration/compile.rs b/prql-compiler/tests/integration/compile.rs
similarity index 99%
rename from prql/tests/integration/compile.rs
rename to prql-compiler/tests/integration/compile.rs
index 2d309561..7763950a 100644
--- a/prql/tests/integration/compile.rs
+++ b/prql-compiler/tests/integration/compile.rs
@@ -1,5 +1,5 @@
 use insta::assert_snapshot;
-use prql::*;
+use prql_compiler::*;
 
 #[test]
 fn parse_simple_string_to_ast() -> Result<()> {
diff --git a/prql/tests/integration/snapshots/integration__examples__run_examples@cte-1.prql.snap b/prql/tests/integration/snapshots/integration__examples__run_examples@cte-1.prql.snap
deleted file mode 100644
index aa720e1d..00000000
--- a/prql/tests/integration/snapshots/integration__examples__run_examples@cte-1.prql.snap
+++ /dev/null
@@ -1,30 +0,0 @@
----
-source: prql/tests/integration/examples.rs
-expression: sql
-input_file: prql/tests/integration/examples/cte-1.prql
----
-WITH newest_employees AS (
-  SELECT
-    employees.*
-  FROM
-    employees
-  ORDER BY
-    employees.tenure
-  LIMIT
-    50
-), average_salaries AS (
-  SELECT
-    country,
-    AVG(salary) AS average_country_salary
-  FROM
-    salaries
-  GROUP BY
-    country
-)
-SELECT
-  name,
-  salary,
-  average_country_salary
-FROM
-  newest_employees
-  JOIN average_salaries USING(country)
diff --git a/prql/tests/integration/snapshots/integration__examples__run_examples@employees-0.prql.snap b/prql/tests/integration/snapshots/integration__examples__run_examples@employees-0.prql.snap
deleted file mode 100644
index 5e3d42eb..00000000
--- a/prql/tests/integration/snapshots/integration__examples__run_examples@employees-0.prql.snap
+++ /dev/null
@@ -1,34 +0,0 @@
----
-source: prql/tests/integration/examples.rs
-expression: sql
-input_file: prql/tests/integration/examples/employees-0.prql
----
-WITH table_0 AS (
-  SELECT
-    emp_no,
-    AVG(salary) AS emp_salary
-  FROM
-    salaries
-  GROUP BY
-    emp_no
-),
-table_1 AS (
-  SELECT
-    dept_emp.dept_no,
-    t.title,
-    AVG(emp_salary) AS avg_salary
-  FROM
-    table_0
-    JOIN titles AS t USING(emp_no)
-    LEFT JOIN dept_emp USING(emp_no)
-  GROUP BY
-    dept_emp.dept_no,
-    t.title
-)
-SELECT
-  dept_name,
-  title,
-  avg_salary
-FROM
-  table_1
-  JOIN departments USING(dept_no)
diff --git a/prql/tests/integration/snapshots/integration__examples__run_examples@employees-1.prql.snap b/prql/tests/integration/snapshots/integration__examples__run_examples@employees-1.prql.snap
deleted file mode 100644
index b96c80ab..00000000
--- a/prql/tests/integration/snapshots/integration__examples__run_examples@employees-1.prql.snap
+++ /dev/null
@@ -1,38 +0,0 @@
----
-source: prql/tests/integration/examples.rs
-expression: sql
-input_file: prql/tests/integration/examples/employees-1.prql
----
-WITH table_0 AS (
-  SELECT
-    emp_no,
-    gender,
-    AVG(salary) AS emp_salary
-  FROM
-    employees
-    JOIN salaries USING(emp_no)
-  GROUP BY
-    emp_no,
-    gender
-),
-table_1 AS (
-  SELECT
-    de.dept_no,
-    gender,
-    AVG(emp_salary) AS salary_avg,
-    STDDEV(emp_salary) AS salary_sd
-  FROM
-    table_0
-    LEFT JOIN dept_emp AS de USING(emp_no)
-  GROUP BY
-    de.dept_no,
-    gender
-)
-SELECT
-  dept_name,
-  gender,
-  salary_avg,
-  salary_sd
-FROM
-  table_1
-  JOIN departments USING(dept_no)
diff --git a/prql/tests/integration/snapshots/integration__examples__run_examples@employees-2.prql.snap b/prql/tests/integration/snapshots/integration__examples__run_examples@employees-2.prql.snap
deleted file mode 100644
index 43fcb13c..00000000
--- a/prql/tests/integration/snapshots/integration__examples__run_examples@employees-2.prql.snap
+++ /dev/null
@@ -1,41 +0,0 @@
----
-source: prql/tests/integration/examples.rs
-expression: sql
-input_file: prql/tests/integration/examples/employees-2.prql
----
-WITH table_0 AS (
-  SELECT
-    emp_no,
-    gender,
-    AVG(salary) AS emp_salary
-  FROM
-    employees
-    JOIN salaries USING(emp_no)
-  GROUP BY
-    emp_no,
-    gender
-),
-table_1 AS (
-  SELECT
-    dm.emp_no,
-    gender,
-    AVG(emp_salary) AS salary_avg,
-    STDDEV(emp_salary) AS salary_sd,
-    dm.emp_no AS mng_no
-  FROM
-    table_0
-    JOIN dept_emp AS de USING(emp_no)
-    JOIN dept_manager AS dm ON dm.dept_no = de.dept_no
-    AND (de.from_date, de.to_date) OVERLAPS (dm.from_date, dm.to_date)
-  GROUP BY
-    dm.emp_no,
-    gender
-)
-SELECT
-  managers.first_name || ' ' || managers.last_name AS mng_name,
-  managers.gender,
-  salary_avg,
-  salary_sd
-FROM
-  table_1
-  JOIN employees AS managers USING(emp_no)
diff --git a/prql/tests/integration/snapshots/integration__examples__run_examples@employees-3.prql.snap b/prql/tests/integration/snapshots/integration__examples__run_examples@employees-3.prql.snap
deleted file mode 100644
index a9e20891..00000000
--- a/prql/tests/integration/snapshots/integration__examples__run_examples@employees-3.prql.snap
+++ /dev/null
@@ -1,27 +0,0 @@
----
-source: prql/tests/integration/examples.rs
-expression: sql
-input_file: prql/tests/integration/examples/employees-3.prql
----
-WITH table_0 AS (
-  SELECT
-    dept_emp.emp_no,
-    dept_emp.dept_no,
-    AVG(salaries.salary) AS salary
-  FROM
-    dept_emp
-    LEFT JOIN salaries ON salaries.emp_no = dept_emp.emp_no
-    AND (salaries.from_date, salaries.to_date) OVERLAPS (dept_emp.from_date, dept_emp.to_date)
-  GROUP BY
-    dept_emp.emp_no,
-    dept_emp.dept_no
-)
-SELECT
-  dept_no,
-  salary,
-  employees.gender,
-  titles.title
-FROM
-  table_0
-  JOIN employees USING(emp_no)
-  JOIN titles USING(emp_no)
diff --git a/prql/tests/integration/snapshots/integration__examples__run_examples@sql-parameters.prql.snap b/prql/tests/integration/snapshots/integration__examples__run_examples@sql-parameters.prql.snap
deleted file mode 100644
index c9837a4b..00000000
--- a/prql/tests/integration/snapshots/integration__examples__run_examples@sql-parameters.prql.snap
+++ /dev/null
@@ -1,11 +0,0 @@
----
-source: prql/tests/integration/examples.rs
-expression: sql
-input_file: prql/tests/integration/examples/sql-parameters.prql
----
-SELECT
-  mytable.*
-FROM
-  mytable
-WHERE
-  id = $1
diff --git a/prql/tests/integration/snapshots/integration__examples__run_examples@variables-1.prql.snap b/prql/tests/integration/snapshots/integration__examples__run_examples@variables-1.prql.snap
deleted file mode 100644
index 81c6d71c..00000000
--- a/prql/tests/integration/snapshots/integration__examples__run_examples@variables-1.prql.snap
+++ /dev/null
@@ -1,29 +0,0 @@
----
-source: prql/tests/integration/examples.rs
-expression: sql
-input_file: prql/tests/integration/examples/variables-1.prql
----
-SELECT
-  title,
-  country,
-  AVG(salary),
-  SUM(salary),
-  AVG(salary + payroll_tax),
-  SUM(salary + payroll_tax),
-  AVG(salary + payroll_tax + benefits_cost),
-  SUM(salary + payroll_tax + benefits_cost) AS sum_gross_cost,
-  COUNT(*) AS ct
-FROM
-  employees
-WHERE
-  country = 'USA'
-  AND salary + payroll_tax + benefits_cost > 0
-GROUP BY
-  title,
-  country
-HAVING
-  COUNT(*) > 200
-ORDER BY
-  sum_gross_cost
-LIMIT
-  20
diff --git a/prql/tests/integration/snapshots/integration__examples__run_examples@variables-2.prql.snap b/prql/tests/integration/snapshots/integration__examples__run_examples@variables-2.prql.snap
deleted file mode 100644
index 77f0f93a..00000000
--- a/prql/tests/integration/snapshots/integration__examples__run_examples@variables-2.prql.snap
+++ /dev/null
@@ -1,24 +0,0 @@
----
-source: prql/tests/integration/examples.rs
-expression: sql
-input_file: prql/tests/integration/examples/variables-2.prql
----
-WITH table_0 AS (
-  SELECT
-    emp_no,
-    AVG(salary) AS emp_salary
-  FROM
-    employees
-  GROUP BY
-    emp_no
-)
-SELECT
-  AVG(emp_salary) / 1000 AS salary_k,
-  AVG(emp_salary) / 1000 * 1000 AS salary
-FROM
-  table_0
-  JOIN titles USING(emp_no)
-GROUP BY
-  title
-LIMIT
-  10
diff --git a/reference/tests/examples/language-features/ranges-0.prql b/reference/tests/examples/language-features/ranges-0.prql
new file mode 100644
index 00000000..dc46261f
--- /dev/null
+++ b/reference/tests/examples/language-features/ranges-0.prql
@@ -0,0 +1,2 @@
+from employees
+filter (age | in 18..40)
diff --git a/reference/tests/snapshot.rs b/reference/tests/snapshot.rs
index e5ee05f8..06583004 100644
--- a/reference/tests/snapshot.rs
+++ b/reference/tests/snapshot.rs
@@ -17,7 +17,7 @@
 use anyhow::{bail, Result};
 use globset::Glob;
 use insta::{assert_snapshot, glob};
-use prql::*;
+use prql_compiler::*;
 use pulldown_cmark::{CodeBlockKind, Event, Parser, Tag};
 use std::fs;
 use std::path::Path;
diff --git a/reference/tests/snapshots/snapshot__run_reference_examples@functions-0.prql.snap b/reference/tests/snapshots/snapshot__run_reference_examples@functions-0.prql.snap
deleted file mode 100644
index 1bc167e0..00000000
--- a/reference/tests/snapshots/snapshot__run_reference_examples@functions-0.prql.snap
+++ /dev/null
@@ -1,38 +0,0 @@
----
-source: reference/tests/snapshot.rs
-expression: sql
-input_file: reference/tests/examples/examples/functions-0.prql
----
-Failed to compile `prql version:0.1 db:snowflake                         # Version number & database name.
-
-func lag_day x = (
-  window x
-  by sec_id
-  sort date
-  lag 1
-)
-func ret x = x / (x | lag_day) - 1 + dividend_return
-func excess x = (x - interest_rate) / 252
-func if_valid x = is_valid_price ? x : null
-
-from prices
-derive [
-  return_total:      prices_adj   | ret | if_valid  # `|` can be used rather than newlines.
-  return_usd:        prices_usd   | ret | if_valid
-  return_excess:     return_total | excess
-  return_usd_excess: return_usd   | excess
-]
-select [
-  date,
-  sec_id,
-  return_total,
-  return_usd,
-  return_excess,
-  return_usd_excess,
-]
-`;  --> 3:19
-  |
-3 | func lag_day x = (␊
-  |                   ^---
-  |
-  = expected expr
diff --git a/reference/tests/snapshots/snapshot__run_reference_examples@ranges-0.prql.snap b/reference/tests/snapshots/snapshot__run_reference_examples@ranges-0.prql.snap
new file mode 100644
index 00000000..890de50a
--- /dev/null
+++ b/reference/tests/snapshots/snapshot__run_reference_examples@ranges-0.prql.snap
@@ -0,0 +1,12 @@
+---
+source: reference/tests/snapshot.rs
+expression: sql
+input_file: reference/tests/examples/language-features/ranges-0.prql
+---
+SELECT
+  employees.*
+FROM
+  employees
+WHERE
+  age BETWEEN 18
+  AND 40