From e86213f4229a396a3342004a7124a8ac70dc06a3 Mon Sep 17 00:00:00 2001 From: Tsung-Ju Lii Date: Fri, 28 Jun 2024 11:45:13 +0800 Subject: [PATCH] [sc-27082] Split up `stl_querytext` table with OVER before aggregating query text rows (#885) * [sc-27082] Split the stl_querytext table with OVER before aggregating query text rows * bump version --- metaphor/redshift/access_event.py | 26 ++++++++++++++++++++++++-- pyproject.toml | 2 +- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/metaphor/redshift/access_event.py b/metaphor/redshift/access_event.py index 9452ce32..5c26ef05 100644 --- a/metaphor/redshift/access_event.py +++ b/metaphor/redshift/access_event.py @@ -12,7 +12,23 @@ ss.rows, ss.bytes, ss.tbl, - LISTAGG(CASE WHEN LEN(RTRIM(sqt.text)) = 0 THEN sqt.text ELSE RTRIM(sqt.text) END, '') within group (order by sqt.sequence) AS querytxt, + REPLACE( + REPLACE( + LISTAGG( + CASE + WHEN LEN(RTRIM(sqt.text)) = 0 THEN sqt.text + ELSE RTRIM(sqt.text) + END, + '' + ) + WITHIN GROUP (ORDER BY sqt.sequence) + OVER ( + PARTITION BY sqt.userid, sqt.xid, sqt.pid, sqt.query + ), + '\r', '' + ), + '\\n', '' + ) AS querytxt, sti.database, sti.schema, sti.table, @@ -40,7 +56,13 @@ sq.starttime, sq.endtime, sq.aborted, - ss.endtime + ss.endtime, + sqt.text, + sqt.userid, + sqt.xid, + sqt.pid, + sqt.query, + sqt.sequence ORDER BY ss.endtime DESC; """ diff --git a/pyproject.toml b/pyproject.toml index 00188d7c..2db72fc5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "metaphor-connectors" -version = "0.14.21" +version = "0.14.22" license = "Apache-2.0" description = "A collection of Python-based 'connectors' that extract metadata from various sources to ingest into the Metaphor app." authors = ["Metaphor "]