Skip to content

Commit

Permalink
[sc-27082] Split up stl_querytext table with OVER before aggregatin…
Browse files Browse the repository at this point in the history
…g query text rows (#885)

* [sc-27082] Split the stl_querytext table with OVER before aggregating query text rows

* bump version
  • Loading branch information
usefulalgorithm authored Jun 28, 2024
1 parent 9eb9a99 commit e86213f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
26 changes: 24 additions & 2 deletions metaphor/redshift/access_event.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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;
"""

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>"]
Expand Down

0 comments on commit e86213f

Please sign in to comment.