Rewrite SQL oracle harness
This commit is contained in:
parent
caefc23b1e
commit
35fcde926c
|
@ -10,7 +10,7 @@ createdb parquet
|
|||
here=$(readlink -f "$(dirname "${BASH_SOURCE[0]}")")
|
||||
|
||||
psql parquet << EOF
|
||||
CREATE TABLE no_nulls(
|
||||
CREATE TABLE no_nulls1(
|
||||
rowid INT2,
|
||||
bool_0 INT2,
|
||||
int8_1 INT2,
|
||||
|
@ -25,9 +25,11 @@ CREATE TABLE no_nulls(
|
|||
binary_10 TEXT
|
||||
);
|
||||
|
||||
CREATE TABLE nulls (LIKE no_nulls);
|
||||
CREATE TABLE no_nulls2 (LIKE no_nulls1);
|
||||
CREATE TABLE nulls (LIKE no_nulls1);
|
||||
|
||||
COPY no_nulls FROM '$here/no-nulls.csv';
|
||||
COPY no_nulls1 FROM '$here/no-nulls.csv';
|
||||
COPY no_nulls2 FROM '$here/no-nulls.csv';
|
||||
COPY nulls FROM '$here/nulls.csv';
|
||||
|
||||
CREATE OR REPLACE FUNCTION quote(TEXT) RETURNS TEXT AS \$\$
|
||||
|
@ -47,9 +49,4 @@ CREATE OR REPLACE FUNCTION printf(TEXT, DOUBLE PRECISION) RETURNS TEXT AS \$\$
|
|||
RETURN CAST(\$2 AS DECIMAL(10, 4))::TEXT;
|
||||
END;
|
||||
\$\$ LANGUAGE 'plpgsql' IMMUTABLE;
|
||||
|
||||
|
||||
|
||||
--COPY (SELECT rowid, bool_0, int8_1, int16_2, int32_3, int64_4, datetime(ts_5 / 1000, 'unixepoch'), double_6, string_7, string_8, quote(binary_9), quote(binary_10) FROM nulls LIMIT 3) TO STDOUT WITH (DELIMITER '|', NULL '');
|
||||
COPY (SELECT rowid, bool_0, int8_1, int16_2, int32_3, int64_4, datetime(ts_5 / 1000, 'unixepoch'), printf('%.4f', double_6) AS double_6, string_7, string_8, quote(binary_9), quote(binary_10) FROM no_nulls) TO STDOUT WITH (DELIMITER '|', NULL '');
|
||||
EOF
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
100-rows-1.parquet
|
||||
SELECT rowid, bool_0, int8_1, int16_2, int32_3, int64_4, datetime(ts_5 / 1000, 'unixepoch'), printf("%.4f", double_6) AS double_6, string_7, string_8, quote(binary_9), quote(binary_10) FROM test;
|
||||
SELECT rowid, bool_0, int8_1, int16_2, int32_3, int64_4, datetime(ts_5 / 1000, 'unixepoch'), printf("%.4f", double_6) AS double_6, string_7, string_8, quote(binary_9), quote(binary_10) FROM no_nulls1;
|
||||
0|1|50|5000|50000000|50000000000|1985-07-20 00:00:00|100.0000|0|000|X'00'|X'00'
|
||||
1|0|49|4900|49000000|49000000000|1985-07-21 00:00:00|50.0000|1|001|X'0101'|X'01'
|
||||
2|1|48|4800|48000000|48000000000|1985-07-22 00:00:00|33.3333|2|002|X'020202'|X'02'
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
100-rows-10.parquet
|
||||
SELECT rowid, bool_0, int8_1, int16_2, int32_3, int64_4, datetime(ts_5 / 1000, 'unixepoch'), printf("%.4f", double_6) AS double_6, string_7, string_8, quote(binary_9), quote(binary_10) FROM test;
|
||||
SELECT rowid, bool_0, int8_1, int16_2, int32_3, int64_4, datetime(ts_5 / 1000, 'unixepoch'), printf("%.4f", double_6) AS double_6, string_7, string_8, quote(binary_9), quote(binary_10) FROM no_nulls2;
|
||||
0|1|50|5000|50000000|50000000000|1985-07-20 00:00:00|100.0000|0|000|X'00'|X'00'
|
||||
1|0|49|4900|49000000|49000000000|1985-07-21 00:00:00|50.0000|1|001|X'0101'|X'01'
|
||||
2|1|48|4800|48000000|48000000000|1985-07-22 00:00:00|33.3333|2|002|X'020202'|X'02'
|
||||
|
|
|
@ -1,3 +1,2 @@
|
|||
100-rows-1.parquet
|
||||
select count(*) from (select * from test t1, test t2);
|
||||
select count(*) from (select * from no_nulls1 t1, no_nulls1 t2);
|
||||
10000
|
||||
|
|
|
@ -1,3 +1,2 @@
|
|||
100-rows-10.parquet
|
||||
select count(*) from (select * from test t1, test t2);
|
||||
select count(*) from (select * from no_nulls2 t1, no_nulls2 t2);
|
||||
10000
|
||||
|
|
|
@ -1,3 +1,2 @@
|
|||
100-rows-1.parquet
|
||||
select int8_1 from test where rowid = 50;
|
||||
select int8_1 from no_nulls1 where rowid = 50;
|
||||
0
|
||||
|
|
|
@ -1,3 +1,2 @@
|
|||
100-rows-10.parquet
|
||||
select int8_1 from test where rowid = 50;
|
||||
select int8_1 from no_nulls2 where rowid = 50;
|
||||
0
|
||||
|
|
|
@ -1,3 +1,2 @@
|
|||
100-rows-10.parquet
|
||||
select int8_1 from test where rowid = 55;
|
||||
select int8_1 from no_nulls2 where rowid = 55;
|
||||
-5
|
||||
|
|
|
@ -1,3 +1,2 @@
|
|||
100-rows-nulls.parquet
|
||||
SELECT SUM(CASE WHEN bool_0 IS NULL THEN 1 ELSE 0 END), SUM(CASE WHEN int8_1 IS NULL THEN 1 ELSE 0 END), SUM(CASE WHEN int16_2 IS NULL THEN 1 ELSE 0 END), SUM(CASE WHEN int32_3 IS NULL THEN 1 ELSE 0 END), SUM(CASE WHEN int64_4 IS NULL THEN 1 ELSE 0 END), SUM(CASE WHEN ts_5 IS NULL THEN 1 ELSE 0 END), SUM(CASE WHEN double_6 IS NULL THEN 1 ELSE 0 END), SUM(CASE WHEN string_7 IS NULL THEN 1 ELSE 0 END), SUM(CASE WHEN string_8 IS NULL THEN 1 ELSE 0 END), SUM(CASE WHEN binary_9 IS NULL THEN 1 ELSE 0 END), SUM(CASE WHEN binary_10 IS NULL THEN 1 ELSE 0 END) from test;
|
||||
SELECT SUM(CASE WHEN bool_0 IS NULL THEN 1 ELSE 0 END), SUM(CASE WHEN int8_1 IS NULL THEN 1 ELSE 0 END), SUM(CASE WHEN int16_2 IS NULL THEN 1 ELSE 0 END), SUM(CASE WHEN int32_3 IS NULL THEN 1 ELSE 0 END), SUM(CASE WHEN int64_4 IS NULL THEN 1 ELSE 0 END), SUM(CASE WHEN ts_5 IS NULL THEN 1 ELSE 0 END), SUM(CASE WHEN double_6 IS NULL THEN 1 ELSE 0 END), SUM(CASE WHEN string_7 IS NULL THEN 1 ELSE 0 END), SUM(CASE WHEN string_8 IS NULL THEN 1 ELSE 0 END), SUM(CASE WHEN binary_9 IS NULL THEN 1 ELSE 0 END), SUM(CASE WHEN binary_10 IS NULL THEN 1 ELSE 0 END) from nulls;
|
||||
50|50|50|50|50|50|50|50|50|50|50
|
||||
|
|
|
@ -6,14 +6,15 @@ set -euo pipefail
|
|||
|
||||
run_query() {
|
||||
file=${1:?must provide testcase file}
|
||||
parquet_file=${2:?must provide parquet file to load}
|
||||
query=${3:?must provide query to run}
|
||||
query=${2:?must provide query to run}
|
||||
basename=$(basename "$file")
|
||||
cat <<EOF
|
||||
.load parquet/libparquet
|
||||
.testcase $basename
|
||||
.bail on
|
||||
CREATE VIRTUAL TABLE test USING parquet('parquet-generator/$parquet_file');
|
||||
CREATE VIRTUAL TABLE nulls USING parquet('$root/parquet-generator/100-rows-nulls.parquet');
|
||||
CREATE VIRTUAL TABLE no_nulls1 USING parquet('$root/parquet-generator/100-rows-1.parquet');
|
||||
CREATE VIRTUAL TABLE no_nulls2 USING parquet('$root/parquet-generator/100-rows-10.parquet');
|
||||
$query
|
||||
EOF
|
||||
}
|
||||
|
@ -26,10 +27,9 @@ main() {
|
|||
queries=$(find tests/queries -type f -name '*.sql' | sort)
|
||||
while read -r file; do
|
||||
echo "Testing: $file"
|
||||
parquet_file=$(head -n1 "$file")
|
||||
query=$(head -n2 "$file" | tail -n1)
|
||||
results=$(tail -n+3 "$file")
|
||||
if ! "$root"/sqlite/sqlite3 -init <(run_query "$file" "$parquet_file" "$query") < /dev/null > testcase-stdout.txt 2> testcase-stderr.txt; then
|
||||
query=$(head -n1 "$file" | tail -n1)
|
||||
results=$(tail -n+2 "$file")
|
||||
if ! "$root"/sqlite/sqlite3 -init <(run_query "$file" "$query") < /dev/null > testcase-stdout.txt 2> testcase-stderr.txt; then
|
||||
echo "...FAILED; check testcase-{out,err}.txt" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
|
Loading…
Reference in New Issue