mirror of
https://github.com/cldellow/sqlite-parquet-vtable.git
synced 2025-02-26 06:39:45 +00:00

`./make-linux` clones and builds: - arrow - brotli - lz4 - parquet - snappy - zlib - zstd - this project as a statically linked binary. Two Boost libs are still pulled in as shared libs, should probably fix that, too, for ultimate portability.
72 lines
2.3 KiB
Bash
Executable File
72 lines
2.3 KiB
Bash
Executable File
#!/bin/bash
|
|
set -euo pipefail
|
|
|
|
# For each files in tests/queries/*, mount that parquet file, run the query, and compare
|
|
# its output.
|
|
|
|
run_query() {
|
|
file=${1:?must provide testcase file}
|
|
query=${2:?must provide query to run}
|
|
basename=$(basename "$file")
|
|
cat <<EOF
|
|
.load build/linux/libparquet
|
|
.testcase $basename
|
|
.bail on
|
|
CREATE VIRTUAL TABLE IF NOT EXISTS nulls1 USING parquet('$root/parquet-generator/99-rows-nulls-1.parquet');
|
|
CREATE VIRTUAL TABLE IF NOT EXISTS nulls2 USING parquet('$root/parquet-generator/99-rows-nulls-10.parquet');
|
|
CREATE VIRTUAL TABLE IF NOT EXISTS nulls3 USING parquet('$root/parquet-generator/99-rows-nulls-99.parquet');
|
|
CREATE VIRTUAL TABLE IF NOT EXISTS no_nulls1 USING parquet('$root/parquet-generator/99-rows-1.parquet');
|
|
CREATE VIRTUAL TABLE IF NOT EXISTS no_nulls2 USING parquet('$root/parquet-generator/99-rows-10.parquet');
|
|
CREATE VIRTUAL TABLE IF NOT EXISTS no_nulls3 USING parquet('$root/parquet-generator/99-rows-99.parquet');
|
|
$query;
|
|
.output
|
|
EOF
|
|
}
|
|
|
|
main() {
|
|
root=$(dirname "${BASH_SOURCE[0]}")/..
|
|
root=$(readlink -f "$root")
|
|
cd "$root"
|
|
|
|
if [ ! -d "$root"/tests/queries ]; then
|
|
"$root"/tests/create-queries-from-templates
|
|
fi
|
|
|
|
find_cmd=(find tests/queries -type f -name '*.sql')
|
|
debug=0
|
|
if [ -n "${1:-""}" ]; then
|
|
find_cmd+=(-regex ".*$1.*")
|
|
debug=1
|
|
fi
|
|
|
|
"${find_cmd[@]}" | sort > testcases.txt
|
|
|
|
if [ ! -s testcases.txt ]; then
|
|
echo "no matching testcases found"
|
|
exit 1
|
|
fi
|
|
|
|
cat "$root"/parquet-generator/*.sql > "$root"/testcase-bootstrap.sql
|
|
rm -f test.db
|
|
"$root"/sqlite/sqlite3 test.db -init "$root"/testcase-bootstrap.sql < /dev/null
|
|
if [ ! -v NO_DEBUG ] && [ "$(cat testcases.txt | wc -l)" == "1" ]; then
|
|
set -x
|
|
gdb -ex run --args "$root"/sqlite/sqlite3 test.db -init testcase-cmds.txt
|
|
else
|
|
while read -r file; do
|
|
echo "Testing: $file"
|
|
query=$(head -n1 "$file" | tail -n1)
|
|
tail -n+2 "$file" > testcase-expected.txt
|
|
|
|
run_query "$file" "$query" > testcase-cmds.txt
|
|
if ! "$root"/sqlite/sqlite3 test.db -init testcase-cmds.txt < /dev/null > testcase-stdout.txt 2> testcase-stderr.txt; then
|
|
echo "...FAILED; check testcase-{out,err}.txt" >&2
|
|
exit 1
|
|
fi
|
|
diff testcase-out.txt testcase-expected.txt
|
|
done < testcases.txt
|
|
fi
|
|
}
|
|
|
|
main "$@"
|