Skip to content

Commit

Permalink
Fix some more SQL set op + PartiQL bag op tests (#121)
Browse files Browse the repository at this point in the history
  • Loading branch information
alancai98 authored Aug 21, 2024
1 parent 9aa7694 commit 87809f9
Show file tree
Hide file tree
Showing 3 changed files with 360 additions and 47 deletions.
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
{
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",
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

0 comments on commit 87809f9

Please sign in to comment.