From 41b3f5fdb89e4dfeafdd1ac3334f60dbdb9da39a Mon Sep 17 00:00:00 2001 From: Jon Udell Date: Mon, 29 Apr 2024 01:41:38 -0700 Subject: [PATCH] Update github_pull_request.md (#425) Trying to minimize the amount of json magic. --- docs/tables/github_pull_request.md | 31 +++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/docs/tables/github_pull_request.md b/docs/tables/github_pull_request.md index 4690e4f..28f1bdd 100644 --- a/docs/tables/github_pull_request.md +++ b/docs/tables/github_pull_request.md @@ -253,4 +253,33 @@ where and state = 'OPEN' group by repository_full_name, number, title; -``` \ No newline at end of file +``` + +OR + +```sql+postgres +select + number, + created_at, + array(select jsonb_object_keys(labels)) as labels +from + github_pull_request +where + state = 'OPEN' + and repository_full_name = 'turbot/steampipe'; +``` + +```sql+sqlite +select + number, + created_at, + ( + select group_concat(key) + from json_each(labels) + ) as labels +from + github_pull_request +where + state = 'OPEN' + and repository_full_name = 'turbot/steampipe'; +```