-
-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add impossible filter and dominated filter tests (#429)
* add test for impossible filter * add overrode filter test * Update trustfall_core/test_data/tests/valid_queries/fold_count_filter_with_overrode_filter.graphql.ron Co-authored-by: Predrag Gruevski <2348618+obi1kenobi@users.noreply.github.com> * Update trustfall_core/test_data/tests/valid_queries/fold_count_filter_with_overrode_filter.graphql.ron Co-authored-by: Predrag Gruevski <2348618+obi1kenobi@users.noreply.github.com> * rename > dominated filter test * add < dominated filter test * fix dominated by lt test * make _gt test has results * correct test again to agree with comment * correct lt test to match what comment says about it --------- Co-authored-by: Predrag Gruevski <2348618+obi1kenobi@users.noreply.github.com>
- Loading branch information
1 parent
c63d358
commit fbcb02a
Showing
15 changed files
with
1,267 additions
and
0 deletions.
There are no files selected for viewing
88 changes: 88 additions & 0 deletions
88
...st_data/tests/valid_queries/fold_count_filter_with_dominated_filter_gt.graphql-parsed.ron
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
Ok(TestParsedGraphQLQuery( | ||
schema_name: "numbers", | ||
query: Query( | ||
root_connection: FieldConnection( | ||
position: Pos( | ||
line: 3, | ||
column: 5, | ||
), | ||
name: "Number", | ||
arguments: { | ||
"max": Int64(30), | ||
"min": Int64(30), | ||
}, | ||
), | ||
root_field: FieldNode( | ||
position: Pos( | ||
line: 3, | ||
column: 5, | ||
), | ||
name: "Number", | ||
coerced_to: Some("Composite"), | ||
connections: [ | ||
(FieldConnection( | ||
position: Pos( | ||
line: 5, | ||
column: 13, | ||
), | ||
name: "value", | ||
), FieldNode( | ||
position: Pos( | ||
line: 5, | ||
column: 13, | ||
), | ||
name: "value", | ||
output: [ | ||
OutputDirective(), | ||
], | ||
)), | ||
(FieldConnection( | ||
position: Pos( | ||
line: 7, | ||
column: 13, | ||
), | ||
name: "primeFactor", | ||
fold: Some(FoldGroup( | ||
fold: FoldDirective(), | ||
transform: Some(TransformGroup( | ||
transform: TransformDirective( | ||
kind: Count, | ||
), | ||
filter: [ | ||
FilterDirective( | ||
operation: GreaterThan((), VariableRef("two")), | ||
), | ||
FilterDirective( | ||
operation: GreaterThan((), VariableRef("three")), | ||
), | ||
], | ||
)), | ||
)), | ||
), FieldNode( | ||
position: Pos( | ||
line: 7, | ||
column: 13, | ||
), | ||
name: "primeFactor", | ||
transform_group: Some(TransformGroup( | ||
transform: TransformDirective( | ||
kind: Count, | ||
), | ||
filter: [ | ||
FilterDirective( | ||
operation: GreaterThan((), VariableRef("two")), | ||
), | ||
FilterDirective( | ||
operation: GreaterThan((), VariableRef("three")), | ||
), | ||
], | ||
)), | ||
)), | ||
], | ||
), | ||
), | ||
arguments: { | ||
"three": Uint64(3), | ||
"two": Uint64(2), | ||
}, | ||
)) |
28 changes: 28 additions & 0 deletions
28
...core/test_data/tests/valid_queries/fold_count_filter_with_dominated_filter_gt.graphql.ron
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
TestGraphQLQuery ( | ||
// Ensure that we properly handle two of the same type of filters | ||
// but one of the filters dominates the other. In this case filtering | ||
// by greater than two is dominated by filtering for greater than three. | ||
// | ||
// This test guards against an accidental min/max mixup in the implementation | ||
// of the optimization that allows us to stop expanding folds early. | ||
// We should only stop when the dominating filter is satisfied, | ||
// not when the dominated filter is satisfied. If such a bug were to happen, | ||
// this query would return `{ "value": 30 }` instead of having no results. | ||
schema_name: "numbers", | ||
query: r#" | ||
{ | ||
Number(min: 30, max: 30) { | ||
... on Composite { | ||
value @output | ||
primeFactor @fold @transform(op: "count") | ||
@filter(op: ">", value: ["$two"]) | ||
@filter(op: ">", value: ["$three"]) | ||
} | ||
} | ||
}"#, | ||
arguments: { | ||
"two": Uint64(2), | ||
"three": Uint64(3), | ||
}, | ||
) |
64 changes: 64 additions & 0 deletions
64
...fall_core/test_data/tests/valid_queries/fold_count_filter_with_dominated_filter_gt.ir.ron
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
Ok(TestIRQuery( | ||
schema_name: "numbers", | ||
ir_query: IRQuery( | ||
root_name: "Number", | ||
root_parameters: EdgeParameters( | ||
contents: { | ||
"max": Int64(30), | ||
"min": Int64(30), | ||
}, | ||
), | ||
root_component: IRQueryComponent( | ||
root: Vid(1), | ||
vertices: { | ||
Vid(1): IRVertex( | ||
vid: Vid(1), | ||
type_name: "Composite", | ||
coerced_from_type: Some("Number"), | ||
), | ||
}, | ||
folds: { | ||
Eid(1): IRFold( | ||
eid: Eid(1), | ||
from_vid: Vid(1), | ||
to_vid: Vid(2), | ||
edge_name: "primeFactor", | ||
component: IRQueryComponent( | ||
root: Vid(2), | ||
vertices: { | ||
Vid(2): IRVertex( | ||
vid: Vid(2), | ||
type_name: "Prime", | ||
), | ||
}, | ||
), | ||
post_filters: [ | ||
GreaterThan(Count, Variable(VariableRef( | ||
variable_name: "two", | ||
variable_type: "Int!", | ||
))), | ||
GreaterThan(Count, Variable(VariableRef( | ||
variable_name: "three", | ||
variable_type: "Int!", | ||
))), | ||
], | ||
), | ||
}, | ||
outputs: { | ||
"value": ContextField( | ||
vertex_id: Vid(1), | ||
field_name: "value", | ||
field_type: "Int", | ||
), | ||
}, | ||
), | ||
variables: { | ||
"three": "Int!", | ||
"two": "Int!", | ||
}, | ||
), | ||
arguments: { | ||
"three": Uint64(3), | ||
"two": Uint64(2), | ||
}, | ||
)) |
11 changes: 11 additions & 0 deletions
11
..._core/test_data/tests/valid_queries/fold_count_filter_with_dominated_filter_gt.output.ron
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
TestInterpreterOutputData( | ||
schema_name: "numbers", | ||
outputs: { | ||
"value": Output( | ||
name: "value", | ||
value_type: "Int", | ||
vid: Vid(1), | ||
), | ||
}, | ||
results: [], | ||
) |
Oops, something went wrong.