Skip to content

Commit

Permalink
Merge pull request #123 from partiql/main-fix-from-unpivot-coercion
Browse files Browse the repository at this point in the history
Fixes FROM/UNPIVOT test cases
  • Loading branch information
johnedquinn authored Aug 27, 2024
2 parents 87809f9 + a5abbef commit 6665b2e
Show file tree
Hide file tree
Showing 10 changed files with 451 additions and 295 deletions.
16 changes: 11 additions & 5 deletions partiql-tests-data/eval-equiv/spec-tests.ion
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,17 @@
]
}
},
assert: {
evalMode: [EvalModeCoerce, EvalModeError],
result: EvaluationSuccess,
output: $bag::[1, 2]
}
assert: [
{
evalMode: EvalModeCoerce,
result: EvaluationSuccess,
output: $bag::[1, 2]
},
{
evalMode: EvalModeError,
result: EvaluationFail,
}
]
},
]
'section-5'::[
Expand Down
98 changes: 61 additions & 37 deletions partiql-tests-data/eval/misc.ion
Original file line number Diff line number Diff line change
Expand Up @@ -95,17 +95,23 @@ uncategorized::[
{
name:"variableShadow", // Note that i, f, d, and s are defined in the global environment
statement:"SELECT f, d, s FROM i AS f, f AS d, @f AS s WHERE f = 1 AND d = 2e0 and s = 1",
assert:{
evalMode:[EvalModeCoerce, EvalModeError],
result:EvaluationSuccess,
output:$bag::[
{
f:1,
d:2e0,
s:1
}
]
}
assert:[
{
evalMode: EvalModeCoerce,
result: EvaluationSuccess,
output: $bag::[
{
f: 1,
d: 2e0,
s: 1
}
]
},
{
evalMode: EvalModeError,
result: EvaluationFail
}
]
},
{
name:"selectValueStructConstructorWithMissing",
Expand All @@ -132,15 +138,21 @@ uncategorized::[
{
name:"selectIndexStruct",
statement:"SELECT VALUE x[0] FROM (SELECT s.id FROM stores AS s) AS x",
assert:{
evalMode:[EvalModeCoerce, EvalModeError],
result:EvaluationSuccess,
output:$bag::[
"5",
"6",
"7"
]
}
assert:[
{
evalMode:EvalModeCoerce,
result:EvaluationSuccess,
output:$bag::[
$missing::null,
$missing::null,
$missing::null
]
},
{
evalMode: EvalModeError,
result: EvaluationFail
}
]
},
{
name:"selectStarSingleSource",
Expand Down Expand Up @@ -212,27 +224,39 @@ uncategorized::[
{
name:"emptySymbol",
statement:"SELECT \"\" FROM `{'': 1}`",
assert:{
evalMode:[EvalModeCoerce, EvalModeError],
result:EvaluationSuccess,
output:$bag::[
{
assert:[
{
evalMode:EvalModeCoerce,
result:EvaluationSuccess,
output:$bag::[
{
'':1
}
]
}
}
]
},
{
evalMode: EvalModeError,
result: EvaluationFail
}
]
},
{
name:"emptySymbolInGlobals",
statement:"SELECT * FROM \"\"",
assert:{
evalMode:[EvalModeCoerce, EvalModeError],
result:EvaluationSuccess,
output:$bag::[
{
_1:1
}
]
}
assert:[
{
evalMode:EvalModeCoerce,
result:EvaluationSuccess,
output:$bag::[
{
_1:1
}
]
},
{
evalMode: EvalModeError,
result: EvaluationFail
}
]
}
]
32 changes: 19 additions & 13 deletions partiql-tests-data/eval/primitives/date-time.ion
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,26 @@ regression::[
{
name:"dateTimePartsAsVariableNames",
statement:"SELECT VALUE [year, month, day, hour, minute, second] FROM 1968 AS year, 4 AS month, 3 as day, 12 as hour, 31 as minute, 59 as second",
assert:{
evalMode:[EvalModeCoerce, EvalModeError],
result:EvaluationSuccess,
output:$bag::[
[
1968,
4,
3,
12,
31,
59
assert:[
{
evalMode:EvalModeCoerce,
result:EvaluationSuccess,
output:$bag::[
[
1968,
4,
3,
12,
31,
59
]
]
]
}
},
{
evalMode: EvalModeError,
result: EvaluationFail,
},
]
},
{
name:"dateTimePartsAsStructFieldNames",
Expand Down
57 changes: 33 additions & 24 deletions partiql-tests-data/eval/primitives/path.ion
Original file line number Diff line number Diff line change
Expand Up @@ -550,14 +550,17 @@ pathUnpivotMissing::[
{
name: "unpivotMissing",
statement: "SELECT * FROM UNPIVOT MISSING",
assert: {
evalMode: [
EvalModeCoerce,
EvalModeError
],
result: EvaluationSuccess,
output: $bag::[]
}
assert: [
{
evalMode: EvalModeCoerce,
result: EvaluationSuccess,
output: $bag::[]
},
{
evalMode: EvalModeError,
result: EvaluationFail,
}
]
},
{
name: "unpivotEmptyStruct",
Expand Down Expand Up @@ -586,26 +589,32 @@ pathUnpivotMissing::[
{
name: "unpivotMissingWithAsAndAt",
statement: "SELECT unnestIndex, unnestValue FROM UNPIVOT MISSING AS unnestValue AT unnestIndex",
assert: {
evalMode: [
EvalModeCoerce,
EvalModeError
],
result: EvaluationSuccess,
output: $bag::[]
}
assert: [
{
evalMode: EvalModeCoerce,
result: EvaluationSuccess,
output: $bag::[]
},
{
evalMode: EvalModeError,
result: EvaluationFail,
}
]
},
{
name: "unpivotMissingCrossJoinWithAsAndAt",
statement: "SELECT unnestIndex, unnestValue FROM MISSING, UNPIVOT MISSING AS unnestValue AT unnestIndex",
assert: {
evalMode: [
EvalModeCoerce,
EvalModeError
],
result: EvaluationSuccess,
output: $bag::[]
}
assert: [
{
evalMode: EvalModeCoerce,
result: EvaluationSuccess,
output: $bag::[]
},
{
evalMode: EvalModeError,
result: EvaluationFail,
}
]
},
{
name: "pathUnpivotEmptyStruct1",
Expand Down
82 changes: 46 additions & 36 deletions partiql-tests-data/eval/primitives/symbol.ion
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,44 @@
{
name:"Empty Symbol in table",
statement:"SELECT \"\" FROM `{'': 1}`",
assert:{
result:EvaluationSuccess,
evalMode:[
EvalModeCoerce,
EvalModeError
],
output:$bag::[
{
'':1
}
]
}
assert: [
{
result: EvaluationSuccess,
evalMode: EvalModeCoerce,
output: $bag::[
{
'': 1
}
]
},
{
evalMode: EvalModeError,
result: EvaluationFail
}
]
},
{
name:"Empty Symbol in globals",
statement:"SELECT * FROM \"\"",
env:{
'':1
},
assert:{
result:EvaluationSuccess,
evalMode:[
EvalModeCoerce,
EvalModeError
],
output:$bag::[
{
_1:1
}
]
}
assert:[

{
result: EvaluationSuccess,
evalMode: EvalModeCoerce,
output: $bag::[
{
_1: 1
}
]
},
{
evalMode: EvalModeError,
result: EvaluationFail
}
]
},
{
name:"Empty Symbol in alias",
Expand All @@ -42,17 +49,20 @@
v:1
}
},
assert:{
result:EvaluationSuccess,
evalMode:[
EvalModeCoerce,
EvalModeError
],
output:$bag::[
{
'':1
}
]
}
assert: [
{
result: EvaluationSuccess,
evalMode: EvalModeCoerce,
output: $bag::[
{
'': 1
}
]
},
{
evalMode: EvalModeError,
result: EvaluationFail
}
]
}
]
Loading

0 comments on commit 6665b2e

Please sign in to comment.