Closed
Bug 1879039
Opened 1 year ago
Closed 11 months ago
Nested repeated key-value arrays don't translate nicely to JSON
Categories
(Data Platform and Tools :: Glean Platform, enhancement, P1)
Data Platform and Tools
Glean Platform
Tracking
(Not tracked)
RESOLVED
FIXED
People
(Reporter: janerik, Assigned: janerik)
References
(Blocks 1 open bug)
Details
Attachments
(1 file)
Right now we encode the metrics
as JSON into its own column.
Everything in there is now accessible.
However e.g. labeled counters show up as this:
{"glean_error_invalid_overflow":[{"key":"page.referrer","value":1},{"key":"glean.page_load","value":2}]}
It's possible to turn them into something nicer with a (hidden) UDF:
mozfun.json.from_map_json(JSON_EXTRACT(metrics, '$.labeled_counter.glean_error_invalid_overflow'))
That gives us
{"glean.page_load":2,"page.referrer":1}
It would be nice if that would be the default.
We would need a new UDF that applies from_map_json
to things nested within $.labeled_counter
Assignee | ||
Comment 1•1 year ago
|
||
CREATE TEMP FUNCTION nested_from_map_json(input JSON)
RETURNS JSON
LANGUAGE js
AS
"""
if (input && Object.keys(input).length) {
for (const k in input) {
input[k] = input[k].reduce((acc, {key, value}) => {
acc[key] = value;
return acc;
}, {});
}
return input;
}
return null;
""";
Comment 2•1 year ago
|
||
Assignee | ||
Updated•1 year ago
|
Assignee: nobody → jrediger
Priority: -- → P1
Assignee | ||
Comment 3•11 months ago
|
||
badboy merged PR [mozilla/bigquery-etl]: Bug 1879039 - events stream: Convert nested maps in metrics (#4981) in 6d8a3d2.
Status: NEW → RESOLVED
Closed: 11 months ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•