Skip to content

Commit

Permalink
[VQR] Fixes query_name recording in results
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrey Fedorov committed Nov 27, 2019
1 parent f31073c commit 7bd53ec
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
16 changes: 16 additions & 0 deletions migrations/v1_9_0-v1_9_1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
## Adds object_assign UDTF

Please run the following code to fix a bug in the violations runner which
broke recording `query_name` in violation query results (`query_id`'s worked).

~~~
USE SCHEMA data;
CREATE FUNCTION IF NOT EXISTS object_assign (o1 VARIANT, o2 VARIANT)
RETURNS VARIANT
LANGUAGE javascript
AS '
return Object.assign(O1, O2);
'
;
~~~
5 changes: 4 additions & 1 deletion src/runners/helpers/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,10 @@ def insert_alerts(alerts, ctx=None):
)
)
))
, OBJECT_CONSTRUCT(*)
, data.object_assign(
OBJECT_CONSTRUCT(*),
OBJECT_CONSTRUCT('QUERY_NAME', '{{query_name}}')
)
FROM rules.{{query_name}}
WHERE IFF(alert_time IS NOT NULL, alert_time > {{CUTOFF_TIME}}, TRUE)
"""
Expand Down

0 comments on commit 7bd53ec

Please sign in to comment.