Repository: prql/prql
Pull request #874 (2022-07-28 01:33:20)

Final fix of BQ quotes (hopefully)

max-sixty: Closes https://github.com/prql/prql/issues/852, hopefully. Please say where I'm wrong!

Patch:
diff --git a/prql-compiler/src/parser.rs b/prql-compiler/src/parser.rs
index ddb92b80..03f52628 100644
--- a/prql-compiler/src/parser.rs
+++ b/prql-compiler/src/parser.rs
@@ -220,13 +220,13 @@ fn ast_of_parse_pair(pair: Pair<Rule>) -> Result<Option<Node>> {
                 pipeline: Box::new(pipeline),
             })
         }
-        Rule::ident | Rule::jinja => {
+        Rule::jinja => {
             let inner = pair.as_str();
-            let stripped = inner
-                .strip_prefix('`')
-                .and_then(|s| s.strip_suffix('`'))
-                .unwrap_or(inner);
-            Item::Ident(stripped.to_string())
+            Item::Ident(inner.to_string())
+        }
+        Rule::ident => {
+            let inner = pair.clone().into_inner();
+            Item::Ident(inner.into_iter().map(|x| x.as_str().to_string()).collect())
         }
 
         Rule::number => {
@@ -244,6 +244,7 @@ fn ast_of_parse_pair(pair: Pair<Rule>) -> Result<Option<Node>> {
         Rule::null => Item::Literal(Literal::Null),
         Rule::boolean => Item::Literal(Literal::Boolean(pair.as_str() == "true")),
         Rule::string => {
+            // Takes the string_inner, without the quotes
             let inner = pair.into_inner().into_only()?.as_str().to_string();
             Item::Literal(Literal::String(inner))
         }
@@ -1463,6 +1464,7 @@ aggregate [max c]
 join `my-proj.dataset.table`
 join `my-proj`.`dataset`.`table`
 ";
+
         assert_yaml_snapshot!(parse(prql)?, @r###"
         ---
         version: ~
@@ -1493,7 +1495,7 @@ join `my-proj`.`dataset`.`table`
                 - FuncCall:
                     name: join
                     args:
-                      - Ident: "my-proj`.`dataset`.`table"
+                      - Ident: my-proj.dataset.table
                     named_args: {}
         "###);
 
diff --git a/prql-compiler/src/prql.pest b/prql-compiler/src/prql.pest
index d0f3ccce..89ad3ccd 100644
--- a/prql-compiler/src/prql.pest
+++ b/prql-compiler/src/prql.pest
@@ -28,19 +28,21 @@ table = { "table" ~ ident ~ "=" ~ nested_pipeline }
 pipe = _{ NEWLINE | "|" }
 pipeline = { WHITESPACE* ~ expr_call ~ (pipe ~ expr_call)* }
 
-// We include backticks because some DBs use them (e.g. BigQuery) and we don't,
-// so we pass anything within them directly through, including otherwise invalid
-// idents, like those with hyphens. Possibly we should consider applying this to
-// expressions rather than just idents — we can adjust as we see more cases.
-ident = @{ !operator ~ !(keyword ~ WHITESPACE) ~ ident_start ~ ("." ~ ident_next)* }
+// See parser.rs for why this is so complicated to parse
+ident = ${ !operator ~ !(keyword ~ WHITESPACE) ~ (ident_part_first | ident_backticks) ~ (ident_part_next | ident_backticks)* }
 // Either a normal ident (starting with a letter, `$` or `_`), or any string surrounded
 // by backticks.
-ident_start = _{ ((ASCII_ALPHA | "$" | "_") ~ (ASCII_ALPHANUMERIC | "_" )* ) | ident_backticks+ }
-// We allow `e.*`, but not just `*`, since it might conflict with multiply in
+ident_part_first = { ((ASCII_ALPHA | "$" | "_") ~ (ASCII_ALPHANUMERIC | "_" )* ) }
+// We allow `e.*`, but not just `*`, since it would conflict with multiply in
 // some cases.
-ident_next = _{ ident_start | "*" }
+ident_part_next = _{ ident_separator ~ (ident_part_first | ident_star | ident_backticks) }
+// These two are split out so we can make `ident_part_next` silent, but still
+// capture these.
+ident_separator = { "." }
+ident_star = { "*" }
 // Anything surrounded by backticks, we pass through.
-ident_backticks = _{ "`" ~ (!NEWLINE ~ !"`" ~ ANY)* ~ "`" }
+// ident_backticks = _{ "`" ~ (!NEWLINE ~ !"`" ~ ANY)* ~ "`" }
+ident_backticks = _{ PUSH("`") ~ (!NEWLINE ~ string_inner)* ~ POP }
 // For sorting
 signed_ident = { ( "+" | "-" ) ~ ident }
 keyword = _{ "prql" | "table" | "func" }
@@ -87,6 +89,7 @@ expr_add = { expr_mul ~ (operator_add ~ expr_add)? }
 expr_mul = { term ~ (operator_mul ~ expr_mul)? }
 
 term = _{ ( s_string | f_string | range | literal | ident | nested_pipeline | expr_unary | list | jinja ) }
+// TODO: is this correct? We have `signed ident` above?
 // expr_unary is for sorting.
 expr_unary = { ( operator_unary ~ ( nested_pipeline | ident )) }
 literal = _{ interval | number | boolean | null | string | timestamp | date | time }
@@ -111,7 +114,7 @@ nested_pipeline = _{ "(" ~ (WHITESPACE | NEWLINE)* ~ pipeline ~ (WHITESPACE | NE
 single_quote = _{ "\"" | "'" }
 multi_quote = _{ "\""{3,} | "'"{3,} }
 opening_quote = _{ PUSH(multi_quote) | PUSH(single_quote) }
-// PEEK refers to the opening quote; either `"` or `'`.
+// PEEK refers to the opening quote; `"` or `'` or multiple quotes.
 string_inner = { ( !( PEEK ) ~ ANY )+ }
 // Either > 3 quotes, or just one. Currently both of those can be multiline.
 string = ${ ( opening_quote ) ~ string_inner ~ POP }
diff --git a/prql-compiler/src/sql/translator.rs b/prql-compiler/src/sql/translator.rs
index 0a27b92d..9a790f9f 100644
--- a/prql-compiler/src/sql/translator.rs
+++ b/prql-compiler/src/sql/translator.rs
@@ -777,7 +777,6 @@ fn translate_column(ident: String, dialect: &dyn DialectHandler) -> Vec<sql_ast:
             } else {
                 translate_ident(ident, dialect)
             }
-            // vec![sql_ast::Ident::new(table), sql_ast::Ident::new(column)]
         }
         _ => translate_ident(ident, dialect),
     }
@@ -2507,17 +2506,20 @@ from some_schema.tablename
 prql dialect:bigquery
 from db.schema.table
 join `db.schema.table2` [id]
+join `db`.`schema`.`table3` [id]
 join `db.schema.t-able` [id]
         "###,
         )?)?), @r###"
         SELECT
           `db.schema.table`.*,
           `db.schema.table2`.*,
+          `db.schema.table3`.*,
           `db.schema.t-able`.*,
           id
         FROM
           `db.schema.table`
           JOIN `db.schema.table2` USING(id)
+          JOIN `db.schema.table3` USING(id)
           JOIN `db.schema.t-able` USING(id)
         "###);
 


Test patch:
diff --git a/prql-compiler/src/snapshots/prql_compiler__parser__test__parse_into_parse_tree-2.snap b/prql-compiler/src/snapshots/prql_compiler__parser__test__parse_into_parse_tree-2.snap
index 4ff82297..8dec9a0e 100644
--- a/prql-compiler/src/snapshots/prql_compiler__parser__test__parse_into_parse_tree-2.snap
+++ b/prql-compiler/src/snapshots/prql_compiler__parser__test__parse_into_parse_tree-2.snap
@@ -18,7 +18,17 @@ expression: "parse_tree_of_str(\"select [a, b, c]\", Rule::func_call)?"
                     start: 0,
                     end: 6,
                 },
-                inner: [],
+                inner: [
+                    Pair {
+                        rule: ident_part_first,
+                        span: Span {
+                            str: "select",
+                            start: 0,
+                            end: 6,
+                        },
+                        inner: [],
+                    },
+                ],
             },
             Pair {
                 rule: expr,
@@ -115,7 +125,17 @@ expression: "parse_tree_of_str(\"select [a, b, c]\", Rule::func_call)?"
                                                                                                             start: 8,
                                                                                                             end: 9,
                                                                                                         },
-                                                                                                        inner: [],
+                                                                                                        inner: [
+                                                                                                            Pair {
+                                                                                                                rule: ident_part_first,
+                                                                                                                span: Span {
+                                                                                                                    str: "a",
+                                                                                                                    start: 8,
+                                                                                                                    end: 9,
+                                                                                                                },
+                                                                                                                inner: [],
+                                                                                                            },
+                                                                                                        ],
                                                                                                     },
                                                                                                 ],
                                                                                             },
@@ -174,7 +194,17 @@ expression: "parse_tree_of_str(\"select [a, b, c]\", Rule::func_call)?"
                                                                                                             start: 11,
                                                                                                             end: 12,
                                                                                                         },
-                                                                                                        inner: [],
+                                                                                                        inner: [
+                                                                                                            Pair {
+                                                                                                                rule: ident_part_first,
+                                                                                                                span: Span {
+                                                                                                                    str: "b",
+                                                                                                                    start: 11,
+                                                                                                                    end: 12,
+                                                                                                                },
+                                                                                                                inner: [],
+                                                                                                            },
+                                                                                                        ],
                                                                                                     },
                                                                                                 ],
                                                                                             },
@@ -233,7 +263,17 @@ expression: "parse_tree_of_str(\"select [a, b, c]\", Rule::func_call)?"
                                                                                                             start: 14,
                                                                                                             end: 15,
                                                                                                         },
-                                                                                                        inner: [],
+                                                                                                        inner: [
+                                                                                                            Pair {
+                                                                                                                rule: ident_part_first,
+                                                                                                                span: Span {
+                                                                                                                    str: "c",
+                                                                                                                    start: 14,
+                                                                                                                    end: 15,
+                                                                                                                },
+                                                                                                                inner: [],
+                                                                                                            },
+                                                                                                        ],
                                                                                                     },
                                                                                                 ],
                                                                                             },
diff --git a/prql-compiler/src/snapshots/prql_compiler__parser__test__parse_into_parse_tree-3.snap b/prql-compiler/src/snapshots/prql_compiler__parser__test__parse_into_parse_tree-3.snap
index 183a7049..06721489 100644
--- a/prql-compiler/src/snapshots/prql_compiler__parser__test__parse_into_parse_tree-3.snap
+++ b/prql-compiler/src/snapshots/prql_compiler__parser__test__parse_into_parse_tree-3.snap
@@ -1,6 +1,6 @@
 ---
 source: prql-compiler/src/parser.rs
-expression: "parse_tree_of_str(\"group [title, country] (\n                aggregate [sum salary]\n            )\",\n                  Rule::pipeline)?"
+expression: "parse_tree_of_str(\"group [title, country] (\n                aggregate [sum salary]\n            )\",\n        Rule::pipeline)?"
 ---
 [
     Pair {
@@ -26,7 +26,17 @@ expression: "parse_tree_of_str(\"group [title, country] (\n                aggre
                             start: 0,
                             end: 5,
                         },
-                        inner: [],
+                        inner: [
+                            Pair {
+                                rule: ident_part_first,
+                                span: Span {
+                                    str: "group",
+                                    start: 0,
+                                    end: 5,
+                                },
+                                inner: [],
+                            },
+                        ],
                     },
                     Pair {
                         rule: expr,
@@ -123,7 +133,17 @@ expression: "parse_tree_of_str(\"group [title, country] (\n                aggre
                                                                                                                     start: 7,
                                                                                                                     end: 12,
                                                                                                                 },
-                                                                                                                inner: [],
+                                                                                                                inner: [
+                                                                                                                    Pair {
+                                                                                                                        rule: ident_part_first,
+                                                                                                                        span: Span {
+                                                                                                                            str: "title",
+                                                                                                                            start: 7,
+                                                                                                                            end: 12,
+                                                                                                                        },
+                                                                                                                        inner: [],
+                                                                                                                    },
+                                                                                                                ],
                                                                                                             },
                                                                                                         ],
                                                                                                     },
@@ -182,7 +202,17 @@ expression: "parse_tree_of_str(\"group [title, country] (\n                aggre
                                                                                                                     start: 14,
                                                                                                                     end: 21,
                                                                                                                 },
-                                                                                                                inner: [],
+                                                                                                                inner: [
+                                                                                                                    Pair {
+                                                                                                                        rule: ident_part_first,
+                                                                                                                        span: Span {
+                                                                                                                            str: "country",
+                                                                                                                            start: 14,
+                                                                                                                            end: 21,
+                                                                                                                        },
+                                                                                                                        inner: [],
+                                                                                                                    },
+                                                                                                                ],
                                                                                                             },
                                                                                                         ],
                                                                                                     },
@@ -269,7 +299,17 @@ expression: "parse_tree_of_str(\"group [title, country] (\n                aggre
                                                                                     start: 41,
                                                                                     end: 50,
                                                                                 },
-                                                                                inner: [],
+                                                                                inner: [
+                                                                                    Pair {
+                                                                                        rule: ident_part_first,
+                                                                                        span: Span {
+                                                                                            str: "aggregate",
+                                                                                            start: 41,
+                                                                                            end: 50,
+                                                                                        },
+                                                                                        inner: [],
+                                                                                    },
+                                                                                ],
                                                                             },
                                                                             Pair {
                                                                                 rule: expr,
@@ -334,7 +374,17 @@ expression: "parse_tree_of_str(\"group [title, country] (\n                aggre
                                                                                                                                             start: 52,
                                                                                                                                             end: 55,
                                                                                                                                         },
-                                                                                                                                        inner: [],
+                                                                                                                                        inner: [
+                                                                                                                                            Pair {
+                                                                                                                                                rule: ident_part_first,
+                                                                                                                                                span: Span {
+                                                                                                                                                    str: "sum",
+                                                                                                                                                    start: 52,
+                                                                                                                                                    end: 55,
+                                                                                                                                                },
+                                                                                                                                                inner: [],
+                                                                                                                                            },
+                                                                                                                                        ],
                                                                                                                                     },
                                                                                                                                     Pair {
                                                                                                                                         rule: expr,
@@ -383,7 +433,17 @@ expression: "parse_tree_of_str(\"group [title, country] (\n                aggre
                                                                                                                                                                                     start: 56,
                                                                                                                                                                                     end: 62,
                                                                                                                                                                                 },
-                                                                                                                                                                                inner: [],
+                                                                                                                                                                                inner: [
+                                                                                                                                                                                    Pair {
+                                                                                                                                                                                        rule: ident_part_first,
+                                                                                                                                                                                        span: Span {
+                                                                                                                                                                                            str: "salary",
+                                                                                                                                                                                            start: 56,
+                                                                                                                                                                                            end: 62,
+                                                                                                                                                                                        },
+                                                                                                                                                                                        inner: [],
+                                                                                                                                                                                    },
+                                                                                                                                                                                ],
                                                                                                                                                                             },
                                                                                                                                                                         ],
                                                                                                                                                                     },
diff --git a/prql-compiler/src/snapshots/prql_compiler__parser__test__parse_into_parse_tree-4.snap b/prql-compiler/src/snapshots/prql_compiler__parser__test__parse_into_parse_tree-4.snap
index f1f6f541..d4c49617 100644
--- a/prql-compiler/src/snapshots/prql_compiler__parser__test__parse_into_parse_tree-4.snap
+++ b/prql-compiler/src/snapshots/prql_compiler__parser__test__parse_into_parse_tree-4.snap
@@ -26,7 +26,17 @@ expression: "parse_tree_of_str(r#\"    filter country == \"USA\"\"#, Rule::pipel
                             start: 4,
                             end: 10,
                         },
-                        inner: [],
+                        inner: [
+                            Pair {
+                                rule: ident_part_first,
+                                span: Span {
+                                    str: "filter",
+                                    start: 4,
+                                    end: 10,
+                                },
+                                inner: [],
+                            },
+                        ],
                     },
                     Pair {
                         rule: expr,
@@ -75,7 +85,17 @@ expression: "parse_tree_of_str(r#\"    filter country == \"USA\"\"#, Rule::pipel
                                                                     start: 11,
                                                                     end: 18,
                                                                 },
-                                                                inner: [],
+                                                                inner: [
+                                                                    Pair {
+                                                                        rule: ident_part_first,
+                                                                        span: Span {
+                                                                            str: "country",
+                                                                            start: 11,
+                                                                            end: 18,
+                                                                        },
+                                                                        inner: [],
+                                                                    },
+                                                                ],
                                                             },
                                                         ],
                                                     },
diff --git a/prql-compiler/src/snapshots/prql_compiler__parser__test__parse_into_parse_tree-5.snap b/prql-compiler/src/snapshots/prql_compiler__parser__test__parse_into_parse_tree-5.snap
index 02d7d3f1..a70c7dc5 100644
--- a/prql-compiler/src/snapshots/prql_compiler__parser__test__parse_into_parse_tree-5.snap
+++ b/prql-compiler/src/snapshots/prql_compiler__parser__test__parse_into_parse_tree-5.snap
@@ -58,7 +58,17 @@ expression: "parse_tree_of_str(\"[a, b, c,]\", Rule::list)?"
                                                             start: 1,
                                                             end: 2,
                                                         },
-                                                        inner: [],
+                                                        inner: [
+                                                            Pair {
+                                                                rule: ident_part_first,
+                                                                span: Span {
+                                                                    str: "a",
+                                                                    start: 1,
+                                                                    end: 2,
+                                                                },
+                                                                inner: [],
+                                                            },
+                                                        ],
                                                     },
                                                 ],
                                             },
@@ -117,7 +127,17 @@ expression: "parse_tree_of_str(\"[a, b, c,]\", Rule::list)?"
                                                             start: 4,
                                                             end: 5,
                                                         },
-                                                        inner: [],
+                                                        inner: [
+                                                            Pair {
+                                                                rule: ident_part_first,
+                                                                span: Span {
+                                                                    str: "b",
+                                                                    start: 4,
+                                                                    end: 5,
+                                                                },
+                                                                inner: [],
+                                                            },
+                                                        ],
                                                     },
                                                 ],
                                             },
@@ -176,7 +196,17 @@ expression: "parse_tree_of_str(\"[a, b, c,]\", Rule::list)?"
                                                             start: 7,
                                                             end: 8,
                                                         },
-                                                        inner: [],
+                                                        inner: [
+                                                            Pair {
+                                                                rule: ident_part_first,
+                                                                span: Span {
+                                                                    str: "c",
+                                                                    start: 7,
+                                                                    end: 8,
+                                                                },
+                                                                inner: [],
+                                                            },
+                                                        ],
                                                     },
                                                 ],
                                             },
diff --git a/prql-compiler/src/snapshots/prql_compiler__parser__test__parse_into_parse_tree-6.snap b/prql-compiler/src/snapshots/prql_compiler__parser__test__parse_into_parse_tree-6.snap
index 0bf58155..75149f86 100644
--- a/prql-compiler/src/snapshots/prql_compiler__parser__test__parse_into_parse_tree-6.snap
+++ b/prql-compiler/src/snapshots/prql_compiler__parser__test__parse_into_parse_tree-6.snap
@@ -1,6 +1,6 @@
 ---
 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)?"
+expression: "parse_tree_of_str(r#\"[\n  gross_salary = salary + payroll_tax,\n  gross_cost   = gross_salary + benefits_cost\n]\"#,\n        Rule::list)?"
 ---
 [
     Pair {
@@ -26,7 +26,17 @@ expression: "parse_tree_of_str(r#\"[\n  gross_salary = salary + payroll_tax,\n
                             start: 4,
                             end: 16,
                         },
-                        inner: [],
+                        inner: [
+                            Pair {
+                                rule: ident_part_first,
+                                span: Span {
+                                    str: "gross_salary",
+                                    start: 4,
+                                    end: 16,
+                                },
+                                inner: [],
+                            },
+                        ],
                     },
                     Pair {
                         rule: expr,
@@ -75,7 +85,17 @@ expression: "parse_tree_of_str(r#\"[\n  gross_salary = salary + payroll_tax,\n
                                                                     start: 19,
                                                                     end: 25,
                                                                 },
-                                                                inner: [],
+                                                                inner: [
+                                                                    Pair {
+                                                                        rule: ident_part_first,
+                                                                        span: Span {
+                                                                            str: "salary",
+                                                                            start: 19,
+                                                                            end: 25,
+                                                                        },
+                                                                        inner: [],
+                                                                    },
+                                                                ],
                                                             },
                                                         ],
                                                     },
@@ -111,7 +131,17 @@ expression: "parse_tree_of_str(r#\"[\n  gross_salary = salary + payroll_tax,\n
                                                                             start: 28,
                                                                             end: 39,
                                                                         },
-                                                                        inner: [],
+                                                                        inner: [
+                                                                            Pair {
+                                                                                rule: ident_part_first,
+                                                                                span: Span {
+                                                                                    str: "payroll_tax",
+                                                                                    start: 28,
+                                                                                    end: 39,
+                                                                                },
+                                                                                inner: [],
+                                                                            },
+                                                                        ],
                                                                     },
                                                                 ],
                                                             },
@@ -142,7 +172,17 @@ expression: "parse_tree_of_str(r#\"[\n  gross_salary = salary + payroll_tax,\n
                             start: 43,
                             end: 53,
                         },
-                        inner: [],
+                        inner: [
+                            Pair {
+                                rule: ident_part_first,
+                                span: Span {
+                                    str: "gross_cost",
+                                    start: 43,
+                                    end: 53,
+                                },
+                                inner: [],
+                            },
+                        ],
                     },
                     Pair {
                         rule: expr,
@@ -191,7 +231,17 @@ expression: "parse_tree_of_str(r#\"[\n  gross_salary = salary + payroll_tax,\n
                                                                     start: 58,
                                                                     end: 70,
                                                                 },
-                                                                inner: [],
+                                                                inner: [
+                                                                    Pair {
+                                                                        rule: ident_part_first,
+                                                                        span: Span {
+                                                                            str: "gross_salary",
+                                                                            start: 58,
+                                                                            end: 70,
+                                                                        },
+                                                                        inner: [],
+                                                                    },
+                                                                ],
                                                             },
                                                         ],
                                                     },
@@ -227,7 +277,17 @@ expression: "parse_tree_of_str(r#\"[\n  gross_salary = salary + payroll_tax,\n
                                                                             start: 73,
                                                                             end: 86,
                                                                         },
-                                                                        inner: [],
+                                                                        inner: [
+                                                                            Pair {
+                                                                                rule: ident_part_first,
+                                                                                span: Span {
+                                                                                    str: "benefits_cost",
+                                                                                    start: 73,
+                                                                                    end: 86,
+                                                                                },
+                                                                                inner: [],
+                                                                            },
+                                                                        ],
                                                                     },
                                                                 ],
                                                             },
diff --git a/prql-compiler/src/snapshots/prql_compiler__parser__test__parse_into_parse_tree-8.snap b/prql-compiler/src/snapshots/prql_compiler__parser__test__parse_into_parse_tree-8.snap
index 559198df..af71a35a 100644
--- a/prql-compiler/src/snapshots/prql_compiler__parser__test__parse_into_parse_tree-8.snap
+++ b/prql-compiler/src/snapshots/prql_compiler__parser__test__parse_into_parse_tree-8.snap
@@ -1,6 +1,6 @@
 ---
 source: prql-compiler/src/parser.rs
-expression: "parse_tree_of_str(\"join side:left country [id==employee_id]\",\n                  Rule::func_call)?"
+expression: "parse_tree_of_str(\"join side:left country [id==employee_id]\",\n        Rule::func_call)?"
 ---
 [
     Pair {
@@ -18,7 +18,17 @@ expression: "parse_tree_of_str(\"join side:left country [id==employee_id]\",\n
                     start: 0,
                     end: 4,
                 },
-                inner: [],
+                inner: [
+                    Pair {
+                        rule: ident_part_first,
+                        span: Span {
+                            str: "join",
+                            start: 0,
+                            end: 4,
+                        },
+                        inner: [],
+                    },
+                ],
             },
             Pair {
                 rule: named_arg,
@@ -35,7 +45,17 @@ expression: "parse_tree_of_str(\"join side:left country [id==employee_id]\",\n
                             start: 5,
                             end: 9,
                         },
-                        inner: [],
+                        inner: [
+                            Pair {
+                                rule: ident_part_first,
+                                span: Span {
+                                    str: "side",
+                                    start: 5,
+                                    end: 9,
+                                },
+                                inner: [],
+                            },
+                        ],
                     },
                     Pair {
                         rule: expr,
@@ -84,7 +104,17 @@ expression: "parse_tree_of_str(\"join side:left country [id==employee_id]\",\n
                                                                     start: 10,
                                                                     end: 14,
                                                                 },
-                                                                inner: [],
+                                                                inner: [
+                                                                    Pair {
+                                                                        rule: ident_part_first,
+                                                                        span: Span {
+                                                                            str: "left",
+                                                                            start: 10,
+                                                                            end: 14,
+                                                                        },
+                                                                        inner: [],
+                                                                    },
+                                                                ],
                                                             },
                                                         ],
                                                     },
@@ -145,7 +175,17 @@ expression: "parse_tree_of_str(\"join side:left country [id==employee_id]\",\n
                                                             start: 15,
                                                             end: 22,
                                                         },
-                                                        inner: [],
+                                                        inner: [
+                                                            Pair {
+                                                                rule: ident_part_first,
+                                                                span: Span {
+                                                                    str: "country",
+                                                                    start: 15,
+                                                                    end: 22,
+                                                                },
+                                                                inner: [],
+                                                            },
+                                                        ],
                                                     },
                                                 ],
                                             },
@@ -252,7 +292,17 @@ expression: "parse_tree_of_str(\"join side:left country [id==employee_id]\",\n
                                                                                                             start: 24,
                                                                                                             end: 26,
                                                                                                         },
-                                                                                                        inner: [],
+                                                                                                        inner: [
+                                                                                                            Pair {
+                                                                                                                rule: ident_part_first,
+                                                                                                                span: Span {
+                                                                                                                    str: "id",
+                                                                                                                    start: 24,
+                                                                                                                    end: 26,
+                                                                                                                },
+                                                                                                                inner: [],
+                                                                                                            },
+                                                                                                        ],
                                                                                                     },
                                                                                                 ],
                                                                                             },
@@ -290,7 +340,17 @@ expression: "parse_tree_of_str(\"join side:left country [id==employee_id]\",\n
                                                                                                             start: 28,
                                                                                                             end: 39,
                                                                                                         },
-                                                                                                        inner: [],
+                                                                                                        inner: [
+                                                                                                            Pair {
+                                                                                                                rule: ident_part_first,
+                                                                                                                span: Span {
+                                                                                                                    str: "employee_id",
+                                                                                                                    start: 28,
+                                                                                                                    end: 39,
+                                                                                                                },
+                                                                                                                inner: [],
+                                                                                                            },
+                                                                                                        ],
                                                                                                     },
                                                                                                 ],
                                                                                             },
diff --git a/prql-compiler/src/snapshots/prql_compiler__parser__test__parse_into_parse_tree.snap b/prql-compiler/src/snapshots/prql_compiler__parser__test__parse_into_parse_tree.snap
index 6ec8fdae..55b4746e 100644
--- a/prql-compiler/src/snapshots/prql_compiler__parser__test__parse_into_parse_tree.snap
+++ b/prql-compiler/src/snapshots/prql_compiler__parser__test__parse_into_parse_tree.snap
@@ -50,7 +50,17 @@ expression: "parse_tree_of_str(r#\"country == \"USA\"\"#, Rule::expr)?"
                                                     start: 0,
                                                     end: 7,
                                                 },
-                                                inner: [],
+                                                inner: [
+                                                    Pair {
+                                                        rule: ident_part_first,
+                                                        span: Span {
+                                                            str: "country",
+                                                            start: 0,
+                                                            end: 7,
+                                                        },
+                                                        inner: [],
+                                                    },
+                                                ],
                                             },
                                         ],
                                     },
diff --git a/prql-compiler/src/snapshots/prql_compiler__parser__test__parse_pipeline_parse_tree.snap b/prql-compiler/src/snapshots/prql_compiler__parser__test__parse_pipeline_parse_tree.snap
index 5b4702a4..581400f5 100644
--- a/prql-compiler/src/snapshots/prql_compiler__parser__test__parse_pipeline_parse_tree.snap
+++ b/prql-compiler/src/snapshots/prql_compiler__parser__test__parse_pipeline_parse_tree.snap
@@ -1,6 +1,6 @@
 ---
 source: prql-compiler/src/parser.rs
-expression: "parse_tree_of_str(&include_str!(\"../../book/tests/prql/examples/variables-0.prql\").trim().replace(\"\\r\\n\",\n                                                                                                  \"\\n\"),\n                  Rule::pipeline).unwrap()"
+expression: "parse_tree_of_str(&include_str!(\"../../book/tests/prql/examples/variables-0.prql\").trim().replace(\"\\r\\n\",\n                \"\\n\"), Rule::pipeline).unwrap()"
 ---
 [
     Pair {
@@ -26,7 +26,17 @@ expression: "parse_tree_of_str(&include_str!(\"../../book/tests/prql/examples/va
                             start: 0,
                             end: 4,
                         },
-                        inner: [],
+                        inner: [
+                            Pair {
+                                rule: ident_part_first,
+                                span: Span {
+                                    str: "from",
+                                    start: 0,
+                                    end: 4,
+                                },
+                                inner: [],
+                            },
+                        ],
                     },
                     Pair {
                         rule: expr,
@@ -75,7 +85,17 @@ expression: "parse_tree_of_str(&include_str!(\"../../book/tests/prql/examples/va
                                                                     start: 5,
                                                                     end: 14,
                                                                 },
-                                                                inner: [],
+                                                                inner: [
+                                                                    Pair {
+                                                                        rule: ident_part_first,
+                                                                        span: Span {
+                                                                            str: "employees",
+                                                                            start: 5,
+                                                                            end: 14,
+                                                                        },
+                                                                        inner: [],
+                                                                    },
+                                                                ],
                                                             },
                                                         ],
                                                     },
@@ -104,7 +124,17 @@ expression: "parse_tree_of_str(&include_str!(\"../../book/tests/prql/examples/va
                             start: 15,
                             end: 21,
                         },
-                        inner: [],
+                        inner: [
+                            Pair {
+                                rule: ident_part_first,
+                                span: Span {
+                                    str: "filter",
+                                    start: 15,
+                                    end: 21,
+                                },
+                                inner: [],
+                            },
+                        ],
                     },
                     Pair {
                         rule: expr,
@@ -153,7 +183,17 @@ expression: "parse_tree_of_str(&include_str!(\"../../book/tests/prql/examples/va
                                                                     start: 22,
                                                                     end: 29,
                                                                 },
-                                                                inner: [],
+                                                                inner: [
+                                                                    Pair {
+                                                                        rule: ident_part_first,
+                                                                        span: Span {
+                                                                            str: "country",
+                                                                            start: 22,
+                                                                            end: 29,
+                                                                        },
+                                                                        inner: [],
+                                                                    },
+                                                                ],
                                                             },
                                                         ],
                                                     },
@@ -230,7 +270,17 @@ expression: "parse_tree_of_str(&include_str!(\"../../book/tests/prql/examples/va
                             start: 105,
                             end: 111,
                         },
-                        inner: [],
+                        inner: [
+                            Pair {
+                                rule: ident_part_first,
+                                span: Span {
+                                    str: "derive",
+                                    start: 105,
+                                    end: 111,
+                                },
+                                inner: [],
+                            },
+                        ],
                     },
                     Pair {
                         rule: expr,
@@ -295,7 +345,17 @@ expression: "parse_tree_of_str(&include_str!(\"../../book/tests/prql/examples/va
                                                                                     start: 185,
                                                                                     end: 197,
                                                                                 },
-                                                                                inner: [],
+                                                                                inner: [
+                                                                                    Pair {
+                                                                                        rule: ident_part_first,
+                                                                                        span: Span {
+                                                                                            str: "gross_salary",
+                                                                                            start: 185,
+                                                                                            end: 197,
+                                                                                        },
+                                                                                        inner: [],
+                                                                                    },
+                                                                                ],
                                                                             },
                                                                             Pair {
                                                                                 rule: expr,
@@ -344,7 +404,17 @@ expression: "parse_tree_of_str(&include_str!(\"../../book/tests/prql/examples/va
                                                                                                                             start: 200,
                                                                                                                             end: 206,
                                                                                                                         },
-                                                                                                                        inner: [],
+                                                                                                                        inner: [
+                                                                                                                            Pair {
+                                                                                                                                rule: ident_part_first,
+                                                                                                                                span: Span {
+                                                                                                                                    str: "salary",
+                                                                                                                                    start: 200,
+                                                                                                                                    end: 206,
+                                                                                                                                },
+                                                                                                                                inner: [],
+                                                                                                                            },
+                                                                                                                        ],
                                                                                                                     },
                                                                                                                 ],
                                                                                                             },
@@ -380,7 +450,17 @@ expression: "parse_tree_of_str(&include_str!(\"../../book/tests/prql/examples/va
                                                                                                                                     start: 209,
                                                                                                                                     end: 220,
                                                                                                                                 },
-                                                                                                                                inner: [],
+                                                                                                                                inner: [
+                                                                                                                                    Pair {
+                                                                                                                                        rule: ident_part_first,
+                                                                                                                                        span: Span {
+                                                                                                                                            str: "payroll_tax",
+                                                                                                                                            start: 209,
+                                                                                                                                            end: 220,
+                                                                                                                                        },
+                                                                                                                                        inner: [],
+                                                                                                                                    },
+                                                                                                                                ],
                                                                                                                             },
                                                                                                                         ],
                                                                                                                     },
@@ -411,7 +491,17 @@ expression: "parse_tree_of_str(&include_str!(\"../../book/tests/prql/examples/va
                                                                                     start: 224,
                                                                                     end: 234,
                                                                                 },
-                                                                                inner: [],
+                                                                                inner: [
+                                                                                    Pair {
+                                                                                        rule: ident_part_first,
+                                                                                        span: Span {
+                                                                                            str: "gross_cost",
+                                                                                            start: 224,
+                                                                                            end: 234,
+                                                                                        },
+                                                                                        inner: [],
+                                                                                    },
+                                                                                ],
                                                                             },
                                                                             Pair {
                                                                                 rule: expr,
@@ -460,7 +550,17 @@ expression: "parse_tree_of_str(&include_str!(\"../../book/tests/prql/examples/va
                                                                                                                             start: 237,
                                                                                                                             end: 249,
                                                                                                                         },
-                                                                                                                        inner: [],
+                                                                                                                        inner: [
+                                                                                                                            Pair {
+                                                                                                                                rule: ident_part_first,
+                                                                                                                                span: Span {
+                                                                                                                                    str: "gross_salary",
+                                                                                                                                    start: 237,
+                                                                                                                                    end: 249,
+                                                                                                                                },
+                                                                                                                                inner: [],
+                                                                                                                            },
+                                                                                                                        ],
                                                                                                                     },
                                                                                                                 ],
                                                                                                             },
@@ -496,7 +596,17 @@ expression: "parse_tree_of_str(&include_str!(\"../../book/tests/prql/examples/va
                                                                                                                                     start: 252,
                                                                                                                                     end: 265,
                                                                                                                                 },
-                                                                                                                                inner: [],
+                                                                                                                                inner: [
+                                                                                                                                    Pair {
+                                                                                                                                        rule: ident_part_first,
+                                                                                                                                        span: Span {
+                                                                                                                                            str: "benefits_cost",
+                                                                                                                                            start: 252,
+                                                                                                                                            end: 265,
+                                                                                                                                        },
+                                                                                                                                        inner: [],
+                                                                                                                                    },
+                                                                                                                                ],
                                                                                                                             },
                                                                                                                         ],
                                                                                                                     },
@@ -541,7 +651,17 @@ expression: "parse_tree_of_str(&include_str!(\"../../book/tests/prql/examples/va
                             start: 306,
                             end: 312,
                         },
-                        inner: [],
+                        inner: [
+                            Pair {
+                                rule: ident_part_first,
+                                span: Span {
+                                    str: "filter",
+                                    start: 306,
+                                    end: 312,
+                                },
+                                inner: [],
+                            },
+                        ],
                     },
                     Pair {
                         rule: expr,
@@ -590,7 +710,17 @@ expression: "parse_tree_of_str(&include_str!(\"../../book/tests/prql/examples/va
                                                                     start: 313,
                                                                     end: 323,
                                                                 },
-                                                                inner: [],
+                                                                inner: [
+                                                                    Pair {
+                                                                        rule: ident_part_first,
+                                                                        span: Span {
+                                                                            str: "gross_cost",
+                                                                            start: 313,
+                                                                            end: 323,
+                                                                        },
+                                                                        inner: [],
+                                                                    },
+                                                                ],
                                                             },
                                                         ],
                                                     },
@@ -657,7 +787,17 @@ expression: "parse_tree_of_str(&include_str!(\"../../book/tests/prql/examples/va
                             start: 328,
                             end: 333,
                         },
-                        inner: [],
+                        inner: [
+                            Pair {
+                                rule: ident_part_first,
+                                span: Span {
+                                    str: "group",
+                                    start: 328,
+                                    end: 333,
+                                },
+                                inner: [],
+                            },
+                        ],
                     },
                     Pair {
                         rule: expr,
@@ -754,7 +894,17 @@ expression: "parse_tree_of_str(&include_str!(\"../../book/tests/prql/examples/va
                                                                                                                     start: 335,
                                                                                                                     end: 340,
                                                                                                                 },
-                                                                                                                inner: [],
+                                                                                                                inner: [
+                                                                                                                    Pair {
+                                                                                                                        rule: ident_part_first,
+                                                                                                                        span: Span {
+                                                                                                                            str: "title",
+                                                                                                                            start: 335,
+                                                                                                                            end: 340,
+                                                                                                                        },
+                                                                                                                        inner: [],
+                                                                                                                    },
+                                                                                                                ],
                                                                                                             },
                                                                                                         ],
                                                                                                     },
@@ -813,7 +963,17 @@ expression: "parse_tree_of_str(&include_str!(\"../../book/tests/prql/examples/va
                                                                                                                     start: 342,
                                                                                                                     end: 349,
                                                                                                                 },
-                                                                                                                inner: [],
+                                                                                                                inner: [
+                                                                                                                    Pair {
+                                                                                                                        rule: ident_part_first,
+                                                                                                                        span: Span {
+                                                                                                                            str: "country",
+                                                                                                                            start: 342,
+                                                                                                                            end: 349,
+                                                                                                                        },
+                                                                                                                        inner: [],
+                                                                                                                    },
+                                                                                                                ],
                                                                                                             },
                                                                                                         ],
                                                                                                     },
@@ -900,7 +1060,17 @@ expression: "parse_tree_of_str(&include_str!(\"../../book/tests/prql/examples/va
                                                                                     start: 414,
                                                                                     end: 423,
                                                                                 },
-                                                                                inner: [],
+                                                                                inner: [
+                                                                                    Pair {
+                                                                                        rule: ident_part_first,
+                                                                                        span: Span {
+                                                                                            str: "aggregate",
+                                                                                            start: 414,
+                                                                                            end: 423,
+                                                                                        },
+                                                                                        inner: [],
+                                                                                    },
+                                                                                ],
                                                                             },
                                                                             Pair {
                                                                                 rule: expr,
@@ -965,7 +1135,17 @@ expression: "parse_tree_of_str(&include_str!(\"../../book/tests/prql/examples/va
                                                                                                                                             start: 500,
                                                                                                                                             end: 507,
                                                                                                                                         },
-                                                                                                                                        inner: [],
+                                                                                                                                        inner: [
+                                                                                                                                            Pair {
+                                                                                                                                                rule: ident_part_first,
+                                                                                                                                                span: Span {
+                                                                                                                                                    str: "average",
+                                                                                                                                                    start: 500,
+                                                                                                                                                    end: 507,
+                                                                                                                                                },
+                                                                                                                                                inner: [],
+                                                                                                                                            },
+                                                                                                                                        ],
                                                                                                                                     },
                                                                                                                                     Pair {
                                                                                                                                         rule: expr,
@@ -1014,7 +1194,17 @@ expression: "parse_tree_of_str(&include_str!(\"../../book/tests/prql/examples/va
                                                                                                                                                                                     start: 508,
                                                                                                                                                                                     end: 514,
                                                                                                                                                                                 },
-                                                                                                                                                                                inner: [],
+                                                                                                                                                                                inner: [
+                                                                                                                                                                                    Pair {
+                                                                                                                                                                                        rule: ident_part_first,
+                                                                                                                                                                                        span: Span {
+                                                                                                                                                                                            str: "salary",
+                                                                                                                                                                                            start: 508,
+                                                                                                                                                                                            end: 514,
+                                                                                                                                                                                        },
+                                                                                                                                                                                        inner: [],
+                                                                                                                                                                                    },
+                                                                                                                                                                                ],
                                                                                                                                                                             },
                                                                                                                                                                         ],
                                                                                                                                                                     },
@@ -1043,7 +1233,17 @@ expression: "parse_tree_of_str(&include_str!(\"../../book/tests/prql/examples/va
                                                                                                                                             start: 520,
                                                                                                                                             end: 527,
                                                                                                                                         },
-                                                                                                                                        inner: [],
+                                                                                                                                        inner: [
+                                                                                                                                            Pair {
+                                                                                                                                                rule: ident_part_first,
+                                                                                                                                                span: Span {
+                                                                                                                                                    str: "average",
+                                                                                                                                                    start: 520,
+                                                                                                                                                    end: 527,
+                                                                                                                                                },
+                                                                                                                                                inner: [],
+                                                                                                                                            },
+                                                                                                                                        ],
                                                                                                                                     },
                                                                                                                                     Pair {
                                                                                                                                         rule: expr,
@@ -1092,7 +1292,17 @@ expression: "parse_tree_of_str(&include_str!(\"../../book/tests/prql/examples/va
                                                                                                                                                                                     start: 528,
                                                                                                                                                                                     end: 540,
                                                                                                                                                                                 },
-                                                                                                                                                                                inner: [],
+                                                                                                                                                                                inner: [
+                                                                                                                                                                                    Pair {
+                                                                                                                                                                                        rule: ident_part_first,
+                                                                                                                                                                                        span: Span {
+                                                                                                                                                                                            str: "gross_salary",
+                                                                                                                                                                                            start: 528,
+                                                                                                                                                                                            end: 540,
+                                                                                                                                                                                        },
+                                                                                                                                                                                        inner: [],
+                                                                                                                                                                                    },
+                                                                                                                                                                                ],
                                                                                                                                                                             },
                                                                                                                                                                         ],
                                                                                                                                                                     },
@@ -1121,7 +1331,17 @@ expression: "parse_tree_of_str(&include_str!(\"../../book/tests/prql/examples/va
                                                                                                                                             start: 546,
                                                                                                                                             end: 549,
                                                                                                                                         },
-                                                                                                                                        inner: [],
+                                                                                                                                        inner: [
+                                                                                                                                            Pair {
+                                                                                                                                                rule: ident_part_first,
+                                                                                                                                                span: Span {
+                                                                                                                                                    str: "sum",
+                                                                                                                                                    start: 546,
+                                                                                                                                                    end: 549,
+                                                                                                                                                },
+                                                                                                                                                inner: [],
+                                                                                                                                            },
+                                                                                                                                        ],
                                                                                                                                     },
                                                                                                                                     Pair {
                                                                                                                                         rule: expr,
@@ -1170,7 +1390,17 @@ expression: "parse_tree_of_str(&include_str!(\"../../book/tests/prql/examples/va
                                                                                                                                                                                     start: 550,
                                                                                                                                                                                     end: 556,
                                                                                                                                                                                 },
-                                                                                                                                                                                inner: [],
+                                                                                                                                                                                inner: [
+                                                                                                                                                                                    Pair {
+                                                                                                                                                                                        rule: ident_part_first,
+                                                                                                                                                                                        span: Span {
+                                                                                                                                                                                            str: "salary",
+                                                                                                                                                                                            start: 550,
+                                                                                                                                                                                            end: 556,
+                                                                                                                                                                                        },
+                                                                                                                                                                                        inner: [],
+                                                                                                                                                                                    },
+                                                                                                                                                                                ],
                                                                                                                                                                             },
                                                                                                                                                                         ],
                                                                                                                                                                     },
@@ -1199,7 +1429,17 @@ expression: "parse_tree_of_str(&include_str!(\"../../book/tests/prql/examples/va
                                                                                                                                             start: 562,
                                                                                                                                             end: 565,
                                                                                                                                         },
-                                                                                                                                        inner: [],
+                                                                                                                                        inner: [
+                                                                                                                                            Pair {
+                                                                                                                                                rule: ident_part_first,
+                                                                                                                                                span: Span {
+                                                                                                                                                    str: "sum",
+                                                                                                                                                    start: 562,
+                                                                                                                                                    end: 565,
+                                                                                                                                                },
+                                                                                                                                                inner: [],
+                                                                                                                                            },
+                                                                                                                                        ],
                                                                                                                                     },
                                                                                                                                     Pair {
                                                                                                                                         rule: expr,
@@ -1248,7 +1488,17 @@ expression: "parse_tree_of_str(&include_str!(\"../../book/tests/prql/examples/va
                                                                                                                                                                                     start: 566,
                                                                                                                                                                                     end: 578,
                                                                                                                                                                                 },
-                                                                                                                                                                                inner: [],
+                                                                                                                                                                                inner: [
+                                                                                                                                                                                    Pair {
+                                                                                                                                                                                        rule: ident_part_first,
+                                                                                                                                                                                        span: Span {
+                                                                                                                                                                                            str: "gross_salary",
+                                                                                                                                                                                            start: 566,
+                                                                                                                                                                                            end: 578,
+                                                                                                                                                                                        },
+                                                                                                                                                                                        inner: [],
+                                                                                                                                                                                    },
+                                                                                                                                                                                ],
                                                                                                                                                                             },
                                                                                                                                                                         ],
                                                                                                                                                                     },
@@ -1277,7 +1527,17 @@ expression: "parse_tree_of_str(&include_str!(\"../../book/tests/prql/examples/va
                                                                                                                                             start: 584,
                                                                                                                                             end: 591,
                                                                                                                                         },
-                                                                                                                                        inner: [],
+                                                                                                                                        inner: [
+                                                                                                                                            Pair {
+                                                                                                                                                rule: ident_part_first,
+                                                                                                                                                span: Span {
+                                                                                                                                                    str: "average",
+                                                                                                                                                    start: 584,
+                                                                                                                                                    end: 591,
+                                                                                                                                                },
+                                                                                                                                                inner: [],
+                                                                                                                                            },
+                                                                                                                                        ],
                                                                                                                                     },
                                                                                                                                     Pair {
                                                                                                                                         rule: expr,
@@ -1326,7 +1586,17 @@ expression: "parse_tree_of_str(&include_str!(\"../../book/tests/prql/examples/va
                                                                                                                                                                                     start: 592,
                                                                                                                                                                                     end: 602,
                                                                                                                                                                                 },
-                                                                                                                                                                                inner: [],
+                                                                                                                                                                                inner: [
+                                                                                                                                                                                    Pair {
+                                                                                                                                                                                        rule: ident_part_first,
+                                                                                                                                                                                        span: Span {
+                                                                                                                                                                                            str: "gross_cost",
+                                                                                                                                                                                            start: 592,
+                                                                                                                                                                                            end: 602,
+                                                                                                                                                                                        },
+                                                                                                                                                                                        inner: [],
+                                                                                                                                                                                    },
+                                                                                                                                                                                ],
                                                                                                                                                                             },
                                                                                                                                                                         ],
                                                                                                                                                                     },
@@ -1355,7 +1625,17 @@ expression: "parse_tree_of_str(&include_str!(\"../../book/tests/prql/examples/va
                                                                                                                                             start: 608,
                                                                                                                                             end: 622,
                                                                                                                                         },
-                                                                                                                                        inner: [],
+                                                                                                                                        inner: [
+                                                                                                                                            Pair {
+                                                                                                                                                rule: ident_part_first,
+                                                                                                                                                span: Span {
+                                                                                                                                                    str: "sum_gross_cost",
+                                                                                                                                                    start: 608,
+                                                                                                                                                    end: 622,
+                                                                                                                                                },
+                                                                                                                                                inner: [],
+                                                                                                                                            },
+                                                                                                                                        ],
                                                                                                                                     },
                                                                                                                                     Pair {
                                                                                                                                         rule: func_call,
@@ -1372,7 +1652,17 @@ expression: "parse_tree_of_str(&include_str!(\"../../book/tests/prql/examples/va
                                                                                                                                                     start: 625,
                                                                                                                                                     end: 628,
                                                                                                                                                 },
-                                                                                                                                                inner: [],
+                                                                                                                                                inner: [
+                                                                                                                                                    Pair {
+                                                                                                                                                        rule: ident_part_first,
+                                                                                                                                                        span: Span {
+                                                                                                                                                            str: "sum",
+                                                                                                                                                            start: 625,
+                                                                                                                                                            end: 628,
+                                                                                                                                                        },
+                                                                                                                                                        inner: [],
+                                                                                                                                                    },
+                                                                                                                                                ],
                                                                                                                                             },
                                                                                                                                             Pair {
                                                                                                                                                 rule: expr,
@@ -1421,7 +1711,17 @@ expression: "parse_tree_of_str(&include_str!(\"../../book/tests/prql/examples/va
                                                                                                                                                                                             start: 629,
                                                                                                                                                                                             end: 639,
                                                                                                                                                                                         },
-                                                                                                                                                                                        inner: [],
+                                                                                                                                                                                        inner: [
+                                                                                                                                                                                            Pair {
+                                                                                                                                                                                                rule: ident_part_first,
+                                                                                                                                                                                                span: Span {
+                                                                                                                                                                                                    str: "gross_cost",
+                                                                                                                                                                                                    start: 629,
+                                                                                                                                                                                                    end: 639,
+                                                                                                                                                                                                },
+                                                                                                                                                                                                inner: [],
+                                                                                                                                                                                            },
+                                                                                                                                                                                        ],
                                                                                                                                                                                     },
                                                                                                                                                                                 ],
                                                                                                                                                                             },
@@ -1452,7 +1752,17 @@ expression: "parse_tree_of_str(&include_str!(\"../../book/tests/prql/examples/va
                                                                                                                                             start: 645,
                                                                                                                                             end: 647,
                                                                                                                                         },
-                                                                                                                                        inner: [],
+                                                                                                                                        inner: [
+                                                                                                                                            Pair {
+                                                                                                                                                rule: ident_part_first,
+                                                                                                                                                span: Span {
+                                                                                                                                                    str: "ct",
+                                                                                                                                                    start: 645,
+                                                                                                                                                    end: 647,
+                                                                                                                                                },
+                                                                                                                                                inner: [],
+                                                                                                                                            },
+                                                                                                                                        ],
                                                                                                                                     },
                                                                                                                                     Pair {
                                                                                                                                         rule: expr,
@@ -1501,7 +1811,17 @@ expression: "parse_tree_of_str(&include_str!(\"../../book/tests/prql/examples/va
                                                                                                                                                                                     start: 650,
                                                                                                                                                                                     end: 655,
                                                                                                                                                                                 },
-                                                                                                                                                                                inner: [],
+                                                                                                                                                                                inner: [
+                                                                                                                                                                                    Pair {
+                                                                                                                                                                                        rule: ident_part_first,
+                                                                                                                                                                                        span: Span {
+                                                                                                                                                                                            str: "count",
+                                                                                                                                                                                            start: 650,
+                                                                                                                                                                                            end: 655,
+                                                                                                                                                                                        },
+                                                                                                                                                                                        inner: [],
+                                                                                                                                                                                    },
+                                                                                                                                                                                ],
                                                                                                                                                                             },
                                                                                                                                                                         ],
                                                                                                                                                                     },
@@ -1558,7 +1878,17 @@ expression: "parse_tree_of_str(&include_str!(\"../../book/tests/prql/examples/va
                             start: 663,
                             end: 667,
                         },
-                        inner: [],
+                        inner: [
+                            Pair {
+                                rule: ident_part_first,
+                                span: Span {
+                                    str: "sort",
+                                    start: 663,
+                                    end: 667,
+                                },
+                                inner: [],
+                            },
+                        ],
                     },
                     Pair {
                         rule: expr,
@@ -1607,7 +1937,17 @@ expression: "parse_tree_of_str(&include_str!(\"../../book/tests/prql/examples/va
                                                                     start: 668,
                                                                     end: 682,
                                                                 },
-                                                                inner: [],
+                                                                inner: [
+                                                                    Pair {
+                                                                        rule: ident_part_first,
+                                                                        span: Span {
+                                                                            str: "sum_gross_cost",
+                                                                            start: 668,
+                                                                            end: 682,
+                                                                        },
+                                                                        inner: [],
+                                                                    },
+                                                                ],
                                                             },
                                                         ],
                                                     },
@@ -1636,7 +1976,17 @@ expression: "parse_tree_of_str(&include_str!(\"../../book/tests/prql/examples/va
                             start: 683,
                             end: 689,
                         },
-                        inner: [],
+                        inner: [
+                            Pair {
+                                rule: ident_part_first,
+                                span: Span {
+                                    str: "filter",
+                                    start: 683,
+                                    end: 689,
+                                },
+                                inner: [],
+                            },
+                        ],
                     },
                     Pair {
                         rule: expr,
@@ -1685,7 +2035,17 @@ expression: "parse_tree_of_str(&include_str!(\"../../book/tests/prql/examples/va
                                                                     start: 690,
                                                                     end: 692,
                                                                 },
-                                                                inner: [],
+                                                                inner: [
+                                                                    Pair {
+                                                                        rule: ident_part_first,
+                                                                        span: Span {
+                                                                            str: "ct",
+                                                                            start: 690,
+                                                                            end: 692,
+                                                                        },
+                                                                        inner: [],
+                                                                    },
+                                                                ],
                                                             },
                                                         ],
                                                     },
@@ -1752,7 +2112,17 @@ expression: "parse_tree_of_str(&include_str!(\"../../book/tests/prql/examples/va
                             start: 699,
                             end: 703,
                         },
-                        inner: [],
+                        inner: [
+                            Pair {
+                                rule: ident_part_first,
+                                span: Span {
+                                    str: "take",
+                                    start: 699,
+                                    end: 703,
+                                },
+                                inner: [],
+                            },
+                        ],
                     },
                     Pair {
                         rule: expr,