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

Fix some more SQL set op + PartiQL bag op tests #121

Merged
merged 3 commits into from
Aug 21, 2024
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
247 changes: 222 additions & 25 deletions partiql-tests-data/eval/primitives/operators/bag-operators.ion
Original file line number Diff line number Diff line change
Expand Up @@ -143,56 +143,205 @@ bagOperators::[
]
}
},
// outer union coercion
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests from L146-346 do the following

  • For strict mode, give an error when coercing a non-collection
  • Adds INTERSECT and EXCEPT versions of the existing OUTER UNION tests

{
name:"outerUnionCoerceScalar",
statement:"1 OUTER UNION 2",
assert:{
evalMode:[EvalModeCoerce, EvalModeError],
result:EvaluationSuccess,
output:$bag::[
1,
2
]
}
assert:[
{
evalMode:EvalModeCoerce,
result:EvaluationSuccess,
output:$bag::[
1,
2
]
},
{
evalMode:EvalModeError,
result:EvaluationFail
},
]
},
{
name:"outerUnionCoerceStruct",
statement:"{'a': 1} OUTER UNION {'b': 2}",
assert:[
{
evalMode:EvalModeCoerce,
result:EvaluationSuccess,
output:$bag::[
{
a:1
},
{
b:2
}
]
},
{
evalMode:EvalModeError,
result:EvaluationFail
},
]
},
{
name:"outerUnionCoerceNullMissing",
statement:"NULL OUTER UNION MISSING",
assert:[
{
evalMode:EvalModeCoerce,
result:EvaluationSuccess,
output:$bag::[
null,
]
},
{
evalMode: EvalModeError,
result:EvaluationFail
},
]
},
{
name:"outerUnionCoerceList",
statement:"[ 1, 1, 1 ] OUTER UNION ALL [ 1, 2 ]",
assert:{
evalMode:[EvalModeCoerce, EvalModeError],
result:EvaluationSuccess,
output:$bag::[
{
a:1
},
{
b:2
}
1,
1,
1,
1,
2
]
}
},
// outer intersect coercion
{
name:"outerUnionCoerceNullMissing",
statement:"NULL OUTER UNION MISSING",
name:"outerIntersectCoerceScalar",
statement:"1 OUTER INTERSECT 1",
assert:[
{
evalMode:EvalModeCoerce,
result:EvaluationSuccess,
output:$bag::[
1
]
},
{
evalMode:EvalModeError,
result:EvaluationFail
},
]
},
{
name:"outerIntersectCoerceStruct",
statement:"{'a': 1} OUTER INTERSECT {'a': 1}",
assert:[
{
evalMode:EvalModeCoerce,
result:EvaluationSuccess,
output:$bag::[
{
a:1
}
]
},
{
evalMode:EvalModeError,
result:EvaluationFail
},
]
},
{
name:"outerIntersectCoerceNullMissing",
statement:"NULL OUTER INTERSECT MISSING",
assert:[
{
evalMode:EvalModeCoerce,
result:EvaluationSuccess,
output:$bag::[
null
]
},
{
evalMode: EvalModeError,
result:EvaluationFail
},
]
},
{
name:"outerIntersectCoerceList",
statement:"[ 1, 1, 1 ] OUTER INTERSECT ALL [ 1, 2 ]",
assert:{
evalMode:[EvalModeCoerce, EvalModeError],
result:EvaluationSuccess,
output:$bag::[
1
]
}
},
// outer except coercion
{
name:"outerUnionCoerceList",
statement:"[ 1, 1, 1 ] OUTER UNION ALL [ 1, 2 ]",
name:"outerExceptCoerceScalar",
statement:"1 OUTER EXCEPT 2",
assert:[
{
evalMode:EvalModeCoerce,
result:EvaluationSuccess,
output:$bag::[
1
]
},
{
evalMode:EvalModeError,
result:EvaluationFail
},
]
},
{
name:"outerExceptCoerceStruct",
statement:"{'a': 1} OUTER EXCEPT {'b': 2}",
assert:[
{
evalMode:EvalModeCoerce,
result:EvaluationSuccess,
output:$bag::[
{
a:1
}
]
},
{
evalMode:EvalModeError,
result:EvaluationFail
},
]
},
{
name:"outerExceptCoerceNullMissing",
statement:"NULL OUTER EXCEPT MISSING",
assert:[
{
evalMode:EvalModeCoerce,
result:EvaluationSuccess,
output:$bag::[]
},
{
evalMode: EvalModeError,
result:EvaluationFail
},
]
},
{
name:"outerExceptCoerceList",
statement:"[ 1, 1, 1 ] OUTER EXCEPT ALL [ 1, 2 ]",
assert:{
evalMode:[EvalModeCoerce, EvalModeError],
result:EvaluationSuccess,
output:$bag::[
1,
1,
1,
1,
2
1
]
}
},
Expand Down Expand Up @@ -244,7 +393,55 @@ bagOperators::[
}
},
{
name:"OUTER UNION with ORDER BY LIMIT on children and bag op",
name:"SQL UNION with ORDER BY LIMIT on children and set op",
statement:"(SELECT a, tbl FROM t1 ORDER BY a LIMIT 2) UNION ALL (SELECT a, tbl FROM t2 ORDER BY a LIMIT 2) ORDER BY a LIMIT 2",
alancai98 marked this conversation as resolved.
Show resolved Hide resolved
assert:{
evalMode:[EvalModeCoerce, EvalModeError],
result:EvaluationSuccess,
output:[
{
a: 1,
tbl: 1,
},
{
a: 2,
tbl: 1
}
]
}
},
{
name:"SQL INTERSECT with ORDER BY LIMIT on children and set op",
statement:"(SELECT a FROM t1 ORDER BY a LIMIT 4) INTERSECT ALL (SELECT a FROM t2 ORDER BY a LIMIT 4) ORDER BY a LIMIT 2",
assert:{
evalMode:[EvalModeCoerce, EvalModeError],
result:EvaluationSuccess,
output:[
{
a: 2,
},
{
a: 3,
}
]
}
},
{
name:"SQL EXCEPT with ORDER BY LIMIT on children and set op",
statement:"(SELECT a FROM t1 ORDER BY a LIMIT 2) EXCEPT ALL (SELECT a FROM t2 ORDER BY a LIMIT 2) ORDER BY a LIMIT 2",
assert:{
evalMode:[EvalModeCoerce, EvalModeError],
result:EvaluationSuccess,
output:[
{
a: 1,
},
]
}
},
// following tests are equivalent to above but use the PartiQL outer bag op
{
name:"PartiQL OUTER UNION with ORDER BY LIMIT on children and bag op",
statement:"(SELECT a, tbl FROM t1 ORDER BY a LIMIT 2) OUTER UNION ALL (SELECT a, tbl FROM t2 ORDER BY a LIMIT 2) ORDER BY a LIMIT 2",
assert:{
evalMode:[EvalModeCoerce, EvalModeError],
Expand All @@ -262,7 +459,7 @@ bagOperators::[
}
},
{
name:"OUTER INTERSECT with ORDER BY LIMIT on children and bag op",
name:"PartiQL OUTER INTERSECT with ORDER BY LIMIT on children and bag op",
statement:"(SELECT a FROM t1 ORDER BY a LIMIT 4) OUTER INTERSECT ALL (SELECT a FROM t2 ORDER BY a LIMIT 4) ORDER BY a LIMIT 2",
assert:{
evalMode:[EvalModeCoerce, EvalModeError],
Expand All @@ -278,7 +475,7 @@ bagOperators::[
}
},
{
name:"OUTER EXCEPT with ORDER BY LIMIT on children and bag op",
name:"PartiQL OUTER EXCEPT with ORDER BY LIMIT on children and bag op",
statement:"(SELECT a FROM t1 ORDER BY a LIMIT 2) OUTER EXCEPT ALL (SELECT a FROM t2 ORDER BY a LIMIT 2) ORDER BY a LIMIT 2",
assert:{
evalMode:[EvalModeCoerce, EvalModeError],
Expand Down
24 changes: 16 additions & 8 deletions partiql-tests-data/eval/rfc/0007.ion
Original file line number Diff line number Diff line change
Expand Up @@ -174,14 +174,22 @@ bag::[
{
name: "Example 6 — Value Coercion; Coercion of single value",
statement: '''SELECT * FROM << 1 >> OUTER UNION 'A' ''',
assert: {
evalMode: [EvalModeCoerce, EvalModeError],
result: EvaluationSuccess,
output: $bag::[
{ "_1": 1 },
"A",
]
}
assert: [
{
evalMode: EvalModeCoerce,
result: EvaluationSuccess,
output: $bag::[
{
"_1": 1
},
"A",
]
},
{
evalMode: EvalModeError,
result: EvaluationFail,
},
]
},
{
name: "Example 6 — Value Coercion",
Expand Down
Loading
Loading