mirror of
				https://github.com/cldellow/sqlite-parquet-vtable.git
				synced 2025-10-27 01:59:56 +00:00 
			
		
		
		
	Add test cases
This commit is contained in:
		| @@ -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); | ||||
|   | ||||
							
								
								
									
										2
									
								
								tests/queries/014-nulls-like-percent-start.sql
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								tests/queries/014-nulls-like-percent-start.sql
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,2 @@ | ||||
| select string_7, string_8 from nulls where string_8 like '%0' | ||||
| 0|000 | ||||
							
								
								
									
										1
									
								
								tests/queries/015-nulls-like-no-match.sql
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								tests/queries/015-nulls-like-no-match.sql
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1 @@ | ||||
| select string_7, string_8 from nulls where string_8 like '0' | ||||
							
								
								
									
										51
									
								
								tests/queries/016-nulls-like-percent-end.sql
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										51
									
								
								tests/queries/016-nulls-like-percent-end.sql
									
									
									
									
									
										Normal file
									
								
							| @@ -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 | ||||
							
								
								
									
										2
									
								
								tests/queries/017-nulls-like-underscore.sql
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								tests/queries/017-nulls-like-underscore.sql
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,2 @@ | ||||
| select string_7, string_8 from nulls where string_8 like '0_0' | ||||
| 0|000 | ||||
							
								
								
									
										3
									
								
								tests/queries/018-string-gt-lt.sql
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								tests/queries/018-string-gt-lt.sql
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,3 @@ | ||||
| select string_8 from nulls where string_8 > '010' and string_8 < '024' | ||||
| 021 | ||||
| 023 | ||||
							
								
								
									
										2
									
								
								tests/queries/019-string-gte-lte.sql
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								tests/queries/019-string-gte-lte.sql
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,2 @@ | ||||
| select string_8 from nulls where string_8 >= '021' and string_8 <= '021' | ||||
| 021 | ||||
							
								
								
									
										2
									
								
								tests/queries/020-string-eq.sql
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								tests/queries/020-string-eq.sql
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,2 @@ | ||||
| select string_8 from nulls where string_8 = '021' | ||||
| 021 | ||||
							
								
								
									
										2
									
								
								tests/queries/021-rowid-and-field-eq.sql
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								tests/queries/021-rowid-and-field-eq.sql
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,2 @@ | ||||
| select string_8 from nulls where rowid = 21 and string_8 = '021' | ||||
| 021 | ||||
							
								
								
									
										1
									
								
								tests/queries/022-rowid-and-field-ne.sql
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								tests/queries/022-rowid-and-field-ne.sql
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1 @@ | ||||
| select string_8 from nulls where rowid = 21 and string_8 <> '021' | ||||
							
								
								
									
										2
									
								
								tests/queries/023-int8-eq.sql
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								tests/queries/023-int8-eq.sql
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,2 @@ | ||||
| select int8_1 from nulls where int8_1 = 30 | ||||
| 30 | ||||
							
								
								
									
										2
									
								
								tests/queries/024-int8-lt.sql
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								tests/queries/024-int8-lt.sql
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,2 @@ | ||||
| select int8_1 from nulls where int8_1 < -46 | ||||
| -48 | ||||
							
								
								
									
										3
									
								
								tests/queries/025-int8-lte.sql
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								tests/queries/025-int8-lte.sql
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,3 @@ | ||||
| select int8_1 from nulls where int8_1 <= -46 | ||||
| -46 | ||||
| -48 | ||||
							
								
								
									
										2
									
								
								tests/queries/026-int8-gt.sql
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								tests/queries/026-int8-gt.sql
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,2 @@ | ||||
| select int8_1 from nulls where int8_1 > 49 | ||||
| 50 | ||||
							
								
								
									
										3
									
								
								tests/queries/027-int8-gte.sql
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								tests/queries/027-int8-gte.sql
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,3 @@ | ||||
| select int8_1 from nulls where int8_1 >= 49 | ||||
| 50 | ||||
| 49 | ||||
							
								
								
									
										1
									
								
								tests/queries/028-int8-rowid-eq-and-field-ne.sql
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								tests/queries/028-int8-rowid-eq-and-field-ne.sql
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1 @@ | ||||
| select int8_1 from nulls where rowid = 66 and int8_1 <> -16 | ||||
							
								
								
									
										3
									
								
								tests/queries/029-int64-gte.sql
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								tests/queries/029-int64-gte.sql
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,3 @@ | ||||
| select int64_4 from nulls where int64_4 >= 49000000000 | ||||
| 50000000000 | ||||
| 49000000000 | ||||
							
								
								
									
										2
									
								
								tests/queries/030-int64-gt.sql
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								tests/queries/030-int64-gt.sql
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,2 @@ | ||||
| select int64_4 from nulls where int64_4 > 49000000000 | ||||
| 50000000000 | ||||
							
								
								
									
										2
									
								
								tests/queries/031-int64-eq.sql
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								tests/queries/031-int64-eq.sql
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,2 @@ | ||||
| select int64_4 from nulls where int64_4 = 49000000000 | ||||
| 49000000000 | ||||
							
								
								
									
										2
									
								
								tests/queries/032-int64-lt.sql
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								tests/queries/032-int64-lt.sql
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,2 @@ | ||||
| select int64_4 from nulls where int64_4 < -47000000000 | ||||
| -49000000000 | ||||
							
								
								
									
										3
									
								
								tests/queries/033-int64-lte.sql
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								tests/queries/033-int64-lte.sql
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,3 @@ | ||||
| select int64_4 from nulls where int64_4 <= -47000000000 | ||||
| -47000000000 | ||||
| -49000000000 | ||||
							
								
								
									
										1
									
								
								tests/queries/034-int64-rowid-eq-and-field-ne.sql
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								tests/queries/034-int64-rowid-eq-and-field-ne.sql
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1 @@ | ||||
| select int64_4 from nulls where rowid = 57 and int64_4 <> -7000000000 | ||||
							
								
								
									
										2
									
								
								tests/queries/035-int64-rowid-eq-and-field-ne2.sql
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								tests/queries/035-int64-rowid-eq-and-field-ne2.sql
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,2 @@ | ||||
| select int64_4 from nulls where rowid = 57 and int64_4 <> -8000000000 | ||||
| -7000000000 | ||||
							
								
								
									
										2
									
								
								tests/queries/036-double-eq.sql
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								tests/queries/036-double-eq.sql
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,2 @@ | ||||
| select printf('%.4f', double_6) as double_6 from nulls where double_6 = 100.0 | ||||
| 100.0000 | ||||
							
								
								
									
										2
									
								
								tests/queries/037-double-gt.sql
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								tests/queries/037-double-gt.sql
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,2 @@ | ||||
| select printf('%.4f', double_6) as double_6 from nulls where double_6 > 99 | ||||
| 100.0000 | ||||
							
								
								
									
										3
									
								
								tests/queries/038-double-gte.sql
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								tests/queries/038-double-gte.sql
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,3 @@ | ||||
| select printf('%.4f', double_6) as double_6 from nulls where double_6 >= 50 | ||||
| 100.0000 | ||||
| 50.0000 | ||||
							
								
								
									
										2
									
								
								tests/queries/039-double-lt.sql
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								tests/queries/039-double-lt.sql
									
									
									
									
									
										Normal file
									
								
							| @@ -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 | ||||
							
								
								
									
										2
									
								
								tests/queries/040-double-lte.sql
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								tests/queries/040-double-lte.sql
									
									
									
									
									
										Normal file
									
								
							| @@ -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 | ||||
							
								
								
									
										1
									
								
								tests/queries/041-double-rowid-and-field-ne.sql
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								tests/queries/041-double-rowid-and-field-ne.sql
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1 @@ | ||||
| select printf('%.4f', double_6)  from nulls where rowid = 0 and double_6 <> 100 | ||||
							
								
								
									
										2
									
								
								tests/queries/042-double-rowid-and-field-ne2.sql
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								tests/queries/042-double-rowid-and-field-ne2.sql
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,2 @@ | ||||
| select printf('%.4f', double_6)  from nulls where rowid = 0 and double_6 <> 101 | ||||
| 100.0000 | ||||
							
								
								
									
										2
									
								
								tests/queries/043-binary-eq.sql
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								tests/queries/043-binary-eq.sql
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,2 @@ | ||||
| select rowid from nulls where binary_10 = x'01'; | ||||
| 1 | ||||
							
								
								
									
										1
									
								
								tests/queries/044-binary-rowid-and-ne.sql
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								tests/queries/044-binary-rowid-and-ne.sql
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1 @@ | ||||
| select rowid from nulls where rowid = 1 and binary_10 <> x'01'; | ||||
							
								
								
									
										2
									
								
								tests/queries/045-binary-lt.sql
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								tests/queries/045-binary-lt.sql
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,2 @@ | ||||
| select rowid from nulls where binary_10 < x'01'; | ||||
| 0 | ||||
							
								
								
									
										3
									
								
								tests/queries/046-binary-lte.sql
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								tests/queries/046-binary-lte.sql
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,3 @@ | ||||
| select rowid from nulls where binary_10 <= x'01' order by 1; | ||||
| 0 | ||||
| 1 | ||||
							
								
								
									
										2
									
								
								tests/queries/047-binary-gt.sql
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								tests/queries/047-binary-gt.sql
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,2 @@ | ||||
| select rowid from nulls where binary_10 > x'61'; | ||||
| 99 | ||||
							
								
								
									
										3
									
								
								tests/queries/048-binary-gte.sql
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								tests/queries/048-binary-gte.sql
									
									
									
									
									
										Normal file
									
								
							| @@ -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 | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Colin Dellow
					Colin Dellow