Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions prqlc/prqlc/src/semantic/resolver/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,24 +154,29 @@ pub(super) mod test {

#[test]
fn test_functions_pipeline() {
assert_yaml_snapshot!(resolve_derive(
r#"
// Spans from `std.prql` carry source id 0 (`STD_LIB_SOURCE_ID`); user
// sources start at 1. Filtering them keeps this snapshot stable when the
// stdlib shifts, without hiding spans from the query under test.
insta::with_settings!({ filters => vec![(r"\b0:\d+-\d+", "[std]")] }, {
assert_yaml_snapshot!(resolve_derive(
r#"
from a
derive one = (foo | sum)
"#
)
.unwrap());
)
.unwrap());

assert_yaml_snapshot!(resolve_derive(
r#"
assert_yaml_snapshot!(resolve_derive(
r#"
let plus_one = x -> x + 1
let plus = x y -> x + y

from a
derive {b = (sum foo | plus_one | plus 2)}
"#
)
.unwrap());
)
.unwrap());
});
}
#[test]
fn test_named_args() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ expression: "resolve_derive(r#\"\n let plus_one = x -> x + 1\n
ty:
kind:
Array: ~
span: "0:1699-1701"
span: "[std]"
name: array
span: "1:120-127"
- Literal:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ expression: "resolve_derive(r#\"\n from a\n derive one = (
ty:
kind:
Array: ~
span: "0:1699-1701"
span: "[std]"
name: array
span: "1:52-55"
alias: one
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ TransformCall:
kind:
Tuple:
- Wildcard: ~
span: "0:1740-1744"
span: "[std]"
name: ~
span: "0:1739-1745"
span: "[std]"
name: relation
lineage:
columns:
Expand Down Expand Up @@ -44,7 +44,7 @@ TransformCall:
ty:
kind:
Array: ~
span: "0:1699-1701"
span: "[std]"
name: array
span: "1:73-87"
span: "1:73-87"
Expand Down
8 changes: 7 additions & 1 deletion prqlc/prqlc/src/semantic/resolver/transforms.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1471,7 +1471,13 @@ mod tests {
let (res, _) = ctx.find_main_rel(&[]).unwrap().clone();
let expr = res.clone().into_relation_var().unwrap();
let expr = super::super::test::erase_ids(*expr);
assert_yaml_snapshot!(expr);

// Spans from `std.prql` carry source id 0 (`STD_LIB_SOURCE_ID`); user
// sources start at 1. Filtering them keeps this snapshot stable when the
// stdlib shifts, without hiding spans from the query under test.
insta::with_settings!({ filters => vec![(r"\b0:\d+-\d+", "[std]")] }, {
assert_yaml_snapshot!(expr);
});
}

#[test]
Expand Down
5 changes: 4 additions & 1 deletion prqlc/prqlc/tests/integration/queries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,10 @@ mod debug_lineage {

let lineage = serde_yaml::to_string(&fc).unwrap();

with_settings!({ input_file => prql_path }, {
with_settings!({
input_file => prql_path,
filters => vec![(r"\b0:\d+-\d+", "[std]")],
}, {
assert_snapshot!(test_name, &lineage, &prql)
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ frames:
table:
- default_db
- _literal_16
- - 0:3522-3608
- - [std]
- columns:
- !Single
name:
Expand All @@ -43,7 +43,7 @@ frames:
table:
- default_db
- _literal_11
- - 0:3611-3665
- - [std]
- columns:
- !Single
name:
Expand Down Expand Up @@ -157,22 +157,22 @@ nodes:
- 11
- id: 55
kind: RqOperator
span: 0:3551-3607
span: [std]
targets:
- 48
- 50
parent: 57
- id: 57
kind: 'TransformCall: Join'
span: 0:3522-3608
span: [std]
children:
- 42
- 11
- 55
parent: 64
- id: 60
kind: Ident
span: 0:6512-6520
span: [std]
ident: !Ident
- this
- b
Expand All @@ -181,7 +181,7 @@ nodes:
- 11
- id: 64
kind: 'TransformCall: Filter'
span: 0:3611-3665
span: [std]
children:
- 57
- 4000000147
Expand All @@ -197,7 +197,7 @@ nodes:
parent: 66
- id: 66
kind: Tuple
span: 0:3675-3678
span: [std]
children:
- 65
parent: 67
Expand Down Expand Up @@ -226,14 +226,14 @@ nodes:
- 68
- id: 4000000147
kind: RqOperator
span: 0:3619-3664
span: [std]
targets:
- 60
- 4000000149
parent: 64
- id: 4000000149
kind: Literal
span: 0:6524-6528
span: [std]
ast:
name: Project
stmts:
Expand Down
Loading