Skip to content

Commit aefd0ac

Browse files
committed
fix
1 parent 5889c17 commit aefd0ac

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

metadata-ingestion/src/datahub/ingestion/source/snowflake/snowflake_query.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -588,9 +588,15 @@ def usage_per_object_per_time_bucket_for_time_window(
588588
query_id,
589589
query_start_time,
590590
user_name,
591+
-- Construct the email in the query, should match the Python behavior.
592+
-- The user_email is only used by the email_filter_query.
593+
NVL(USERS.email, CONCAT(LOWER(user_name), '{email_domain}')) AS user_email,
591594
{objects_column}
592595
from
593596
snowflake.account_usage.access_history
597+
LEFT JOIN
598+
snowflake.account_usage.users USERS
599+
ON user_name = users.name
594600
WHERE
595601
query_start_time >= to_timestamp_ltz({start_time_millis}, 3)
596602
AND query_start_time < to_timestamp_ltz({end_time_millis}, 3)
@@ -647,7 +653,7 @@ def usage_per_object_per_time_bucket_for_time_window(
647653
DATE_TRUNC('{time_bucket_size.value}', CONVERT_TIMEZONE('UTC', query_start_time)) AS bucket_start_time,
648654
count(distinct(query_id)) AS total_queries,
649655
user_name,
650-
ANY_VALUE(NVL(users.email, CONCAT(user_name, '{email_domain}'))) AS user_email
656+
ANY_VALUE(users.email) AS user_email
651657
FROM
652658
object_access_history
653659
LEFT JOIN

0 commit comments

Comments
 (0)