-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #48 from citusdata/bump-2.4.0
- Loading branch information
Showing
11 changed files
with
146 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
SHOW server_version \gset | ||
SELECT substring(:'server_version', '\d+')::int = 14; | ||
?column? | ||
---------- | ||
f | ||
(1 row) | ||
|
||
SELECT substring(:'server_version', '\d+')::int = 13; | ||
?column? | ||
---------- | ||
f | ||
(1 row) | ||
|
||
-- Create table to insert summaries. | ||
create table popular_products | ||
( | ||
review_summary jsonb, | ||
year double precision, | ||
month double precision | ||
); | ||
set topn.number_of_counters to 1000; | ||
-- Create different summaries by grouping the reviews according to their year and month. | ||
insert into | ||
popular_products(review_summary, year, month ) | ||
select | ||
topn_add_agg(product_id), | ||
extract(year from review_date) as year, | ||
extract(month from review_date) as month | ||
from | ||
customer_reviews | ||
group by | ||
year, | ||
month; | ||
-- Create another table for the merged results. | ||
create table | ||
overall_result(merged_summary jsonb); | ||
-- Let's merge the summaries for the overall result and check top-20 items. | ||
insert into | ||
overall_result(merged_summary) | ||
select | ||
topn_union_agg(review_summary) | ||
from | ||
popular_products; | ||
select | ||
(topn(merged_summary, 20)).* | ||
from | ||
overall_result | ||
order by 2 DESC, 1; | ||
item | frequency | ||
------------+----------- | ||
0671003755 | 576 | ||
0613033205 | 575 | ||
0671014730 | 572 | ||
0743527550 | 572 | ||
0375700757 | 555 | ||
0871136791 | 555 | ||
0679460691 | 551 | ||
0375402926 | 550 | ||
0613221583 | 536 | ||
0812550293 | 536 | ||
1575110458 | 536 | ||
1590073983 | 536 | ||
1590073991 | 536 | ||
0375402675 | 524 | ||
0375403477 | 524 | ||
0375703241 | 524 | ||
0399143904 | 524 | ||
0425170349 | 524 | ||
0613222407 | 524 | ||
0765342294 | 510 | ||
(20 rows) | ||
|
||
-- Test window functions | ||
CREATE TABLE daily_populars | ||
( | ||
date DATE, | ||
agg_data JSONB | ||
); | ||
INSERT INTO daily_populars | ||
SELECT | ||
date_trunc('day', review_date), | ||
topn_add_agg(product_id) | ||
FROM | ||
customer_reviews | ||
GROUP BY | ||
1; | ||
SELECT | ||
date, | ||
topn_union_agg(agg_data) OVER seven_days | ||
FROM | ||
daily_populars | ||
WINDOW | ||
seven_days AS (ORDER BY date ASC ROWS 6 PRECEDING) | ||
ORDER BY | ||
1 | ||
LIMIT 5; | ||
date | topn_union_agg | ||
------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ||
12-30-1970 | {"1551802538": 1, "1551803542": 1} | ||
06-19-1995 | {"0898624932": 1, "1551802538": 1, "1551803542": 1} | ||
06-23-1995 | {"0521469112": 1, "0898624932": 1, "1551802538": 1, "1551803542": 1} | ||
07-14-1995 | {"0521469112": 1, "0679722955": 1, "0898624932": 1, "1551802538": 1, "1551803542": 1} | ||
07-18-1995 | {"0195069056": 1, "0471114251": 1, "0517887290": 1, "0521469112": 1, "0679722955": 1, "0898624932": 1, "0962344788": 1, "1551802538": 1, "1551803542": 1, "1574531093": 1} | ||
(5 rows) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# topn extension | ||
comment = 'type for top-n JSONB' | ||
default_version = '2.3.1' | ||
default_version = '2.4.0' | ||
module_pathname = '$libdir/topn' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/* topn--2.3.1--2.4.0 */ | ||
|
||
/* bump version to 2.4.0 */ |