timescaledb/tsl/test/sql/include/cont_agg_test_equal.sql
Matvey Arye dc0e250428 Add pg_dump/restore tests for continuous aggs
The data in caggs needs to survive dump/restore. This
test makes sure that caggs that are materialized both
before and after restore are correct.

Two code changes were necessary to make this work:
1) the valid_job_type constraint on bgw_job needed to be altered to add
'continuous_aggregate' as a valid job type

2) The user_view_query field needed to be changed to a text because
dump/restore does not support pg_node_tree.
2019-04-26 13:08:00 -04:00

17 lines
658 B
SQL

-- This file and its contents are licensed under the Timescale License.
-- Please see the included NOTICE for copyright information and
-- LICENSE-TIMESCALE for a copy of the license.
--expects QUERY and VIEW_NAME to be set
with original AS (
SELECT row_number() OVER(ORDER BY q.*) row_number, * FROM (:QUERY) as q
),
view AS (
SELECT row_number() OVER (ORDER BY q.*) row_number, * FROM :VIEW_NAME as q
)
SELECT 'Number of rows different between view and original (expect 0)' as description, :'VIEW_NAME' as view_name, count(*)
FROM original
FULL OUTER JOIN view ON (original.row_number = view.row_number)
WHERE (original.*) IS DISTINCT FROM (view.*);