Skip to content

Commit

Permalink
Add test for JSON format output
Browse files Browse the repository at this point in the history
  • Loading branch information
mkindahl committed Nov 22, 2024
1 parent 2744c4f commit cf8ce07
Show file tree
Hide file tree
Showing 2 changed files with 143 additions and 0 deletions.
138 changes: 138 additions & 0 deletions tsl/test/expected/hypercore_scans.out
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,144 @@ select time, temp + humidity from readings where device between 5 and 10 and hum
Array: cache misses=6, decompress count=18 calls=105
(27 rows)

-- Testing JSON format to make sure it works and to get coverage for
-- those parts of the code.
explain (analyze, costs off, timing off, summary off, decompress_cache_stats, format json)
select time, temp + humidity from readings where device between 5 and 10 and humidity > 5;
QUERY PLAN
---------------------------------------------------------------------
[ +
{ +
"Plan": { +
"Node Type": "Result", +
"Parallel Aware": false, +
"Async Capable": false, +
"Actual Rows": 1624, +
"Actual Loops": 1, +
"Plans": [ +
{ +
"Node Type": "Append", +
"Parent Relationship": "Outer", +
"Parallel Aware": false, +
"Async Capable": false, +
"Actual Rows": 1624, +
"Actual Loops": 1, +
"Subplans Removed": 0, +
"Plans": [ +
{ +
"Node Type": "Index Scan", +
"Parent Relationship": "Member", +
"Parallel Aware": false, +
"Async Capable": false, +
"Scan Direction": "Forward", +
"Index Name": "_hyper_1_1_chunk_readings_device_idx",+
"Relation Name": "_hyper_1_1_chunk", +
"Alias": "_hyper_1_1_chunk", +
"Actual Rows": 34, +
"Actual Loops": 1, +
"Index Cond": "((device >= 5) AND (device <= 10))", +
"Rows Removed by Index Recheck": 0, +
"Filter": "(humidity > '5'::double precision)", +
"Rows Removed by Filter": 1 +
}, +
{ +
"Node Type": "Index Scan", +
"Parent Relationship": "Member", +
"Parallel Aware": false, +
"Async Capable": false, +
"Scan Direction": "Forward", +
"Index Name": "_hyper_1_2_chunk_readings_device_idx",+
"Relation Name": "_hyper_1_2_chunk", +
"Alias": "_hyper_1_2_chunk", +
"Actual Rows": 404, +
"Actual Loops": 1, +
"Index Cond": "((device >= 5) AND (device <= 10))", +
"Rows Removed by Index Recheck": 0, +
"Filter": "(humidity > '5'::double precision)", +
"Rows Removed by Filter": 17 +
}, +
{ +
"Node Type": "Index Scan", +
"Parent Relationship": "Member", +
"Parallel Aware": false, +
"Async Capable": false, +
"Scan Direction": "Forward", +
"Index Name": "_hyper_1_3_chunk_readings_device_idx",+
"Relation Name": "_hyper_1_3_chunk", +
"Alias": "_hyper_1_3_chunk", +
"Actual Rows": 380, +
"Actual Loops": 1, +
"Index Cond": "((device >= 5) AND (device <= 10))", +
"Rows Removed by Index Recheck": 0, +
"Filter": "(humidity > '5'::double precision)", +
"Rows Removed by Filter": 23 +
}, +
{ +
"Node Type": "Index Scan", +
"Parent Relationship": "Member", +
"Parallel Aware": false, +
"Async Capable": false, +
"Scan Direction": "Forward", +
"Index Name": "_hyper_1_4_chunk_readings_device_idx",+
"Relation Name": "_hyper_1_4_chunk", +
"Alias": "_hyper_1_4_chunk", +
"Actual Rows": 359, +
"Actual Loops": 1, +
"Index Cond": "((device >= 5) AND (device <= 10))", +
"Rows Removed by Index Recheck": 0, +
"Filter": "(humidity > '5'::double precision)", +
"Rows Removed by Filter": 18 +
}, +
{ +
"Node Type": "Index Scan", +
"Parent Relationship": "Member", +
"Parallel Aware": false, +
"Async Capable": false, +
"Scan Direction": "Forward", +
"Index Name": "_hyper_1_5_chunk_readings_device_idx",+
"Relation Name": "_hyper_1_5_chunk", +
"Alias": "_hyper_1_5_chunk", +
"Actual Rows": 379, +
"Actual Loops": 1, +
"Index Cond": "((device >= 5) AND (device <= 10))", +
"Rows Removed by Index Recheck": 0, +
"Filter": "(humidity > '5'::double precision)", +
"Rows Removed by Filter": 16 +
}, +
{ +
"Node Type": "Index Scan", +
"Parent Relationship": "Member", +
"Parallel Aware": false, +
"Async Capable": false, +
"Scan Direction": "Forward", +
"Index Name": "_hyper_1_6_chunk_readings_device_idx",+
"Relation Name": "_hyper_1_6_chunk", +
"Alias": "_hyper_1_6_chunk", +
"Actual Rows": 68, +
"Actual Loops": 1, +
"Index Cond": "((device >= 5) AND (device <= 10))", +
"Rows Removed by Index Recheck": 0, +
"Filter": "(humidity > '5'::double precision)", +
"Rows Removed by Filter": 6 +
} +
] +
} +
] +
}, +
"Triggers": [ +
] +
}, +
"Arrow Array Cache": { +
"hits": 0, +
"misses": 6, +
"evictions": 0 +
}, +
"Arrow Array Decompress": { +
"count": 18 +
} +
]
(1 row)

-- Check the explain cache information output.
--
-- Query 1 and 3 should show the same explain plan, and the plan in
Expand Down
5 changes: 5 additions & 0 deletions tsl/test/sql/hypercore_scans.sql
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ select * from :chunk where device between 5 and 10;
explain (analyze, costs off, timing off, summary off, decompress_cache_stats)
select time, temp + humidity from readings where device between 5 and 10 and humidity > 5;

-- Testing JSON format to make sure it works and to get coverage for
-- those parts of the code.
explain (analyze, costs off, timing off, summary off, decompress_cache_stats, format json)
select time, temp + humidity from readings where device between 5 and 10 and humidity > 5;

-- Check the explain cache information output.
--
-- Query 1 and 3 should show the same explain plan, and the plan in
Expand Down

0 comments on commit cf8ce07

Please sign in to comment.