-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reporting range aggregate functions and IS JSON predicate clauses #2113
Changes from 47 commits
56e5ab1
0d9261c
7995ae2
9785925
d465efa
4a0fdf6
2348e26
3700e44
6a96cdd
1bb6de4
078a6a1
5b1fe49
d5d2fd7
facaced
ea061d7
133bf75
bac4011
37f73b9
31d3d6b
db5e6e4
f954155
8b66a73
64b9c02
7144ffb
375c546
9c2e2f7
84a4a24
a944ba6
b6f3054
f3a8bd4
46b2f66
b4b8f54
734860d
d18c0ef
5546fad
1bc41ca
b285424
54aaa97
bed3120
df1420d
8d28862
1116517
c87cd8e
4183bd9
babfad0
f1f30ee
c93c816
1d666b1
29491dd
fccdd99
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,4 +45,44 @@ INSERT INTO analytics.metrics (metric_name, metric_value) VALUES ('ConversionRat | |
|
||
create view sales.employ_depart_view AS SELECT | ||
any_value(name) AS any_employee | ||
FROM employees; | ||
FROM employees; | ||
|
||
CREATE TABLE sales.events ( | ||
id int PRIMARY KEY, | ||
event_range daterange | ||
); | ||
|
||
-- Insert some ranges | ||
INSERT INTO sales.events (id, event_range) VALUES | ||
(1,'[2024-01-01, 2024-01-10]'::daterange), | ||
(2,'[2024-01-05, 2024-01-15]'::daterange), | ||
(3,'[2024-01-20, 2024-01-25]'::daterange); | ||
|
||
CREATE VIEW sales.event_analysis_view AS | ||
SELECT | ||
range_agg(event_range) AS all_event_ranges, | ||
range_intersect_agg(event_range) AS overlapping_range, | ||
lower(range_agg(event_range)) AS earliest_start, | ||
upper(range_agg(event_range)) AS latest_end | ||
FROM | ||
sales.events; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above, currently the view has multiple unsupported functions. Better to split it into multiple views to ensure that all the function types are getting caught. |
||
|
||
-- PG 16 and above feature | ||
CREATE TABLE sales.json_data ( | ||
id int PRIMARY KEY, | ||
data_column TEXT NOT NULL CHECK (data_column IS JSON), | ||
object_column TEXT CHECK (object_column IS JSON OBJECT), | ||
array_column TEXT CHECK (array_column IS JSON ARRAY), | ||
scalar_column TEXT CHECK (scalar_column IS JSON SCALAR), | ||
unique_keys_column TEXT CHECK (unique_keys_column IS JSON WITH UNIQUE KEYS) | ||
); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same comment as above for this table too. |
||
|
||
INSERT INTO public.json_data ( | ||
id, data_column, object_column, array_column, scalar_column, unique_keys_column | ||
) VALUES ( | ||
1, '{"key": "value"}', | ||
2, '{"name": "John", "age": 30}', | ||
3, '[1, 2, 3, 4]', | ||
4, '"hello"', | ||
5, '{"uniqueKey1": "value1", "uniqueKey2": "value2"}' | ||
); |
sanyamsinghal marked this conversation as resolved.
Show resolved
Hide resolved
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we add separate tables for each of the IS JSON clauses (not even each but at least 2 or three different clauses in different tables)? Currently the tables might just be getting reported due to the first IS JSON clause and the rest seem kind of useless.