Skip to content
This repository was archived by the owner on Jan 23, 2024. It is now read-only.

Commit 015ed3b

Browse files
authored
Merge pull request #132 from bcc-code/update-changes
Unpack commits from metadata in changes.sql
2 parents 2ab2eee + dddb5aa commit 015ed3b

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

queries/changes.sql

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
# Changes Table
22
SELECT
33
source,
4-
id as change_id,
5-
time_created,
6-
event_type
7-
FROM four_keys.events_raw
4+
event_type,
5+
JSON_EXTRACT_SCALAR(commit, '$.id') change_id,
6+
TIMESTAMP_TRUNC(TIMESTAMP(JSON_EXTRACT_SCALAR(commit, '$.timestamp')),second) as time_created,
7+
FROM four_keys.events_raw e,
8+
UNNEST(JSON_EXTRACT_ARRAY(e.metadata, '$.commits')) as commit
89
WHERE event_type in ("pull_request", "push", "merge_request")
9-
GROUP BY 1,2,3,4;
10+
GROUP BY 1,2,3,4

0 commit comments

Comments
 (0)