Skip to content

Commit

Permalink
Add pg17 jsonpath methods tests
Browse files Browse the repository at this point in the history
various jsonpath methods were added in PG17
Relevant PG commit: postgres/postgres@66ea94e8e
Here we add the same test as in pg15_jsonpath.sql for the new additions
  • Loading branch information
naisila committed Dec 30, 2024
1 parent 7dc97d3 commit 531acbd
Show file tree
Hide file tree
Showing 2 changed files with 92 additions and 4 deletions.
64 changes: 60 additions & 4 deletions src/test/regress/expected/pg17.out
Original file line number Diff line number Diff line change
Expand Up @@ -1462,12 +1462,68 @@ CREATE TABLE date_partitioned_table(
eventdate date,
measure_data jsonb) PARTITION BY RANGE(eventdate);
SELECT create_time_partitions('date_partitioned_table', INTERVAL 'infinity', '2022-01-01', '2021-01-01');
ERROR: Partition interval must be a finite value
CONTEXT: PL/pgSQL function create_time_partitions(regclass,interval,timestamp with time zone,timestamp with time zone) line XX at RAISE
create_time_partitions
---------------------------------------------------------------------
t
(1 row)

SELECT create_time_partitions('date_partitioned_table', INTERVAL '-infinity', '2022-01-01', '2021-01-01');
ERROR: Partition interval must be a finite value
CONTEXT: PL/pgSQL function create_time_partitions(regclass,interval,timestamp with time zone,timestamp with time zone) line XX at RAISE
ERROR: partition date_partitioned_table_p2021 with the range from 01-01-2021 to infinity does not align with the initial partition given the partition interval
HINT: Only use partitions of the same size, without gaps between partitions.
CONTEXT: PL/pgSQL function get_missing_time_partition_ranges(regclass,interval,timestamp with time zone,timestamp with time zone) line XX at RAISE
PL/pgSQL function create_time_partitions(regclass,interval,timestamp with time zone,timestamp with time zone) line XX at FOR over SELECT rows
-- end of testing interval with infinite values
-- various jsonpath methods were added in PG17
-- relevant PG commit: https://github.com/postgres/postgres/commit/66ea94e8e
-- here we add the same test as in pg15_jsonpath.sql for the new additions
CREATE TABLE jsonpath_test (id serial, sample text);
SELECT create_distributed_table('jsonpath_test', 'id');
create_distributed_table
---------------------------------------------------------------------

(1 row)

\COPY jsonpath_test(sample) FROM STDIN
-- Cast the text into jsonpath on the worker nodes.
SELECT sample, sample::jsonpath FROM jsonpath_test ORDER BY id;
sample | sample
---------------------------------------------------------------------
$.bigint().integer().number().decimal() | $.bigint().integer().number().decimal()
$.boolean() | $.boolean()
$.date() | $.date()
$.decimal(4,2) | $.decimal(4,2)
$.string() | $.string()
$.time() | $.time()
$.time(6) | $.time(6)
$.time_tz() | $.time_tz()
$.time_tz(4) | $.time_tz(4)
$.timestamp() | $.timestamp()
$.timestamp(2) | $.timestamp(2)
$.timestamp_tz() | $.timestamp_tz()
$.timestamp_tz(0) | $.timestamp_tz(0)
(13 rows)

-- Pull the data, and cast on the coordinator node
WITH samples as (SELECT id, sample FROM jsonpath_test OFFSET 0)
SELECT sample, sample::jsonpath FROM samples ORDER BY id;
sample | sample
---------------------------------------------------------------------
$.bigint().integer().number().decimal() | $.bigint().integer().number().decimal()
$.boolean() | $.boolean()
$.date() | $.date()
$.decimal(4,2) | $.decimal(4,2)
$.string() | $.string()
$.time() | $.time()
$.time(6) | $.time(6)
$.time_tz() | $.time_tz()
$.time_tz(4) | $.time_tz(4)
$.timestamp() | $.timestamp()
$.timestamp(2) | $.timestamp(2)
$.timestamp_tz() | $.timestamp_tz()
$.timestamp_tz(0) | $.timestamp_tz(0)
(13 rows)

-- End of testing jsonpath methods
\set VERBOSITY terse
SET client_min_messages TO WARNING;
DROP SCHEMA pg17 CASCADE;
Expand Down
32 changes: 32 additions & 0 deletions src/test/regress/sql/pg17.sql
Original file line number Diff line number Diff line change
Expand Up @@ -812,6 +812,38 @@ SELECT create_time_partitions('date_partitioned_table', INTERVAL '-infinity', '2

-- end of testing interval with infinite values

-- various jsonpath methods were added in PG17
-- relevant PG commit: https://github.com/postgres/postgres/commit/66ea94e8e
-- here we add the same test as in pg15_jsonpath.sql for the new additions

CREATE TABLE jsonpath_test (id serial, sample text);
SELECT create_distributed_table('jsonpath_test', 'id');

\COPY jsonpath_test(sample) FROM STDIN
$.bigint().integer().number().decimal()
$.boolean()
$.date()
$.decimal(4,2)
$.string()
$.time()
$.time(6)
$.time_tz()
$.time_tz(4)
$.timestamp()
$.timestamp(2)
$.timestamp_tz()
$.timestamp_tz(0)
\.

-- Cast the text into jsonpath on the worker nodes.
SELECT sample, sample::jsonpath FROM jsonpath_test ORDER BY id;

-- Pull the data, and cast on the coordinator node
WITH samples as (SELECT id, sample FROM jsonpath_test OFFSET 0)
SELECT sample, sample::jsonpath FROM samples ORDER BY id;

-- End of testing jsonpath methods

\set VERBOSITY terse
SET client_min_messages TO WARNING;
DROP SCHEMA pg17 CASCADE;
Expand Down

0 comments on commit 531acbd

Please sign in to comment.