refactor: move delete tests to .sql

pull/24376/head
Nga Tran 2021-10-12 15:49:23 -04:00
parent 9b6726b99c
commit 459dd46ae9
21 changed files with 905 additions and 977 deletions

View File

@ -586,8 +586,6 @@ impl InfluxRpcPlanner {
/// The data is sorted on (tag_col1, tag_col2, ...) so that all
/// rows for a particular series (groups where all tags are the
/// same) occur together in the plan
// NGA todo: may need to add delete predicate here to eliminate deleted data at read time
// https://github.com/influxdata/influxdb_iox/issues/2548
pub fn read_filter<D>(&self, database: &D, predicate: Predicate) -> Result<SeriesSetPlans>
where
D: QueryDatabase + 'static,

View File

@ -0,0 +1,25 @@
-- Test Setup: OneDeleteSimpleExprOneChunkDeleteAll
-- SQL: SELECT * from cpu;
++
++
-- SQL: SELECT time from cpu;
++
++
-- SQL: SELECT count(*), count(bar), count(time) from cpu;
+-----------------+----------------+-----------------+
| COUNT(UInt8(1)) | COUNT(cpu.bar) | COUNT(cpu.time) |
+-----------------+----------------+-----------------+
| 0 | 0 | 0 |
+-----------------+----------------+-----------------+
-- SQL: SELECT min(bar), max(bar), min(time), max(time) from cpu;
+--------------+--------------+---------------+---------------+
| MIN(cpu.bar) | MAX(cpu.bar) | MIN(cpu.time) | MAX(cpu.time) |
+--------------+--------------+---------------+---------------+
| | | | |
+--------------+--------------+---------------+---------------+
-- SQL: SELECT max(bar) from cpu;
+--------------+
| MAX(cpu.bar) |
+--------------+
| |
+--------------+

View File

@ -0,0 +1,17 @@
-- Demonstrate soft deleted rows will not be return to queries
-- IOX_SETUP: OneDeleteSimpleExprOneChunkDeleteAll
-- select *
SELECT * from cpu;
-- select one specific column
SELECT time from cpu;
-- select aggregate of every column inlcuding star
SELECT count(*), count(bar), count(time) from cpu;
-- select aggregate of every column
SELECT min(bar), max(bar), min(time), max(time) from cpu;
-- select aggregate of one column
SELECT max(bar) from cpu;

View File

@ -0,0 +1,111 @@
-- Test Setup: OneDeleteMultiExprsOneChunk
-- SQL: SELECT * from cpu;
+-----+-----+--------------------------------+
| bar | foo | time |
+-----+-----+--------------------------------+
| 1 | me | 1970-01-01T00:00:00.000000040Z |
| 2 | you | 1970-01-01T00:00:00.000000020Z |
+-----+-----+--------------------------------+
-- SQL: SELECT time, bar from cpu;
+--------------------------------+-----+
| time | bar |
+--------------------------------+-----+
| 1970-01-01T00:00:00.000000040Z | 1 |
| 1970-01-01T00:00:00.000000020Z | 2 |
+--------------------------------+-----+
-- SQL: SELECT bar from cpu;
+-----+
| bar |
+-----+
| 1 |
| 2 |
+-----+
-- SQL: SELECT count(time), count(*), count(bar), min(bar), max(bar), min(time), max(time) from cpu;
+-----------------+-----------------+----------------+--------------+--------------+--------------------------------+--------------------------------+
| COUNT(cpu.time) | COUNT(UInt8(1)) | COUNT(cpu.bar) | MIN(cpu.bar) | MAX(cpu.bar) | MIN(cpu.time) | MAX(cpu.time) |
+-----------------+-----------------+----------------+--------------+--------------+--------------------------------+--------------------------------+
| 2 | 2 | 2 | 1 | 2 | 1970-01-01T00:00:00.000000020Z | 1970-01-01T00:00:00.000000040Z |
+-----------------+-----------------+----------------+--------------+--------------+--------------------------------+--------------------------------+
-- SQL: SELECT count(time) from cpu;
+-----------------+
| COUNT(cpu.time) |
+-----------------+
| 2 |
+-----------------+
-- SQL: SELECT count(foo) from cpu;
+----------------+
| COUNT(cpu.foo) |
+----------------+
| 2 |
+----------------+
-- SQL: SELECT count(bar) from cpu;
+----------------+
| COUNT(cpu.bar) |
+----------------+
| 2 |
+----------------+
-- SQL: SELECT count(*) from cpu;
+-----------------+
| COUNT(UInt8(1)) |
+-----------------+
| 2 |
+-----------------+
-- SQL: SELECT min(bar) from cpu;
+--------------+
| MIN(cpu.bar) |
+--------------+
| 1 |
+--------------+
-- SQL: SELECT foo from cpu;
+-----+
| foo |
+-----+
| me |
| you |
+-----+
-- SQL: SELECT time from cpu;
+--------------------------------+
| time |
+--------------------------------+
| 1970-01-01T00:00:00.000000040Z |
| 1970-01-01T00:00:00.000000020Z |
+--------------------------------+
-- SQL: SELECT max(bar) from cpu;
+--------------+
| MAX(cpu.bar) |
+--------------+
| 2 |
+--------------+
-- SQL: SELECT * from cpu where bar >= 1.0 order by bar, foo, time;
+-----+-----+--------------------------------+
| bar | foo | time |
+-----+-----+--------------------------------+
| 1 | me | 1970-01-01T00:00:00.000000040Z |
| 2 | you | 1970-01-01T00:00:00.000000020Z |
+-----+-----+--------------------------------+
-- SQL: SELECT foo from cpu where bar >= 1.0 order by foo;
+-----+
| foo |
+-----+
| me |
| you |
+-----+
-- SQL: SELECT time, bar from cpu where bar >= 1.0 order by bar, time;
+--------------------------------+-----+
| time | bar |
+--------------------------------+-----+
| 1970-01-01T00:00:00.000000040Z | 1 |
| 1970-01-01T00:00:00.000000020Z | 2 |
+--------------------------------+-----+
-- SQL: SELECT * from cpu where foo = 'you' order by bar, foo, time;
+-----+-----+--------------------------------+
| bar | foo | time |
+-----+-----+--------------------------------+
| 2 | you | 1970-01-01T00:00:00.000000020Z |
+-----+-----+--------------------------------+
-- SQL: SELECT min(bar) as mi, max(time) as ma from cpu where foo = 'you' order by mi, ma
+----+--------------------------------+
| mi | ma |
+----+--------------------------------+
| 2 | 1970-01-01T00:00:00.000000020Z |
+----+--------------------------------+

View File

@ -0,0 +1,51 @@
-- Demonstrate soft deleted rows will not be return to queries
-- IOX_SETUP: OneDeleteMultiExprsOneChunk
-- select *
SELECT * from cpu;
SELECT time, bar from cpu;
SELECT bar from cpu;
SELECT count(time), count(*), count(bar), min(bar), max(bar), min(time), max(time) from cpu;
SELECT count(time) from cpu;
SELECT count(foo) from cpu;
SELECT count(bar) from cpu;
SELECT count(*) from cpu;
SELECT min(bar) from cpu;
SELECT foo from cpu;
-- BUG: https://github.com/influxdata/influxdb_iox/issues/2776
-- SELECT min(foo) from cpu;
-- SELECT max(foo) from cpu
-- BUG: https://github.com/influxdata/influxdb_iox/issues/2779
-- inconsistent format returned
-- SELECT min(time) from cpu;
-- SELECT max(time) from cpu;
SELECT time from cpu;
SELECT max(bar) from cpu;
--------------------------------------------------------
-- With selection predicate
SELECT * from cpu where bar >= 1.0 order by bar, foo, time;
SELECT foo from cpu where bar >= 1.0 order by foo;
SELECT time, bar from cpu where bar >= 1.0 order by bar, time;
SELECT * from cpu where foo = 'you' order by bar, foo, time;
SELECT min(bar) as mi, max(time) as ma from cpu where foo = 'you' order by mi, ma

View File

@ -0,0 +1,73 @@
-- Test Setup: OneDeleteSimpleExprOneChunk
-- SQL: SELECT * from cpu;
+-----+--------------------------------+
| bar | time |
+-----+--------------------------------+
| 2 | 1970-01-01T00:00:00.000000020Z |
+-----+--------------------------------+
-- SQL: SELECT time, bar from cpu;
+--------------------------------+-----+
| time | bar |
+--------------------------------+-----+
| 1970-01-01T00:00:00.000000020Z | 2 |
+--------------------------------+-----+
-- SQL: SELECT min(bar), max(bar) from cpu;
+--------------+--------------+
| MIN(cpu.bar) | MAX(cpu.bar) |
+--------------+--------------+
| 2 | 2 |
+--------------+--------------+
-- SQL: SELECT time from cpu;
+--------------------------------+
| time |
+--------------------------------+
| 1970-01-01T00:00:00.000000020Z |
+--------------------------------+
-- SQL: SELECT count(time), max(time) from cpu;
+-----------------+--------------------------------+
| COUNT(cpu.time) | MAX(cpu.time) |
+-----------------+--------------------------------+
| 1 | 1970-01-01T00:00:00.000000020Z |
+-----------------+--------------------------------+
-- SQL: SELECT count(time) from cpu;
+-----------------+
| COUNT(cpu.time) |
+-----------------+
| 1 |
+-----------------+
-- SQL: SELECT count(time), count(*), count(bar), min(bar), max(bar), min(time), max(time) from cpu;
+-----------------+-----------------+----------------+--------------+--------------+--------------------------------+--------------------------------+
| COUNT(cpu.time) | COUNT(UInt8(1)) | COUNT(cpu.bar) | MIN(cpu.bar) | MAX(cpu.bar) | MIN(cpu.time) | MAX(cpu.time) |
+-----------------+-----------------+----------------+--------------+--------------+--------------------------------+--------------------------------+
| 1 | 1 | 1 | 2 | 2 | 1970-01-01T00:00:00.000000020Z | 1970-01-01T00:00:00.000000020Z |
+-----------------+-----------------+----------------+--------------+--------------+--------------------------------+--------------------------------+
-- SQL: SELECT * from cpu where bar = 2.0;
+-----+--------------------------------+
| bar | time |
+-----+--------------------------------+
| 2 | 1970-01-01T00:00:00.000000020Z |
+-----+--------------------------------+
-- SQL: SELECT * from cpu where bar != 2.0;
++
++
-- SQL: SELECT count(time), count(*), count(bar), min(bar), max(bar), min(time), max(time) from cpu where bar= 2.0;
+-----------------+-----------------+----------------+--------------+--------------+--------------------------------+--------------------------------+
| COUNT(cpu.time) | COUNT(UInt8(1)) | COUNT(cpu.bar) | MIN(cpu.bar) | MAX(cpu.bar) | MIN(cpu.time) | MAX(cpu.time) |
+-----------------+-----------------+----------------+--------------+--------------+--------------------------------+--------------------------------+
| 1 | 1 | 1 | 2 | 2 | 1970-01-01T00:00:00.000000020Z | 1970-01-01T00:00:00.000000020Z |
+-----------------+-----------------+----------------+--------------+--------------+--------------------------------+--------------------------------+
-- SQL: SELECT count(time), count(*), count(bar), min(bar), max(bar), min(time), max(time) from cpu where bar != 2.0;
+-----------------+-----------------+----------------+--------------+--------------+---------------+---------------+
| COUNT(cpu.time) | COUNT(UInt8(1)) | COUNT(cpu.bar) | MIN(cpu.bar) | MAX(cpu.bar) | MIN(cpu.time) | MAX(cpu.time) |
+-----------------+-----------------+----------------+--------------+--------------+---------------+---------------+
| 0 | 0 | 0 | | | | |
+-----------------+-----------------+----------------+--------------+--------------+---------------+---------------+
-- SQL: SELECT time from cpu where bar=2;
+--------------------------------+
| time |
+--------------------------------+
| 1970-01-01T00:00:00.000000020Z |
+--------------------------------+
-- SQL: SELECT bar from cpu where bar!= 2;
++
++

View File

@ -0,0 +1,38 @@
-- Demonstrate soft deleted rows will not be return to queries
-- IOX_SETUP: OneDeleteSimpleExprOneChunk
-- select *
SELECT * from cpu;
SELECT time, bar from cpu;
SELECT min(bar), max(bar) from cpu;
SELECT time from cpu;
-- BUG: https://github.com/influxdata/influxdb_iox/issues/2779
-- inconsistent format returned
-- ignore for now
-- SELECT max(time) from cpu;
SELECT count(time), max(time) from cpu;
SELECT count(time) from cpu;
SELECT count(time), count(*), count(bar), min(bar), max(bar), min(time), max(time) from cpu;
----------------------------------------------------------------
-- Now att spection predicate
SELECT * from cpu where bar = 2.0;
SELECT * from cpu where bar != 2.0;
SELECT count(time), count(*), count(bar), min(bar), max(bar), min(time), max(time) from cpu where bar= 2.0;
SELECT count(time), count(*), count(bar), min(bar), max(bar), min(time), max(time) from cpu where bar != 2.0;
SELECT time from cpu where bar=2;
SELECT bar from cpu where bar!= 2;

View File

@ -0,0 +1,226 @@
-- Test Setup: ThreeDeleteThreeChunks
-- SQL: SELECT * from cpu order by foo, bar, time;
+-----+-----+--------------------------------+
| bar | foo | time |
+-----+-----+--------------------------------+
| 1 | me | 1970-01-01T00:00:00.000000040Z |
| 1 | me | 1970-01-01T00:00:00.000000042Z |
| 1 | me | 1970-01-01T00:00:00.000000062Z |
| 4 | me | 1970-01-01T00:00:00.000000050Z |
| 5 | me | 1970-01-01T00:00:00.000000060Z |
| 7 | me | 1970-01-01T00:00:00.000000080Z |
| 3 | you | 1970-01-01T00:00:00.000000070Z |
+-----+-----+--------------------------------+
-- SQL: SELECT time, bar from cpu order by bar, time;
+--------------------------------+-----+
| time | bar |
+--------------------------------+-----+
| 1970-01-01T00:00:00.000000040Z | 1 |
| 1970-01-01T00:00:00.000000042Z | 1 |
| 1970-01-01T00:00:00.000000062Z | 1 |
| 1970-01-01T00:00:00.000000070Z | 3 |
| 1970-01-01T00:00:00.000000050Z | 4 |
| 1970-01-01T00:00:00.000000060Z | 5 |
| 1970-01-01T00:00:00.000000080Z | 7 |
+--------------------------------+-----+
-- SQL: SELECT bar from cpu order by bar;
+-----+
| bar |
+-----+
| 1 |
| 1 |
| 1 |
| 3 |
| 4 |
| 5 |
| 7 |
+-----+
-- SQL: SELECT count(time) as t, count(*) as c, count(bar) as b, min(bar) as mi, min(time) as mt, max(time) as mat from cpu order by t, c, b, mi, mt, mat;
+---+---+---+----+--------------------------------+--------------------------------+
| t | c | b | mi | mt | mat |
+---+---+---+----+--------------------------------+--------------------------------+
| 7 | 7 | 7 | 1 | 1970-01-01T00:00:00.000000040Z | 1970-01-01T00:00:00.000000080Z |
+---+---+---+----+--------------------------------+--------------------------------+
-- SQL: SELECT count(time) from cpu;
+-----------------+
| COUNT(cpu.time) |
+-----------------+
| 7 |
+-----------------+
-- SQL: SELECT count(foo) from cpu;
+----------------+
| COUNT(cpu.foo) |
+----------------+
| 7 |
+----------------+
-- SQL: SELECT count(bar) from cpu;
+----------------+
| COUNT(cpu.bar) |
+----------------+
| 7 |
+----------------+
-- SQL: SELECT count(*) from cpu;
+-----------------+
| COUNT(UInt8(1)) |
+-----------------+
| 7 |
+-----------------+
-- SQL: SELECT min(bar) from cpu;
+--------------+
| MIN(cpu.bar) |
+--------------+
| 1 |
+--------------+
-- SQL: SELECT foo from cpu order by foo;
+-----+
| foo |
+-----+
| me |
| me |
| me |
| me |
| me |
| me |
| you |
+-----+
-- SQL: SELECT time from cpu order by time;
+--------------------------------+
| time |
+--------------------------------+
| 1970-01-01T00:00:00.000000040Z |
| 1970-01-01T00:00:00.000000042Z |
| 1970-01-01T00:00:00.000000050Z |
| 1970-01-01T00:00:00.000000060Z |
| 1970-01-01T00:00:00.000000062Z |
| 1970-01-01T00:00:00.000000070Z |
| 1970-01-01T00:00:00.000000080Z |
+--------------------------------+
-- SQL: SELECT max(bar) from cpu;
+--------------+
| MAX(cpu.bar) |
+--------------+
| 7 |
+--------------+
-- SQL: SELECT min(time), max(time) from cpu;
+--------------------------------+--------------------------------+
| MIN(cpu.time) | MAX(cpu.time) |
+--------------------------------+--------------------------------+
| 1970-01-01T00:00:00.000000040Z | 1970-01-01T00:00:00.000000080Z |
+--------------------------------+--------------------------------+
-- SQL: SELECT * from cpu where bar != 1.0 order by bar, foo, time;
+-----+-----+--------------------------------+
| bar | foo | time |
+-----+-----+--------------------------------+
| 3 | you | 1970-01-01T00:00:00.000000070Z |
| 4 | me | 1970-01-01T00:00:00.000000050Z |
| 5 | me | 1970-01-01T00:00:00.000000060Z |
| 7 | me | 1970-01-01T00:00:00.000000080Z |
+-----+-----+--------------------------------+
-- SQL: SELECT * from cpu where foo = 'me' and bar > 2.0 order by bar, foo, time;
+-----+-----+--------------------------------+
| bar | foo | time |
+-----+-----+--------------------------------+
| 4 | me | 1970-01-01T00:00:00.000000050Z |
| 5 | me | 1970-01-01T00:00:00.000000060Z |
| 7 | me | 1970-01-01T00:00:00.000000080Z |
+-----+-----+--------------------------------+
-- SQL: SELECT * from cpu where bar = 1 order by bar, foo, time;
+-----+-----+--------------------------------+
| bar | foo | time |
+-----+-----+--------------------------------+
| 1 | me | 1970-01-01T00:00:00.000000040Z |
| 1 | me | 1970-01-01T00:00:00.000000042Z |
| 1 | me | 1970-01-01T00:00:00.000000062Z |
+-----+-----+--------------------------------+
-- SQL: SELECT * from cpu where foo = 'me' and (bar > 2 or bar = 1.0) order by bar, foo, time;
+-----+-----+--------------------------------+
| bar | foo | time |
+-----+-----+--------------------------------+
| 1 | me | 1970-01-01T00:00:00.000000040Z |
| 1 | me | 1970-01-01T00:00:00.000000042Z |
| 1 | me | 1970-01-01T00:00:00.000000062Z |
| 4 | me | 1970-01-01T00:00:00.000000050Z |
| 5 | me | 1970-01-01T00:00:00.000000060Z |
| 7 | me | 1970-01-01T00:00:00.000000080Z |
+-----+-----+--------------------------------+
-- SQL: SELECT * from cpu where foo = 'you' and (bar > 3.0 or bar = 1) order by bar, foo, time;
++
++
-- SQL: SELECT min(bar) from cpu where foo = 'me' and (bar > 2 or bar = 1.0);
+--------------+
| MIN(cpu.bar) |
+--------------+
| 1 |
+--------------+
-- SQL: SELECT min(time) from cpu where foo = 'me' and (bar > 2 or bar = 1.0);
+--------------------------------+
| MIN(cpu.time) |
+--------------------------------+
| 1970-01-01T00:00:00.000000040Z |
+--------------------------------+
-- SQL: SELECT count(bar) from cpu where foo = 'me' and (bar > 2 or bar = 1.0);
+----------------+
| COUNT(cpu.bar) |
+----------------+
| 6 |
+----------------+
-- SQL: SELECT count(time) from cpu where foo = 'me' and (bar > 2 or bar = 1.0);
+-----------------+
| COUNT(cpu.time) |
+-----------------+
| 6 |
+-----------------+
-- SQL: SELECT count(*) from cpu where foo = 'me' and (bar > 2 or bar = 1.0);
+-----------------+
| COUNT(UInt8(1)) |
+-----------------+
| 6 |
+-----------------+
-- SQL: SELECT * from cpu where bar >= 1.0 order by bar, foo, time;
+-----+-----+--------------------------------+
| bar | foo | time |
+-----+-----+--------------------------------+
| 1 | me | 1970-01-01T00:00:00.000000040Z |
| 1 | me | 1970-01-01T00:00:00.000000042Z |
| 1 | me | 1970-01-01T00:00:00.000000062Z |
| 3 | you | 1970-01-01T00:00:00.000000070Z |
| 4 | me | 1970-01-01T00:00:00.000000050Z |
| 5 | me | 1970-01-01T00:00:00.000000060Z |
| 7 | me | 1970-01-01T00:00:00.000000080Z |
+-----+-----+--------------------------------+
-- SQL: SELECT foo from cpu where bar >= 1.0 order by foo;
+-----+
| foo |
+-----+
| me |
| me |
| me |
| me |
| me |
| me |
| you |
+-----+
-- SQL: SELECT time, bar from cpu where bar >= 1.0 order by bar, time;
+--------------------------------+-----+
| time | bar |
+--------------------------------+-----+
| 1970-01-01T00:00:00.000000040Z | 1 |
| 1970-01-01T00:00:00.000000042Z | 1 |
| 1970-01-01T00:00:00.000000062Z | 1 |
| 1970-01-01T00:00:00.000000070Z | 3 |
| 1970-01-01T00:00:00.000000050Z | 4 |
| 1970-01-01T00:00:00.000000060Z | 5 |
| 1970-01-01T00:00:00.000000080Z | 7 |
+--------------------------------+-----+
-- SQL: SELECT * from cpu where foo = 'you' order by bar, foo, time;
+-----+-----+--------------------------------+
| bar | foo | time |
+-----+-----+--------------------------------+
| 3 | you | 1970-01-01T00:00:00.000000070Z |
+-----+-----+--------------------------------+
-- SQL: SELECT min(bar) as mi, max(time) as ma from cpu where foo = 'you' order by mi, ma;
+----+--------------------------------+
| mi | ma |
+----+--------------------------------+
| 3 | 1970-01-01T00:00:00.000000070Z |
+----+--------------------------------+

View File

@ -0,0 +1,75 @@
-- Demonstrate soft deleted rows will not be return to queries
-- IOX_SETUP: ThreeDeleteThreeChunks
-- select *
SELECT * from cpu order by foo, bar, time;
SELECT time, bar from cpu order by bar, time;
SELECT bar from cpu order by bar;
SELECT count(time) as t, count(*) as c, count(bar) as b, min(bar) as mi, min(time) as mt, max(time) as mat from cpu order by t, c, b, mi, mt, mat;
SELECT count(time) from cpu;
SELECT count(foo) from cpu;
SELECT count(bar) from cpu;
SELECT count(*) from cpu;
SELECT min(bar) from cpu;
SELECT foo from cpu order by foo;
-- BUG: https://github.com/influxdata/influxdb_iox/issues/2776
-- SELECT min(foo) from cpu;
-- SELECT max(foo) from cpu
-- BUG: https://github.com/influxdata/influxdb_iox/issues/2779
-- inconsistent format returned
-- SELECT min(time) from cpu;
-- SELECT max(time) from cpu;
SELECT time from cpu order by time;
SELECT max(bar) from cpu;
SELECT min(time), max(time) from cpu;
--------------------------------------------------------
-- With selection predicate
SELECT * from cpu where bar != 1.0 order by bar, foo, time;
SELECT * from cpu where foo = 'me' and bar > 2.0 order by bar, foo, time;
SELECT * from cpu where bar = 1 order by bar, foo, time;
SELECT * from cpu where foo = 'me' and (bar > 2 or bar = 1.0) order by bar, foo, time;
SELECT * from cpu where foo = 'you' and (bar > 3.0 or bar = 1) order by bar, foo, time;
SELECT min(bar) from cpu where foo = 'me' and (bar > 2 or bar = 1.0);
-- BUG: https://github.com/influxdata/influxdb_iox/issues/2779
-- SELECT max(foo) from cpu where foo = 'me' and (bar > 2 or bar = 1.0);
SELECT min(time) from cpu where foo = 'me' and (bar > 2 or bar = 1.0);
SELECT count(bar) from cpu where foo = 'me' and (bar > 2 or bar = 1.0);
SELECT count(time) from cpu where foo = 'me' and (bar > 2 or bar = 1.0);
SELECT count(*) from cpu where foo = 'me' and (bar > 2 or bar = 1.0);
----------
SELECT * from cpu where bar >= 1.0 order by bar, foo, time;
SELECT foo from cpu where bar >= 1.0 order by foo;
SELECT time, bar from cpu where bar >= 1.0 order by bar, time;
SELECT * from cpu where foo = 'you' order by bar, foo, time;
SELECT min(bar) as mi, max(time) as ma from cpu where foo = 'you' order by mi, ma;

View File

@ -0,0 +1,34 @@
-- Test Setup: TwoDeletesMultiExprsOneChunk
-- SQL: SELECT * from cpu;
+-----+-----+--------------------------------+
| bar | foo | time |
+-----+-----+--------------------------------+
| 1 | me | 1970-01-01T00:00:00.000000040Z |
+-----+-----+--------------------------------+
-- SQL: SELECT foo from cpu;
+-----+
| foo |
+-----+
| me |
+-----+
-- SQL: SELECT * from cpu where cast(time as bigint) > 30;
+-----+-----+--------------------------------+
| bar | foo | time |
+-----+-----+--------------------------------+
| 1 | me | 1970-01-01T00:00:00.000000040Z |
+-----+-----+--------------------------------+
-- SQL: SELECT count(bar) from cpu where cast(time as bigint) > 30;
+----------------+
| COUNT(cpu.bar) |
+----------------+
| 1 |
+----------------+
-- SQL: SELECT * from cpu where cast(time as bigint) > 40;
++
++
-- SQL: SELECT max(time) from cpu where cast(time as bigint) > 40;
+---------------+
| MAX(cpu.time) |
+---------------+
| |
+---------------+

View File

@ -0,0 +1,15 @@
-- Demonstrate soft deleted rows will not be return to queries
-- IOX_SETUP: TwoDeletesMultiExprsOneChunk
-- select *
SELECT * from cpu;
SELECT foo from cpu;
SELECT * from cpu where cast(time as bigint) > 30;
SELECT count(bar) from cpu where cast(time as bigint) > 30;
SELECT * from cpu where cast(time as bigint) > 40;
SELECT max(time) from cpu where cast(time as bigint) > 40;

View File

@ -32,6 +32,76 @@ async fn test_cases_chunk_order_sql() {
.expect("flush worked");
}
#[tokio::test]
// Tests from "delete_all.sql",
async fn test_cases_delete_all_sql() {
let input_path = Path::new("cases").join("in").join("delete_all.sql");
let mut runner = Runner::new();
runner
.run(input_path)
.await
.expect("test failed");
runner
.flush()
.expect("flush worked");
}
#[tokio::test]
// Tests from "delete_multi_expr_one_chunk.sql",
async fn test_cases_delete_multi_expr_one_chunk_sql() {
let input_path = Path::new("cases").join("in").join("delete_multi_expr_one_chunk.sql");
let mut runner = Runner::new();
runner
.run(input_path)
.await
.expect("test failed");
runner
.flush()
.expect("flush worked");
}
#[tokio::test]
// Tests from "delete_simple_pred_one_chunk.sql",
async fn test_cases_delete_simple_pred_one_chunk_sql() {
let input_path = Path::new("cases").join("in").join("delete_simple_pred_one_chunk.sql");
let mut runner = Runner::new();
runner
.run(input_path)
.await
.expect("test failed");
runner
.flush()
.expect("flush worked");
}
#[tokio::test]
// Tests from "delete_three_delete_three_chunks.sql",
async fn test_cases_delete_three_delete_three_chunks_sql() {
let input_path = Path::new("cases").join("in").join("delete_three_delete_three_chunks.sql");
let mut runner = Runner::new();
runner
.run(input_path)
.await
.expect("test failed");
runner
.flush()
.expect("flush worked");
}
#[tokio::test]
// Tests from "delete_two_del_multi_expr_one_chunk.sql",
async fn test_cases_delete_two_del_multi_expr_one_chunk_sql() {
let input_path = Path::new("cases").join("in").join("delete_two_del_multi_expr_one_chunk.sql");
let mut runner = Runner::new();
runner
.run(input_path)
.await
.expect("test failed");
runner
.flush()
.expect("flush worked");
}
#[tokio::test]
// Tests from "duplicates.sql",
async fn test_cases_duplicates_sql() {

View File

@ -2,7 +2,10 @@
#[cfg(test)]
use super::util::run_series_set_plan;
use crate::scenarios::{DbScenario, DbSetup, NoData, TwoMeasurements, TwoMeasurementsManyFields, util::all_scenarios_for_one_chunk};
use crate::scenarios::{
util::all_scenarios_for_one_chunk, DbScenario, DbSetup, NoData, TwoMeasurements,
TwoMeasurementsManyFields, TwoMeasurementsWithDelete,
};
use async_trait::async_trait;
use datafusion::logical_plan::{col, lit};
use predicate::predicate::{Predicate, PredicateBuilder, EMPTY_PREDICATE};
@ -264,6 +267,17 @@ async fn test_read_filter_data_pred_refers_to_non_existent_column() {
run_read_filter_test_case(TwoMeasurements {}, predicate, expected_results).await;
}
#[tokio::test]
async fn test_read_filter_data_pred_refers_to_non_existent_column_with_delete() {
let predicate = PredicateBuilder::default()
.add_expr(col("tag_not_in_h20").eq(lit("foo")))
.build();
let expected_results = vec![] as Vec<&str>;
run_read_filter_test_case(TwoMeasurementsWithDelete {}, predicate, expected_results).await;
}
#[tokio::test]
async fn test_read_filter_data_pred_no_columns() {
// predicate with no columns,
@ -306,6 +320,47 @@ async fn test_read_filter_data_pred_no_columns() {
run_read_filter_test_case(TwoMeasurements {}, predicate, expected_results).await;
}
#[tokio::test]
async fn test_read_filter_data_pred_no_columns_with_delete() {
// predicate with no columns,
let predicate = PredicateBuilder::default()
.add_expr(lit("foo").eq(lit("foo")))
.build();
let expected_results = vec![
"SeriesSet",
"table_name: cpu",
"tags",
" (region, west)",
"field_indexes:",
" (value_index: 1, timestamp_index: 2)",
"start_row: 0",
"num_rows: 1",
"Batches:",
"+--------+------+--------------------------------+",
"| region | user | time |",
"+--------+------+--------------------------------+",
"| west | 23.2 | 1970-01-01T00:00:00.000000100Z |",
"+--------+------+--------------------------------+",
"SeriesSet",
"table_name: disk",
"tags",
" (region, east)",
"field_indexes:",
" (value_index: 1, timestamp_index: 2)",
"start_row: 0",
"num_rows: 1",
"Batches:",
"+--------+-------+--------------------------------+",
"| region | bytes | time |",
"+--------+-------+--------------------------------+",
"| east | 99 | 1970-01-01T00:00:00.000000200Z |",
"+--------+-------+--------------------------------+",
];
run_read_filter_test_case(TwoMeasurementsWithDelete {}, predicate, expected_results).await;
}
#[tokio::test]
async fn test_read_filter_data_pred_refers_to_good_and_non_existent_columns() {
// predicate with both a column that does and does not appear

View File

@ -1,5 +1,7 @@
//! Tests for the Influx gRPC queries
use crate::scenarios::{DbScenario, DbSetup, NoData, make_two_chunk_scenarios, util::all_scenarios_for_one_chunk};
use crate::scenarios::{
make_two_chunk_scenarios, util::all_scenarios_for_one_chunk, DbScenario, DbSetup, NoData,
};
use arrow_util::display::pretty_format_batches;
use async_trait::async_trait;
@ -88,7 +90,7 @@ impl DbSetup for OneMeasurementNoTags {
}
}
// NGA todo: similar test with deleted data
// NGA todo: similar test with deleted data
#[tokio::test]
async fn test_read_group_data_no_tag_columns() {

View File

@ -246,8 +246,6 @@ impl DbSetup for MeasurementForWindowAggregateMonths {
}
}
#[tokio::test]
async fn test_read_window_aggregate_months() {
let predicate = PredicateBuilder::default().build();

View File

@ -388,10 +388,7 @@ SELECT * from disk;
format!("expected output in {:?}", &expected_path)
);
assert_contains!(&runner_log, "Setup: TwoMeasurements");
assert_contains!(
&runner_log,
"Running scenario"
);
assert_contains!(&runner_log, "Running scenario");
}
#[tokio::test]

View File

@ -6,13 +6,19 @@ pub mod util;
use std::collections::HashMap;
use std::sync::Arc;
use data_types::timestamp::TimestampRange;
use once_cell::sync::OnceCell;
use predicate::delete_expr::DeleteExpr;
use predicate::delete_predicate::DeletePredicate;
use query::QueryChunk;
use async_trait::async_trait;
use delete::ThreeDeleteThreeChunks;
use delete::{
OneDeleteMultiExprsOneChunk, OneDeleteSimpleExprOneChunk, OneDeleteSimpleExprOneChunkDeleteAll,
ThreeDeleteThreeChunks, TwoDeletesMultiExprsOneChunk,
};
use server::db::{LockableChunk, LockablePartition};
use server::utils::{
count_mutable_buffer_chunks, count_object_store_chunks, count_read_buffer_chunks, make_db,
@ -60,6 +66,10 @@ pub fn get_all_setups() -> &'static HashMap<String, Arc<dyn DbSetup>> {
register_setup!(OneMeasurementAllChunksDropped),
register_setup!(ChunkOrder),
register_setup!(ThreeDeleteThreeChunks),
register_setup!(OneDeleteSimpleExprOneChunkDeleteAll),
register_setup!(OneDeleteSimpleExprOneChunk),
register_setup!(OneDeleteMultiExprsOneChunk),
register_setup!(TwoDeletesMultiExprsOneChunk),
]
.into_iter()
.map(|(name, setup)| (name.to_string(), setup as Arc<dyn DbSetup>))
@ -260,11 +270,91 @@ impl DbSetup for TwoMeasurements {
];
// return all possible scenarios a chunk: MUB open, MUB frozen, RUB, RUB & OS, OS
all_scenarios_for_one_chunk(vec![], vec![], lp_lines, "disk", partition_key).await
all_scenarios_for_one_chunk(vec![], vec![], lp_lines, "cpu", partition_key).await
}
}
// NGA todo: similar test with deleted data
/// Two measurements data in different chunk scenarios
/// with one delete applied at different stages of the chunk
#[derive(Debug)]
pub struct TwoMeasurementsWithDelete {}
#[async_trait]
impl DbSetup for TwoMeasurementsWithDelete {
async fn make(&self) -> Vec<DbScenario> {
let partition_key = "1970-01-01T00";
let lp_lines = vec![
"cpu,region=west user=23.2 100",
"cpu,region=west user=21.0 150",
"disk,region=east bytes=99i 200",
];
// pred: delete from cpu where 120 <= time <= 160 and region="west"
let table_name = "cpu";
let pred = DeletePredicate {
range: TimestampRange {
start: 120,
end: 160,
},
exprs: vec![DeleteExpr::new(
"region".to_string(),
predicate::delete_expr::Op::Eq,
predicate::delete_expr::Scalar::String("west".to_string()),
)],
};
// return all possible combination scenarios of a chunk stage and when the delete predicates are applied
all_scenarios_for_one_chunk(vec![&pred], vec![], lp_lines, table_name, partition_key).await
}
}
/// Two measurements data in different chunk scenarios
/// with 2 deletes that remove all data from one table
#[derive(Debug)]
pub struct TwoMeasurementsWithDeleteAll {}
#[async_trait]
impl DbSetup for TwoMeasurementsWithDeleteAll {
async fn make(&self) -> Vec<DbScenario> {
let partition_key = "1970-01-01T00";
let lp_lines = vec![
"cpu,region=west user=23.2 100",
"cpu,region=west user=21.0 150",
"disk,region=east bytes=99i 200",
];
// pred: delete from cpu where 120 <= time <= 160 and region="west"
// which will delete second row of the cpu
let table_name = "cpu";
let pred1 = DeletePredicate {
range: TimestampRange {
start: 120,
end: 160,
},
exprs: vec![DeleteExpr::new(
"region".to_string(),
predicate::delete_expr::Op::Eq,
predicate::delete_expr::Scalar::String("west".to_string()),
)],
};
// delete the first row of the cpu
let pred2 = DeletePredicate {
range: TimestampRange { start: 0, end: 110 },
exprs: vec![],
};
// return all possible combination scenarios of a chunk stage and when the delete predicates are applied
all_scenarios_for_one_chunk(
vec![&pred1],
vec![&pred2],
lp_lines,
table_name,
partition_key,
)
.await
}
}
#[derive(Debug)]
pub struct TwoMeasurementsUnsignedTypeMubScenario {}

View File

@ -6,7 +6,10 @@ use predicate::delete_predicate::DeletePredicate;
use async_trait::async_trait;
use crate::scenarios::util::{ChunkData, ChunkStage, all_scenarios_for_one_chunk, make_different_stage_chunks_with_deletes_scenario};
use crate::scenarios::util::{
all_scenarios_for_one_chunk, make_different_stage_chunks_with_deletes_scenario, ChunkData,
ChunkStage,
};
use super::{DbScenario, DbSetup};
@ -33,8 +36,7 @@ impl DbSetup for OneDeleteSimpleExprOneChunkDeleteAll {
};
// this returns 15 scenarios
all_scenarios_for_one_chunk(vec![&pred], vec![], lp_lines, table_name, partition_key)
.await
all_scenarios_for_one_chunk(vec![&pred], vec![], lp_lines, table_name, partition_key).await
}
}
@ -61,8 +63,7 @@ impl DbSetup for OneDeleteSimpleExprOneChunk {
};
// this returns 15 scenarios
all_scenarios_for_one_chunk(vec![&pred], vec![], lp_lines, table_name, partition_key)
.await
all_scenarios_for_one_chunk(vec![&pred], vec![], lp_lines, table_name, partition_key).await
}
}
@ -84,8 +85,7 @@ impl DbSetup for NoDeleteOneChunk {
];
// this returns 15 scenarios
all_scenarios_for_one_chunk(vec![], vec![], lp_lines, table_name, partition_key)
.await
all_scenarios_for_one_chunk(vec![], vec![], lp_lines, table_name, partition_key).await
}
}
@ -122,8 +122,7 @@ impl DbSetup for OneDeleteMultiExprsOneChunk {
};
// this returns 15 scenarios
all_scenarios_for_one_chunk(vec![&pred], vec![], lp_lines, table_name, partition_key)
.await
all_scenarios_for_one_chunk(vec![&pred], vec![], lp_lines, table_name, partition_key).await
}
}
@ -408,4 +407,3 @@ impl DbSetup for ThreeDeleteThreeChunks {
]
}
}

View File

@ -10,8 +10,7 @@ use server::utils::make_db;
use super::DbScenario;
// Structs, enums, and functions used to exhaust all test scenarios of chunk life cycle
// Structs, enums, and functions used to exhaust all test scenarios of chunk life cycle
// & when delete predicates are applied
// STRUCTs & ENUMs
@ -138,7 +137,9 @@ pub async fn all_scenarios_for_one_chunk(
// But only need to get all delete time if chunk_stage_preds is not empty,
// otherwise, produce only one scenario of each chunk stage
let mut delete_times = vec![DeleteTime::Mubo];
if !chunk_stage_preds.is_empty() { delete_times = DeleteTime::all_from_and_before(chunk_stage.clone()) } ;
if !chunk_stage_preds.is_empty() {
delete_times = DeleteTime::all_from_and_before(chunk_stage.clone())
};
for delete_time in delete_times {
// make delete predicate with time it happens
@ -183,7 +184,8 @@ pub async fn make_chunk_with_deletes_at_different_stages(
// ----------
// Make an open MUB
write_lp(&db, &lp_lines.join("\n")).await;
// There may be more than one tables in the lp data
let _tables = write_lp(&db, &lp_lines.join("\n")).await;
// 0 does not represent the real chunk id. It is here just to initialize the chunk_id variable for later assignment
let mut chunk_id = db.chunk_summaries().unwrap()[0].id;
// Apply delete predicate
@ -237,6 +239,7 @@ pub async fn make_chunk_with_deletes_at_different_stages(
// Move MUB to RUB
match chunk_stage {
ChunkStage::Rub | ChunkStage::RubOs | ChunkStage::Os => {
println!(" === MUB -> RUB chunk_id = {}", chunk_id);
let chunk_result = db
.compact_chunks(table_name, partition_key, |chunk| chunk.id() == chunk_id)
.await

View File

@ -881,268 +881,6 @@ async fn sql_select_all_different_tags_chunks() {
}
// ----------------------------------------------
// Delete tests
#[tokio::test]
async fn sql_select_with_delete_from_one_expr_delete_all() {
// select *
let expected = vec!["++", "++"];
run_sql_test_case(
scenarios::delete::OneDeleteSimpleExprOneChunkDeleteAll {},
"SELECT * from cpu",
&expected,
)
.await;
// select a specific column
run_sql_test_case(
scenarios::delete::OneDeleteSimpleExprOneChunkDeleteAll {},
"SELECT time from cpu",
&expected,
)
.await;
// Count
let expected = vec![
"+-----------------+----------------+-----------------+",
"| COUNT(UInt8(1)) | COUNT(cpu.bar) | COUNT(cpu.time) |",
"+-----------------+----------------+-----------------+",
"| 0 | 0 | 0 |",
"+-----------------+----------------+-----------------+",
];
run_sql_test_case(
scenarios::delete::OneDeleteSimpleExprOneChunkDeleteAll {},
"SELECT count(*), count(bar), count(time) from cpu",
&expected,
)
.await;
// Min & Max
let expected = vec![
"+--------------+--------------+---------------+---------------+",
"| MIN(cpu.bar) | MAX(cpu.bar) | MIN(cpu.time) | MAX(cpu.time) |",
"+--------------+--------------+---------------+---------------+",
"| | | | |",
"+--------------+--------------+---------------+---------------+",
];
run_sql_test_case(
scenarios::delete::OneDeleteSimpleExprOneChunkDeleteAll {},
"SELECT min(bar), max(bar), min(time), max(time) from cpu",
&expected,
)
.await;
}
// --------------------------------------------------------
#[tokio::test]
async fn sql_select_with_delete_from_one_expr() {
let expected = vec![
"+-----+--------------------------------+",
"| bar | time |",
"+-----+--------------------------------+",
"| 2 | 1970-01-01T00:00:00.000000020Z |",
"+-----+--------------------------------+",
];
run_sql_test_case(
scenarios::delete::OneDeleteSimpleExprOneChunk {},
"SELECT * from cpu",
&expected,
)
.await;
// select all explicit columns
let expected = vec![
"+--------------------------------+-----+",
"| time | bar |",
"+--------------------------------+-----+",
"| 1970-01-01T00:00:00.000000020Z | 2 |",
"+--------------------------------+-----+",
];
run_sql_test_case(
scenarios::delete::OneDeleteSimpleExprOneChunk {},
"SELECT time, bar from cpu",
&expected,
)
.await;
}
// --------------------------------------------------------
#[tokio::test]
async fn sql_select_with_delete_from_one_expr_min_max() {
// Min & Max of bar only
let expected = vec![
"+--------------+--------------+",
"| MIN(cpu.bar) | MAX(cpu.bar) |",
"+--------------+--------------+",
"| 2 | 2 |",
"+--------------+--------------+",
];
run_sql_test_case(
scenarios::delete::OneDeleteSimpleExprOneChunk {},
"SELECT min(bar), max(bar) from cpu",
&expected,
)
.await;
}
#[tokio::test]
async fn sql_select_with_delete_from_one_expr_time() {
// one column, time, and no cover all 2 columns, time and bar, of the delete predicate
let expected = vec![
"+--------------------------------+",
"| time |",
"+--------------------------------+",
"| 1970-01-01T00:00:00.000000020Z |",
"+--------------------------------+",
];
run_sql_test_case(
scenarios::delete::OneDeleteSimpleExprOneChunk {},
"SELECT time from cpu",
&expected,
)
.await;
}
// BUG: https://github.com/influxdata/influxdb_iox/issues/2779
// inconsistent format returned
#[ignore]
#[tokio::test]
async fn sql_select_with_delete_from_one_expr_max_time() {
// max on one column and no cover all 2 columns, time and bar, of the delete predicate
let expected = vec![
"+--------------------------------+",
"| MAX(cpu.time) |",
"+--------------------------------+",
"| 1970-01-01T00:00:00.000000020Z |",
"+--------------------------------+",
];
run_sql_test_case(
scenarios::delete::OneDeleteSimpleExprOneChunk {},
"SELECT max(time) from cpu",
&expected,
)
.await;
}
#[tokio::test]
async fn sql_select_with_delete_from_one_expr_count_max_time() {
// Count and max on one column and no cover all 2 columns, time and bar, of the delete predicate
let expected = vec![
"+-----------------+--------------------------------+",
"| COUNT(cpu.time) | MAX(cpu.time) |",
"+-----------------+--------------------------------+",
"| 1 | 1970-01-01T00:00:00.000000020Z |",
"+-----------------+--------------------------------+",
];
run_sql_test_case(
scenarios::delete::OneDeleteSimpleExprOneChunk {},
"SELECT count(time), max(time) from cpu",
&expected,
)
.await;
}
#[tokio::test]
async fn sql_select_with_delete_from_one_expr_count_time() {
// Count and max on one column and no cover all 2 columns, time and bar, of the delete predicate
let expected = vec![
"+-----------------+",
"| COUNT(cpu.time) |",
"+-----------------+",
"| 1 |",
"+-----------------+",
];
run_sql_test_case(
scenarios::delete::OneDeleteSimpleExprOneChunk {},
"SELECT count(time) from cpu",
&expected,
)
.await;
}
// --------------------------------------------------------
#[tokio::test]
async fn sql_select_with_delete_from_one_expr_with_select_predicate() {
// Select predicate does not eliminate extra rows
let expected = vec![
"+-----+--------------------------------+",
"| bar | time |",
"+-----+--------------------------------+",
"| 2 | 1970-01-01T00:00:00.000000020Z |",
"+-----+--------------------------------+",
];
run_sql_test_case(
scenarios::delete::OneDeleteSimpleExprOneChunk {},
"SELECT * from cpu where bar = 2.0",
&expected,
)
.await;
// Select predicate eliminates rows
let expected = vec!["++", "++"];
run_sql_test_case(
scenarios::delete::OneDeleteSimpleExprOneChunk {},
"SELECT * from cpu where bar != 2.0",
&expected,
)
.await;
// Count, min and max
let expected = vec![
"+-----------------+-----------------+----------------+--------------+--------------+--------------------------------+--------------------------------+",
"| COUNT(cpu.time) | COUNT(UInt8(1)) | COUNT(cpu.bar) | MIN(cpu.bar) | MAX(cpu.bar) | MIN(cpu.time) | MAX(cpu.time) |",
"+-----------------+-----------------+----------------+--------------+--------------+--------------------------------+--------------------------------+",
"| 1 | 1 | 1 | 2 | 2 | 1970-01-01T00:00:00.000000020Z | 1970-01-01T00:00:00.000000020Z |",
"+-----------------+-----------------+----------------+--------------+--------------+--------------------------------+--------------------------------+",
];
run_sql_test_case(
scenarios::delete::OneDeleteSimpleExprOneChunk {},
"SELECT count(time), count(*), count(bar), min(bar), max(bar), min(time), max(time) from cpu",
&expected,
)
.await;
}
// --------------------------------------------------------
#[tokio::test]
async fn sql_select_with_delete_from_multi_exprs() {
let expected = vec![
"+-----+-----+--------------------------------+",
"| bar | foo | time |",
"+-----+-----+--------------------------------+",
"| 1 | me | 1970-01-01T00:00:00.000000040Z |",
"| 2 | you | 1970-01-01T00:00:00.000000020Z |",
"+-----+-----+--------------------------------+",
];
run_sql_test_case(
scenarios::delete::OneDeleteMultiExprsOneChunk {},
"SELECT * from cpu",
&expected,
)
.await;
// select one column, delete predicates on all 3 columns of the table
let expected = vec![
"+-----+", "| bar |", "+-----+", "| 1 |", "| 2 |", "+-----+",
];
run_sql_test_case(
scenarios::delete::OneDeleteMultiExprsOneChunk {},
"SELECT bar from cpu",
&expected,
)
.await;
}
// --------------------------------------------------------
// tests without delete
#[tokio::test]
async fn sql_select_without_delete_agg() {
@ -1201,690 +939,3 @@ async fn sql_select_without_delete_min_foo() {
}
// --------------------------------------------------------
#[tokio::test]
async fn sql_select_with_delete_from_multi_exprs_agg() {
// Count, min and max on many columns but not `foo` that is included in delete predicate
let expected = vec![
"+-----------------+-----------------+----------------+--------------+--------------+--------------------------------+--------------------------------+",
"| COUNT(cpu.time) | COUNT(UInt8(1)) | COUNT(cpu.bar) | MIN(cpu.bar) | MAX(cpu.bar) | MIN(cpu.time) | MAX(cpu.time) |",
"+-----------------+-----------------+----------------+--------------+--------------+--------------------------------+--------------------------------+",
"| 2 | 2 | 2 | 1 | 2 | 1970-01-01T00:00:00.000000020Z | 1970-01-01T00:00:00.000000040Z |",
"+-----------------+-----------------+----------------+--------------+--------------+--------------------------------+--------------------------------+",
];
run_sql_test_case(
scenarios::delete::OneDeleteMultiExprsOneChunk {},
"SELECT count(time), count(*), count(bar), min(bar), max(bar), min(time), max(time) from cpu",
&expected,
)
.await;
}
#[tokio::test]
async fn sql_select_with_delete_from_multi_exprs_count_time() {
// Count, min and max on many columns but not `foo` that is included in delete predicate
let expected = vec![
"+-----------------+",
"| COUNT(cpu.time) |",
"+-----------------+",
"| 2 |",
"+-----------------+",
];
run_sql_test_case(
scenarios::delete::OneDeleteMultiExprsOneChunk {},
"SELECT count(time) from cpu",
&expected,
)
.await;
}
#[tokio::test]
async fn sql_select_with_delete_from_multi_exprs_count_foo() {
let expected = vec![
"+----------------+",
"| COUNT(cpu.foo) |",
"+----------------+",
"| 2 |",
"+----------------+",
];
// OneDeleteMultiExprsOneChunk's delete predicates include columns foo, bar and time
run_sql_test_case(
scenarios::delete::OneDeleteMultiExprsOneChunk {},
"SELECT count(foo) from cpu",
&expected,
)
.await;
}
#[tokio::test]
async fn sql_select_with_delete_from_multi_exprs_count_bar() {
let expected = vec![
"+----------------+",
"| COUNT(cpu.bar) |",
"+----------------+",
"| 2 |",
"+----------------+",
];
// OneDeleteMultiExprsOneChunk's delete predicates include columns foo, bar and time
run_sql_test_case(
scenarios::delete::OneDeleteMultiExprsOneChunk {},
"SELECT count(bar) from cpu",
&expected,
)
.await;
}
#[tokio::test]
async fn sql_select_with_delete_from_multi_exprs_count_star() {
let expected = vec![
"+-----------------+",
"| COUNT(UInt8(1)) |",
"+-----------------+",
"| 2 |",
"+-----------------+",
];
run_sql_test_case(
scenarios::delete::OneDeleteMultiExprsOneChunk {},
"SELECT count(*) from cpu",
&expected,
)
.await;
}
#[tokio::test]
async fn sql_select_with_delete_from_multi_exprs_min_bar() {
let expected = vec![
"+--------------+",
"| MIN(cpu.bar) |",
"+--------------+",
"| 1 |",
"+--------------+",
];
run_sql_test_case(
scenarios::delete::OneDeleteMultiExprsOneChunk {},
"SELECT min(bar) from cpu",
&expected,
)
.await;
}
// BUG: https://github.com/influxdata/influxdb_iox/issues/2776
#[ignore]
#[tokio::test]
async fn sql_select_with_delete_from_multi_exprs_min_foo() {
let expected = vec![
"+--------------+",
"| MIN(cpu.foo) |",
"+--------------+",
"| me |",
"+--------------+",
];
run_sql_test_case(
scenarios::delete::OneDeleteMultiExprsOneChunk {},
"SELECT min(foo) from cpu",
&expected,
)
.await;
}
#[tokio::test]
async fn sql_select_with_delete_from_multi_exprs_foo() {
let expected = vec![
"+-----+", "| foo |", "+-----+", "| me |", "| you |", "+-----+",
];
run_sql_test_case(
scenarios::delete::OneDeleteMultiExprsOneChunk {},
"SELECT foo from cpu",
&expected,
)
.await;
}
// BUG: https://github.com/influxdata/influxdb_iox/issues/2779
// inconsistent format returned
#[ignore]
#[tokio::test]
async fn sql_select_with_delete_from_multi_exprs_min_time() {
let expected = vec![
"+--------------------------------+",
"| MIN(cpu.time) |",
"+--------------------------------+",
"| 1970-01-01T00:00:00.000000020Z |",
"+--------------------------------+",
];
run_sql_test_case(
scenarios::delete::OneDeleteMultiExprsOneChunk {},
"SELECT min(time) from cpu",
&expected,
)
.await;
}
#[tokio::test]
async fn sql_select_with_delete_from_multi_exprs_time() {
let expected = vec![
"+--------------------------------+",
"| time |",
"+--------------------------------+",
"| 1970-01-01T00:00:00.000000020Z |",
"| 1970-01-01T00:00:00.000000040Z |",
"+--------------------------------+",
];
run_sql_test_case(
scenarios::delete::OneDeleteMultiExprsOneChunk {},
"SELECT time from cpu",
&expected,
)
.await;
}
#[tokio::test]
async fn sql_select_with_delete_from_multi_exprs_max_bar() {
let expected = vec![
"+--------------+",
"| MAX(cpu.bar) |",
"+--------------+",
"| 2 |",
"+--------------+",
];
run_sql_test_case(
scenarios::delete::OneDeleteMultiExprsOneChunk {},
"SELECT max(bar) from cpu",
&expected,
)
.await;
}
// BUG: https://github.com/influxdata/influxdb_iox/issues/2776
#[ignore]
#[tokio::test]
async fn sql_select_with_delete_from_multi_exprs_max_foo() {
let expected = vec![
"+----------------+",
"| COUNT(cpu.foo) |",
"+----------------+",
"| 2 |",
"+----------------+",
];
run_sql_test_case(
scenarios::delete::OneDeleteMultiExprsOneChunk {},
"SELECT max(foo) from cpu",
&expected,
)
.await;
}
// BUG: https://github.com/influxdata/influxdb_iox/issues/2779
// inconsistent format returned
#[ignore]
#[tokio::test]
async fn sql_select_with_delete_from_multi_exprs_max_time() {
let expected = vec![
"+--------------------------------+",
"| MAX(cpu.time) |",
"+--------------------------------+",
"| 1970-01-01T00:00:00.000000040Z |",
"+--------------------------------+",
];
run_sql_test_case(
scenarios::delete::OneDeleteMultiExprsOneChunk {},
"SELECT max(time) from cpu",
&expected,
)
.await;
}
// --------------------------------------------------------
#[tokio::test]
async fn sql_select_with_delete_from_multi_exprs_with_select_predicate() {
// not eliminate extra row
let expected = vec![
"+-----+-----+--------------------------------+",
"| bar | foo | time |",
"+-----+-----+--------------------------------+",
"| 1 | me | 1970-01-01T00:00:00.000000040Z |",
"| 2 | you | 1970-01-01T00:00:00.000000020Z |",
"+-----+-----+--------------------------------+",
];
run_sql_test_case(
scenarios::delete::OneDeleteMultiExprsOneChunk {},
"SELECT * from cpu where bar >= 1.0",
&expected,
)
.await;
// eliminate something
let expected = vec![
"+-----+-----+--------------------------------+",
"| bar | foo | time |",
"+-----+-----+--------------------------------+",
"| 2 | you | 1970-01-01T00:00:00.000000020Z |",
"+-----+-----+--------------------------------+",
];
run_sql_test_case(
scenarios::delete::OneDeleteMultiExprsOneChunk {},
"SELECT * from cpu where foo = 'you'",
&expected,
)
.await;
// eliminate all
let expected = vec!["++", "++"];
run_sql_test_case(
scenarios::delete::OneDeleteMultiExprsOneChunk {},
"SELECT * from cpu where foo = 'you' and bar > 2.0",
&expected,
)
.await;
}
#[tokio::test]
async fn sql_select_with_two_deletes_from_multi_exprs() {
let expected = vec![
"+-----+-----+--------------------------------+",
"| bar | foo | time |",
"+-----+-----+--------------------------------+",
"| 1 | me | 1970-01-01T00:00:00.000000040Z |",
"+-----+-----+--------------------------------+",
];
run_sql_test_case(
scenarios::delete::TwoDeletesMultiExprsOneChunk {},
"SELECT * from cpu",
&expected,
)
.await;
}
#[tokio::test]
async fn sql_select_with_two_deletes_from_multi_exprs_with_select_predicate() {
// no extra eliminated
let expected = vec![
"+-----+-----+--------------------------------+",
"| bar | foo | time |",
"+-----+-----+--------------------------------+",
"| 1 | me | 1970-01-01T00:00:00.000000040Z |",
"+-----+-----+--------------------------------+",
];
run_sql_test_case(
scenarios::delete::TwoDeletesMultiExprsOneChunk {},
"SELECT * from cpu where cast(time as bigint) > 30",
&expected,
)
.await;
// all eliminated
let expected = vec!["++", "++"];
run_sql_test_case(
scenarios::delete::TwoDeletesMultiExprsOneChunk {},
"SELECT * from cpu where cast(time as bigint) > 40",
&expected,
)
.await;
}
// --------------------------------------------------------
#[tokio::test]
async fn sql_select_with_three_deletes_from_three_chunks() {
let expected = vec![
"+-----+-----+--------------------------------+",
"| bar | foo | time |",
"+-----+-----+--------------------------------+",
"| 1 | me | 1970-01-01T00:00:00.000000040Z |",
"| 1 | me | 1970-01-01T00:00:00.000000042Z |",
"| 1 | me | 1970-01-01T00:00:00.000000062Z |",
"| 3 | you | 1970-01-01T00:00:00.000000070Z |",
"| 4 | me | 1970-01-01T00:00:00.000000050Z |",
"| 5 | me | 1970-01-01T00:00:00.000000060Z |",
"| 7 | me | 1970-01-01T00:00:00.000000080Z |",
"+-----+-----+--------------------------------+",
];
run_sql_test_case(
scenarios::delete::ThreeDeleteThreeChunks {},
"SELECT * from cpu",
&expected,
)
.await;
}
// --------------------------------------------------------
#[tokio::test]
async fn sql_select_with_three_deletes_from_three_chunks_count_star() {
let expected = vec![
"+-----------------+",
"| COUNT(UInt8(1)) |",
"+-----------------+",
"| 7 |",
"+-----------------+",
];
run_sql_test_case(
scenarios::delete::ThreeDeleteThreeChunks {},
"SELECT count(*) from cpu",
&expected,
)
.await;
}
#[tokio::test]
async fn sql_select_with_three_deletes_from_three_chunks_count_time() {
let expected = vec![
"+-----------------+",
"| COUNT(cpu.time) |",
"+-----------------+",
"| 7 |",
"+-----------------+",
];
run_sql_test_case(
scenarios::delete::ThreeDeleteThreeChunks {},
"SELECT count(time) from cpu",
&expected,
)
.await;
}
#[tokio::test]
async fn sql_select_with_three_deletes_from_three_chunks_count_foo() {
let expected = vec![
"+----------------+",
"| COUNT(cpu.foo) |",
"+----------------+",
"| 7 |",
"+----------------+",
];
run_sql_test_case(
scenarios::delete::ThreeDeleteThreeChunks {},
"SELECT count(foo) from cpu",
&expected,
)
.await;
}
#[tokio::test]
async fn sql_select_with_three_deletes_from_three_chunks_count_bar() {
let expected = vec![
"+----------------+",
"| COUNT(cpu.bar) |",
"+----------------+",
"| 7 |",
"+----------------+",
];
run_sql_test_case(
scenarios::delete::ThreeDeleteThreeChunks {},
"SELECT count(bar) from cpu",
&expected,
)
.await;
}
#[tokio::test]
async fn sql_select_with_three_deletes_from_three_chunks_min_bar() {
let expected = vec![
"+--------------+",
"| MIN(cpu.bar) |",
"+--------------+",
"| 1 |",
"+--------------+",
];
run_sql_test_case(
scenarios::delete::ThreeDeleteThreeChunks {},
"SELECT min(bar) from cpu",
&expected,
)
.await;
}
// BUG: https://github.com/influxdata/influxdb_iox/issues/2776
#[ignore]
#[tokio::test]
async fn sql_select_with_three_deletes_from_three_chunks_max_foo() {
let expected = vec![
"+-----+-----+--------------------------------+",
"| bar | foo | time |",
"+-----+-----+--------------------------------+",
"| 7 | me | 1970-01-01T00:00:00.000000080Z |",
"+-----+-----+--------------------------------+",
];
run_sql_test_case(
scenarios::delete::ThreeDeleteThreeChunks {},
"SELECT max(foo) from cpu",
&expected,
)
.await;
}
#[tokio::test]
async fn sql_select_with_three_deletes_from_three_chunks_min_max_time() {
let expected = vec![
"+--------------------------------+--------------------------------+",
"| MIN(cpu.time) | MAX(cpu.time) |",
"+--------------------------------+--------------------------------+",
"| 1970-01-01T00:00:00.000000040Z | 1970-01-01T00:00:00.000000080Z |",
"+--------------------------------+--------------------------------+",
];
run_sql_test_case(
scenarios::delete::ThreeDeleteThreeChunks {},
"SELECT min(time), max(time) from cpu",
&expected,
)
.await;
}
// --------------------------------------------------------
#[tokio::test]
async fn sql_select_with_three_deletes_from_three_chunks_with_select_predicate() {
test_helpers::maybe_start_logging();
let expected = vec![
"+-----+-----+--------------------------------+",
"| bar | foo | time |",
"+-----+-----+--------------------------------+",
"| 3 | you | 1970-01-01T00:00:00.000000070Z |",
"| 4 | me | 1970-01-01T00:00:00.000000050Z |",
"| 5 | me | 1970-01-01T00:00:00.000000060Z |",
"| 7 | me | 1970-01-01T00:00:00.000000080Z |",
"+-----+-----+--------------------------------+",
];
run_sql_test_case(
scenarios::delete::ThreeDeleteThreeChunks {},
"SELECT * from cpu where bar != 1.0",
&expected,
)
.await;
//--------------------
let expected = vec![
"+-----+-----+--------------------------------+",
"| bar | foo | time |",
"+-----+-----+--------------------------------+",
"| 4 | me | 1970-01-01T00:00:00.000000050Z |",
"| 5 | me | 1970-01-01T00:00:00.000000060Z |",
"| 7 | me | 1970-01-01T00:00:00.000000080Z |",
"+-----+-----+--------------------------------+",
];
run_sql_test_case(
scenarios::delete::ThreeDeleteThreeChunks {},
"SELECT * from cpu where foo = 'me' and bar > 2.0",
&expected,
)
.await;
//--------------------
let expected = vec![
"+-----+-----+--------------------------------+",
"| bar | foo | time |",
"+-----+-----+--------------------------------+",
"| 1 | me | 1970-01-01T00:00:00.000000040Z |",
"| 1 | me | 1970-01-01T00:00:00.000000042Z |",
"| 1 | me | 1970-01-01T00:00:00.000000062Z |",
"+-----+-----+--------------------------------+",
];
run_sql_test_case(
scenarios::delete::ThreeDeleteThreeChunks {},
"SELECT * from cpu where bar = 1",
&expected,
)
.await;
//--------------------
// Multi select expressions and eliminate something
let expected = vec![
"+-----+-----+--------------------------------+",
"| bar | foo | time |",
"+-----+-----+--------------------------------+",
"| 1 | me | 1970-01-01T00:00:00.000000040Z |",
"| 1 | me | 1970-01-01T00:00:00.000000042Z |",
"| 1 | me | 1970-01-01T00:00:00.000000062Z |",
"| 4 | me | 1970-01-01T00:00:00.000000050Z |",
"| 5 | me | 1970-01-01T00:00:00.000000060Z |",
"| 7 | me | 1970-01-01T00:00:00.000000080Z |",
"+-----+-----+--------------------------------+",
];
run_sql_test_case(
scenarios::delete::ThreeDeleteThreeChunks {},
"SELECT * from cpu where foo = 'me' and (bar > 2 or bar = 1.0)",
&expected,
)
.await;
//--------------------
// Multi select expressions and eliminate everything
let expected = vec!["++", "++"];
run_sql_test_case(
scenarios::delete::ThreeDeleteThreeChunks {},
"SELECT * from cpu where foo = 'you' and (bar > 3.0 or bar = 1)",
&expected,
)
.await;
}
// --------------------------------------------------------
#[tokio::test]
async fn sql_select_with_three_deletes_from_three_chunks_with_select_predicate_min_bar() {
let expected = vec![
"+--------------+",
"| MIN(cpu.bar) |",
"+--------------+",
"| 1 |",
"+--------------+",
];
run_sql_test_case(
scenarios::delete::ThreeDeleteThreeChunks {},
"SELECT min(bar) from cpu where foo = 'me' and (bar > 2 or bar = 1.0)",
&expected,
)
.await;
}
// BUG: https://github.com/influxdata/influxdb_iox/issues/2776
#[ignore]
#[tokio::test]
async fn sql_select_with_three_deletes_from_three_chunks_with_select_predicate_max_foo() {
let expected = vec![
"+--------------+",
"| MAX(cpu.foo) |",
"+--------------+",
"| me |",
"+--------------+",
];
run_sql_test_case(
scenarios::delete::ThreeDeleteThreeChunks {},
"SELECT max(foo) from cpu where foo = 'me' and (bar > 2 or bar = 1.0)",
&expected,
)
.await;
}
#[tokio::test]
async fn sql_select_with_three_deletes_from_three_chunks_with_select_predicate_min_time() {
let expected = vec![
"+--------------------------------+",
"| MIN(cpu.time) |",
"+--------------------------------+",
"| 1970-01-01T00:00:00.000000040Z |",
"+--------------------------------+",
];
run_sql_test_case(
scenarios::delete::ThreeDeleteThreeChunks {},
"SELECT min(time) from cpu where foo = 'me' and (bar > 2 or bar = 1.0)",
&expected,
)
.await;
}
#[tokio::test]
async fn sql_select_with_three_deletes_from_three_chunks_with_select_predicate_count_bar() {
let expected = vec![
"+----------------+",
"| COUNT(cpu.bar) |",
"+----------------+",
"| 6 |",
"+----------------+",
];
run_sql_test_case(
scenarios::delete::ThreeDeleteThreeChunks {},
"SELECT count(bar) from cpu where foo = 'me' and (bar > 2 or bar = 1.0);",
&expected,
)
.await;
}
#[tokio::test]
async fn sql_select_with_three_deletes_from_three_chunks_with_select_predicate_count_time() {
let expected = vec![
"+-----------------+",
"| COUNT(cpu.time) |",
"+-----------------+",
"| 6 |",
"+-----------------+",
];
run_sql_test_case(
scenarios::delete::ThreeDeleteThreeChunks {},
"SELECT count(time) from cpu where foo = 'me' and (bar > 2 or bar = 1.0);",
&expected,
)
.await;
}
#[tokio::test]
async fn sql_select_with_three_deletes_from_three_chunks_with_select_predicate_count_star() {
let expected = vec![
"+-----------------+",
"| COUNT(UInt8(1)) |",
"+-----------------+",
"| 6 |",
"+-----------------+",
];
run_sql_test_case(
scenarios::delete::ThreeDeleteThreeChunks {},
"SELECT count(*) from cpu where foo = 'me' and (bar > 2 or bar = 1.0);",
&expected,
)
.await;
}

View File

@ -1383,6 +1383,7 @@ pub mod test_helpers {
let mut tables: Vec<_> = tables.into_iter().collect();
tables.sort();
println!(" === lp tables: {:#?}", tables);
Ok(tables)
}