Skip to content

Commit

Permalink
Fix ApacheOnly regression test
Browse files Browse the repository at this point in the history
The recently added test for hypertable detection used compression
which is not available in ApacheOnly tests so we use that test
to regresscheck-t. Additionally we move the other test in
plan_hypertable_cache to plan_expand_hypertable to reduce the number
of tests.
  • Loading branch information
svenklemm committed Sep 18, 2020
1 parent 5179447 commit 1c30363
Show file tree
Hide file tree
Showing 10 changed files with 211 additions and 262 deletions.
38 changes: 38 additions & 0 deletions test/expected/plan_expand_hypertable-11.out
Expand Up @@ -2753,4 +2753,42 @@ SELECT * FROM hyper h WHERE _timescaledb_internal.chunks_in(h, NULL);
(0 rows)

\set ECHO errors
RESET timescaledb.enable_optimizations;
CREATE TABLE test (a int, time timestamptz NOT NULL);
SELECT create_hypertable('public.test', 'time');
create_hypertable
--------------------
(15,public,test,t)
(1 row)

INSERT INTO test SELECT i, '2020-04-01'::date-10-i from generate_series(1,20) i;
CREATE OR REPLACE FUNCTION test_f(_ts timestamptz)
RETURNS SETOF test LANGUAGE SQL STABLE PARALLEL SAFE
AS $f$
SELECT DISTINCT ON (a) * FROM test WHERE time >= _ts ORDER BY a, time DESC
$f$;
EXPLAIN (costs off) SELECT * FROM test_f(now());
QUERY PLAN
-----------------------------------------------------------------
Unique
-> Sort
Sort Key: test.a, test."time" DESC
-> Custom Scan (ChunkAppend) on test
Chunks excluded during startup: 4
-> Index Scan using test_time_idx on test test_1
Index Cond: ("time" >= now())
(7 rows)

EXPLAIN (costs off) SELECT * FROM test_f(now());
QUERY PLAN
-------------------------------------------------
Unique
-> Sort
Sort Key: test.a, test."time" DESC
-> Custom Scan (ChunkAppend) on test
Chunks excluded during startup: 4
-> Seq Scan on test test_1
Filter: ("time" >= now())
(7 rows)

--TEST END--
34 changes: 34 additions & 0 deletions test/expected/plan_expand_hypertable-12.out
Expand Up @@ -2717,4 +2717,38 @@ SELECT * FROM hyper h WHERE _timescaledb_internal.chunks_in(h, NULL);
(0 rows)

\set ECHO errors
RESET timescaledb.enable_optimizations;
CREATE TABLE test (a int, time timestamptz NOT NULL);
SELECT create_hypertable('public.test', 'time');
create_hypertable
--------------------
(15,public,test,t)
(1 row)

INSERT INTO test SELECT i, '2020-04-01'::date-10-i from generate_series(1,20) i;
CREATE OR REPLACE FUNCTION test_f(_ts timestamptz)
RETURNS SETOF test LANGUAGE SQL STABLE PARALLEL SAFE
AS $f$
SELECT DISTINCT ON (a) * FROM test WHERE time >= _ts ORDER BY a, time DESC
$f$;
EXPLAIN (costs off) SELECT * FROM test_f(now());
QUERY PLAN
-------------------------------------------------
Unique
-> Sort
Sort Key: test.a, test."time" DESC
-> Custom Scan (ChunkAppend) on test
Chunks excluded during startup: 4
(5 rows)

EXPLAIN (costs off) SELECT * FROM test_f(now());
QUERY PLAN
-------------------------------------------------
Unique
-> Sort
Sort Key: test.a, test."time" DESC
-> Custom Scan (ChunkAppend) on test
Chunks excluded during startup: 4
(5 rows)

--TEST END--
103 changes: 0 additions & 103 deletions test/expected/plan_hypertable_cache-11.out

This file was deleted.

95 changes: 0 additions & 95 deletions test/expected/plan_hypertable_cache-12.out

This file was deleted.

1 change: 0 additions & 1 deletion test/sql/CMakeLists.txt
Expand Up @@ -123,7 +123,6 @@ set(TEST_TEMPLATES
plan_expand_hypertable.sql.in
#hashagg is different in 9.6 and 10 because of hashagg parallelism
plan_hashagg.sql.in
plan_hypertable_cache.sql.in
query.sql.in
# Query tests differ in how PostgreSQL deals with projections on partitioned tables.
sort_optimization.sql.in
Expand Down
25 changes: 25 additions & 0 deletions test/sql/plan_expand_hypertable.sql.in
Expand Up @@ -30,4 +30,29 @@ SET timescaledb.enable_optimizations TO false;

:DIFF_CMD
\set ECHO queries

RESET timescaledb.enable_optimizations;
-- test hypertable classification when hypertable is not in cache
-- https://github.com/timescale/timescaledb/issues/1832

\set PREFIX 'EXPLAIN (costs off)'

CREATE TABLE test (a int, time timestamptz NOT NULL);
SELECT create_hypertable('public.test', 'time');
INSERT INTO test SELECT i, '2020-04-01'::date-10-i from generate_series(1,20) i;

CREATE OR REPLACE FUNCTION test_f(_ts timestamptz)
RETURNS SETOF test LANGUAGE SQL STABLE PARALLEL SAFE
AS $f$
SELECT DISTINCT ON (a) * FROM test WHERE time >= _ts ORDER BY a, time DESC
$f$;

:PREFIX SELECT * FROM test_f(now());

-- create new session
\c

-- plan output should be identical to previous session
:PREFIX SELECT * FROM test_f(now());

\qecho '--TEST END--'
63 changes: 0 additions & 63 deletions test/sql/plan_hypertable_cache.sql.in

This file was deleted.

0 comments on commit 1c30363

Please sign in to comment.