mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-11-08 06:53:11 +00:00
fix(profiler): snowflake system metric (#10246)
This commit is contained in:
parent
785142d86a
commit
219adbe9d9
@ -322,15 +322,11 @@ def _(
|
|||||||
metric_results: List[Dict] = []
|
metric_results: List[Dict] = []
|
||||||
|
|
||||||
information_schema_query_history = """
|
information_schema_query_history = """
|
||||||
SELECT * FROM table(information_schema.query_history(
|
SELECT * FROM "SNOWFLAKE"."ACCOUNT_USAGE"."QUERY_HISTORY"
|
||||||
end_time_range_start=>to_timestamp_ltz(DATEADD(HOUR, -{decrement_start}, CURRENT_TIMESTAMP())),
|
WHERE
|
||||||
end_time_range_end=>to_timestamp_ltz(DATEADD(HOUR, -{decrement_end}, CURRENT_TIMESTAMP())),
|
start_time>= DATEADD('DAY', -1, CURRENT_TIMESTAMP)
|
||||||
result_limit=>10000
|
AND QUERY_TYPE IN ('INSERT', 'MERGE', 'DELETE', 'UPDATE');
|
||||||
))
|
|
||||||
WHERE QUERY_TYPE IN ('INSERT', 'MERGE', 'DELETE', 'UPDATE')
|
|
||||||
order by start_time DESC;
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
result_scan = """
|
result_scan = """
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM TABLE(RESULT_SCAN('{query_id}'));
|
FROM TABLE(RESULT_SCAN('{query_id}'));
|
||||||
@ -345,17 +341,7 @@ def _(
|
|||||||
|
|
||||||
# limit of results is 10K. We'll query range of 1 hours to make sure we
|
# limit of results is 10K. We'll query range of 1 hours to make sure we
|
||||||
# get all the necessary data.
|
# get all the necessary data.
|
||||||
for decrement in range(24):
|
rows = session.execute(text(information_schema_query_history)).fetchall()
|
||||||
cursor = session.execute(
|
|
||||||
text(
|
|
||||||
dedent(
|
|
||||||
information_schema_query_history.format(
|
|
||||||
decrement_start=decrement + 1, decrement_end=decrement
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
rows.extend(cursor.fetchall())
|
|
||||||
|
|
||||||
query_results = [
|
query_results = [
|
||||||
QueryResult(
|
QueryResult(
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user