Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add impossible filter and dominated filter tests #429

Merged
merged 10 commits into from
Aug 4, 2023
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),
},
))
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),
},
)
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),
},
))
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: [],
)
Loading