From 94d25447e181433f1b9a3a8021d52840b5d8dad2 Mon Sep 17 00:00:00 2001 From: Luke Couzens Date: Fri, 13 Dec 2024 09:58:59 +0000 Subject: [PATCH] [COST-5565] - dont match on empty resource ids (OCP/AWS managed tables) (#5425) * [COST-5565] - dont match empty resource ids --- .../trino_sql/aws/openshift/managed_aws_openshift_daily.sql | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/koku/masu/database/trino_sql/aws/openshift/managed_aws_openshift_daily.sql b/koku/masu/database/trino_sql/aws/openshift/managed_aws_openshift_daily.sql index c826e2e948..65d70bb6ae 100644 --- a/koku/masu/database/trino_sql/aws/openshift/managed_aws_openshift_daily.sql +++ b/koku/masu/database/trino_sql/aws/openshift/managed_aws_openshift_daily.sql @@ -96,6 +96,7 @@ cte_array_agg_nodes AS ( SELECT DISTINCT resource_id FROM hive.{{schema | sqlsafe}}.openshift_pod_usage_line_items_daily WHERE source = {{ocp_source_uuid}} + AND resource_id != '' AND year = {{year}} AND month = {{month}} AND interval_start >= {{start_date}} @@ -105,6 +106,7 @@ cte_array_agg_volumes AS ( SELECT DISTINCT persistentvolume, csi_volume_handle FROM hive.{{schema | sqlsafe}}.openshift_storage_usage_line_items_daily WHERE source = {{ocp_source_uuid}} + AND persistentvolume != '' AND year = {{year}} AND month = {{month}} AND interval_start >= {{start_date}} @@ -124,7 +126,7 @@ cte_matchable_resource_names AS ( JOIN cte_array_agg_volumes AS volumes ON ( substr(resource_names.lineitem_resourceid, -length(volumes.persistentvolume)) = volumes.persistentvolume - OR substr(resource_names.lineitem_resourceid, -length(volumes.csi_volume_handle)) = volumes.csi_volume_handle + OR (volumes.csi_volume_handle != '' AND substr(resource_names.lineitem_resourceid, -length(volumes.csi_volume_handle)) = volumes.csi_volume_handle) ) ),