support value-wise query result
xxchan opened this issue · 3 comments
xxchan commented
https://duckdb.org/dev/sqllogictest/result_verification#row-wise-vs-value-wise-result-ordering
# row-wise
query II
SELECT 42, 84 UNION ALL SELECT 10, 20;
----
42 84
10 20
# value-wise
query II
SELECT 42, 84 UNION ALL SELECT 10, 20;
----
42
84
10
20
xxchan commented
sqlite only supports value-wise.
cockroach only supports row-wise, but will use value-wise when option -bigtest
is used (i.e., when testing against sqlite's test cases).
tv42 commented
I can work around this with tester.with_validator(sql_result_validator)
and something like this. I ripped out the whitespace trimming to keep the code simple, the sqlite tests I was playing with don't have any whitespace ambiquity:
fn sql_result_validator(actual: &[Vec<String>], expected: &[String]) -> bool {
let expected = expected
.iter()
.map(|s| s.split_ascii_whitespace().collect::<Vec<_>>())
.collect::<Vec<_>>();
if let Some(first_actual) = actual.first() {
if expected.iter().all(|v| v.len() == 1) {
// SQLite "value-wise" compatibility.
// Flatten and re-chunk based on column width in `actual`.
let expected = expected.into_iter().flatten().collect::<Vec<_>>();
let expected = expected.chunks(first_actual.len()).collect::<Vec<_>>();
return expected == actual;
}
}
actual == expected
}