Skip to content
New issue

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

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

Already on GitHub? # to your account

support value-wise query result #108

Open
xxchan opened this issue Dec 5, 2022 · 3 comments · May be fixed by #123
Open

support value-wise query result #108

xxchan opened this issue Dec 5, 2022 · 3 comments · May be fixed by #123

Comments

@xxchan
Copy link
Member

xxchan commented Dec 5, 2022

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
Copy link
Member Author

xxchan commented Dec 5, 2022

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).

@xxchan xxchan linked a pull request Dec 8, 2022 that will close this issue
2 tasks
@tv42
Copy link

tv42 commented Dec 11, 2023

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
}

@xxchan
Copy link
Member Author

xxchan commented Dec 12, 2023

FYI, #123 contains support for value sort. I forget whether it's finished though.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants