Add test cases
This commit is contained in:
parent
b7c134efc0
commit
96fcafcd2f
|
@ -277,7 +277,8 @@ static int parquetEof(sqlite3_vtab_cursor *cur){
|
|||
return 0;
|
||||
}
|
||||
|
||||
void debugConstraints(sqlite3_index_info *pIdxInfo, ParquetTable *table, sqlite3_value** argv) {
|
||||
void debugConstraints(sqlite3_index_info *pIdxInfo, ParquetTable *table, int argc, sqlite3_value** argv) {
|
||||
printf("debugConstraints, argc=%d\n", argc);
|
||||
for(int i = 0; i < pIdxInfo->nConstraint; i++) {
|
||||
std::string valueStr = "?";
|
||||
if(argv != NULL) {
|
||||
|
@ -345,14 +346,16 @@ static int parquetFilter(
|
|||
){
|
||||
ParquetCursor* cursor = ((sqlite3_vtab_cursor_parquet*)cur)->cursor;
|
||||
printf("xFilter: idxNum=%d, idxStr=%lu, argc=%d\n", idxNum, (long unsigned int)idxStr, argc);
|
||||
debugConstraints((sqlite3_index_info*)idxStr, cursor->getTable(), argv);
|
||||
debugConstraints((sqlite3_index_info*)idxStr, cursor->getTable(), argc, argv);
|
||||
cursor->reset();
|
||||
return parquetNext(cur);
|
||||
}
|
||||
|
||||
/*
|
||||
* Only a forward full table scan is supported. xBestIndex is mostly
|
||||
* a no-op.
|
||||
* We'll always indicate to SQLite that we prefer it to use an index so that it will
|
||||
* pass additional context to xFilter, which we may or may not use.
|
||||
*
|
||||
* We copy the sqlite3_index_info structure, as is, into idxStr for later use.
|
||||
*/
|
||||
static int parquetBestIndex(
|
||||
sqlite3_vtab *tab,
|
||||
|
@ -361,17 +364,19 @@ static int parquetBestIndex(
|
|||
ParquetTable* table = ((sqlite3_vtab_parquet*)tab)->table;
|
||||
|
||||
printf("xBestIndex: nConstraint=%d, nOrderBy=%d\n", pIdxInfo->nConstraint, pIdxInfo->nOrderBy);
|
||||
debugConstraints(pIdxInfo, table, NULL);
|
||||
debugConstraints(pIdxInfo, table, 0, NULL);
|
||||
|
||||
if((pIdxInfo->nConstraint == 0 && pIdxInfo->nOrderBy == 0)) {
|
||||
if(pIdxInfo->nConstraint == 0) {
|
||||
pIdxInfo->estimatedCost = 1000000000000;
|
||||
pIdxInfo->idxNum = 0;
|
||||
pIdxInfo->estimatedRows = 10000;
|
||||
} else {
|
||||
pIdxInfo->estimatedCost = 1;
|
||||
pIdxInfo->idxNum = 1;
|
||||
pIdxInfo->estimatedRows = 100000;
|
||||
pIdxInfo->aConstraintUsage[0].argvIndex = 1;
|
||||
for(int i = 0; i < pIdxInfo->nConstraint; i++) {
|
||||
pIdxInfo->aConstraintUsage[i].argvIndex = i + 1;
|
||||
}
|
||||
|
||||
// TODO: consider setting this when querying by rowid? Unclear if that's implied.
|
||||
// pIdxInfo->idxFlags = SQLITE_INDEX_SCAN_UNIQUE;
|
||||
}
|
||||
printf("idx %d has cost %f\n", pIdxInfo->idxNum, pIdxInfo->estimatedCost);
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
select string_7, string_8 from nulls where string_8 like '%0'
|
||||
0|000
|
|
@ -0,0 +1 @@
|
|||
select string_7, string_8 from nulls where string_8 like '0'
|
|
@ -0,0 +1,51 @@
|
|||
select string_7, string_8 from nulls where string_8 like '0%'
|
||||
0|000
|
||||
1|001
|
||||
2|002
|
||||
3|003
|
||||
4|004
|
||||
5|005
|
||||
6|006
|
||||
7|007
|
||||
8|008
|
||||
9|009
|
||||
|021
|
||||
|023
|
||||
|025
|
||||
|027
|
||||
|029
|
||||
|031
|
||||
|033
|
||||
|035
|
||||
|037
|
||||
|039
|
||||
|041
|
||||
|043
|
||||
|045
|
||||
|047
|
||||
|049
|
||||
|051
|
||||
|053
|
||||
|055
|
||||
|057
|
||||
|059
|
||||
|061
|
||||
|063
|
||||
|065
|
||||
|067
|
||||
|069
|
||||
|071
|
||||
|073
|
||||
|075
|
||||
|077
|
||||
|079
|
||||
|081
|
||||
|083
|
||||
|085
|
||||
|087
|
||||
|089
|
||||
|091
|
||||
|093
|
||||
|095
|
||||
|097
|
||||
|099
|
|
@ -0,0 +1,2 @@
|
|||
select string_7, string_8 from nulls where string_8 like '0_0'
|
||||
0|000
|
|
@ -0,0 +1,3 @@
|
|||
select string_8 from nulls where string_8 > '010' and string_8 < '024'
|
||||
021
|
||||
023
|
|
@ -0,0 +1,2 @@
|
|||
select string_8 from nulls where string_8 >= '021' and string_8 <= '021'
|
||||
021
|
|
@ -0,0 +1,2 @@
|
|||
select string_8 from nulls where string_8 = '021'
|
||||
021
|
|
@ -0,0 +1,2 @@
|
|||
select string_8 from nulls where rowid = 21 and string_8 = '021'
|
||||
021
|
|
@ -0,0 +1 @@
|
|||
select string_8 from nulls where rowid = 21 and string_8 <> '021'
|
|
@ -0,0 +1,2 @@
|
|||
select int8_1 from nulls where int8_1 = 30
|
||||
30
|
|
@ -0,0 +1,2 @@
|
|||
select int8_1 from nulls where int8_1 < -46
|
||||
-48
|
|
@ -0,0 +1,3 @@
|
|||
select int8_1 from nulls where int8_1 <= -46
|
||||
-46
|
||||
-48
|
|
@ -0,0 +1,2 @@
|
|||
select int8_1 from nulls where int8_1 > 49
|
||||
50
|
|
@ -0,0 +1,3 @@
|
|||
select int8_1 from nulls where int8_1 >= 49
|
||||
50
|
||||
49
|
|
@ -0,0 +1 @@
|
|||
select int8_1 from nulls where rowid = 66 and int8_1 <> -16
|
|
@ -0,0 +1,3 @@
|
|||
select int64_4 from nulls where int64_4 >= 49000000000
|
||||
50000000000
|
||||
49000000000
|
|
@ -0,0 +1,2 @@
|
|||
select int64_4 from nulls where int64_4 > 49000000000
|
||||
50000000000
|
|
@ -0,0 +1,2 @@
|
|||
select int64_4 from nulls where int64_4 = 49000000000
|
||||
49000000000
|
|
@ -0,0 +1,2 @@
|
|||
select int64_4 from nulls where int64_4 < -47000000000
|
||||
-49000000000
|
|
@ -0,0 +1,3 @@
|
|||
select int64_4 from nulls where int64_4 <= -47000000000
|
||||
-47000000000
|
||||
-49000000000
|
|
@ -0,0 +1 @@
|
|||
select int64_4 from nulls where rowid = 57 and int64_4 <> -7000000000
|
|
@ -0,0 +1,2 @@
|
|||
select int64_4 from nulls where rowid = 57 and int64_4 <> -8000000000
|
||||
-7000000000
|
|
@ -0,0 +1,2 @@
|
|||
select printf('%.4f', double_6) as double_6 from nulls where double_6 = 100.0
|
||||
100.0000
|
|
@ -0,0 +1,2 @@
|
|||
select printf('%.4f', double_6) as double_6 from nulls where double_6 > 99
|
||||
100.0000
|
|
@ -0,0 +1,3 @@
|
|||
select printf('%.4f', double_6) as double_6 from nulls where double_6 >= 50
|
||||
100.0000
|
||||
50.0000
|
|
@ -0,0 +1,2 @@
|
|||
select printf('%.4f', double_6) as double_6 from nulls where double_6 < 100.0 order by double_6 desc limit 1
|
||||
50.0000
|
|
@ -0,0 +1,2 @@
|
|||
select printf('%.4f', double_6) from nulls where double_6 <= 100.0 order by double_6 desc limit 1
|
||||
100.0000
|
|
@ -0,0 +1 @@
|
|||
select printf('%.4f', double_6) from nulls where rowid = 0 and double_6 <> 100
|
|
@ -0,0 +1,2 @@
|
|||
select printf('%.4f', double_6) from nulls where rowid = 0 and double_6 <> 101
|
||||
100.0000
|
|
@ -0,0 +1,2 @@
|
|||
select rowid from nulls where binary_10 = x'01';
|
||||
1
|
|
@ -0,0 +1 @@
|
|||
select rowid from nulls where rowid = 1 and binary_10 <> x'01';
|
|
@ -0,0 +1,2 @@
|
|||
select rowid from nulls where binary_10 < x'01';
|
||||
0
|
|
@ -0,0 +1,3 @@
|
|||
select rowid from nulls where binary_10 <= x'01' order by 1;
|
||||
0
|
||||
1
|
|
@ -0,0 +1,2 @@
|
|||
select rowid from nulls where binary_10 > x'61';
|
||||
99
|
|
@ -0,0 +1,3 @@
|
|||
select rowid from nulls where binary_10 >= x'61' order by 1;
|
||||
97
|
||||
99
|
|
@ -15,7 +15,8 @@ run_query() {
|
|||
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
|
||||
$query;
|
||||
.output
|
||||
EOF
|
||||
}
|
||||
|
||||
|
@ -39,6 +40,7 @@ main() {
|
|||
fi
|
||||
|
||||
if [ "$(cat testcases.txt | wc -l)" == "1" ]; then
|
||||
set -x
|
||||
gdb -ex run --args "$root"/sqlite/sqlite3 -init testcase-cmds.txt
|
||||
else
|
||||
while read -r file; do
|
||||
|
|
Loading…
Reference in New Issue