Created
October 21, 2019 14:39
-
-
Save mekhami/2e0c3549d4fe6081764822d4ecbb53a9 to your computer and use it in GitHub Desktop.
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
create or replace function get_partitions(spec text, conditions text) | |
returns table (id bigint, partition jsonb) | |
as | |
$body$ | |
select j.ord, j.value | |
from subscriptions_fulfillmentplan plan, jsonb_array_elements(plan.new_segments) segment, jsonb_array_elements(segment->'partitions') with ordinality as j(value,ord) | |
where plan.spec = spec | |
and segment->'rule'->>'conditions' = conditions | |
$body$ | |
language sql; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment