@@ -684,7 +684,6 @@ JOIN hive.{{schema | sqlsafe}}.aws_openshift_daily_resource_matched_temp as aws
684
684
JOIN hive.{{schema | sqlsafe}}.aws_openshift_disk_capacities_temp AS aws_disk
685
685
ON aws_disk .usage_start = aws .usage_start
686
686
AND aws_disk .resource_id = aws .resource_id
687
- AND aws_disk .ocp_source = {{ocp_source_uuid}}
688
687
WHERE ocp .source = {{ocp_source_uuid}}
689
688
AND ocp .year = {{year}}
690
689
AND lpad(ocp .month , 2 , ' 0' ) = {{month}} -- Zero pad the month when fewer than 2 characters
@@ -697,6 +696,9 @@ WHERE ocp.source = {{ocp_source_uuid}}
697
696
AND aws .data_transfer_direction IS NULL
698
697
AND ocp .namespace != ' Storage unattributed'
699
698
AND aws .resource_id_matched = True
699
+ AND aws_disk .year = {{year}}
700
+ AND aws_disk .month = {{month}}
701
+ AND aws_disk .ocp_source = {{ocp_source_uuid}}
700
702
GROUP BY aws .uuid , ocp .namespace , ocp .pod_labels , ocp .volume_labels
701
703
{% endif %}
702
704
;
@@ -749,15 +751,17 @@ WITH cte_total_pv_capacity as (
749
751
aws .resource_id as aws_resource_id
750
752
FROM hive.{{schema | sqlsafe}}.reporting_ocpusagelineitem_daily_summary as ocp
751
753
JOIN hive.{{schema | sqlsafe}}.aws_openshift_daily_resource_matched_temp as aws
752
- ON (aws .usage_start = ocp .usage_start )
753
- AND strpos(aws .resource_id , ocp .csi_volume_handle ) > 0
754
- AND ocp .csi_volume_handle is not null
755
- AND ocp .csi_volume_handle != ' '
756
- WHERE ocp .source = {{ocp_source_uuid}}
757
- AND ocp .year = {{year}}
754
+ ON (aws .usage_start = ocp .usage_start )
755
+ AND strpos(aws .resource_id , ocp .csi_volume_handle ) > 0
756
+ AND ocp .csi_volume_handle is not null
757
+ AND ocp .csi_volume_handle != ' '
758
+ WHERE ocp .year = {{year}}
758
759
AND lpad(ocp .month , 2 , ' 0' ) = {{month}}
759
760
AND ocp .usage_start >= {{start_date}}
760
761
AND ocp .usage_start < date_add(' day' , 1 , {{end_date}})
762
+ AND aws .ocp_source = {{ocp_source_uuid}}
763
+ AND aws .year = {{year}}
764
+ AND aws .month = {{month}}
761
765
GROUP BY ocp .persistentvolume , aws .resource_id
762
766
) as combined_requests group by aws_resource_id
763
767
)
@@ -802,7 +806,6 @@ JOIN hive.{{schema | sqlsafe}}.aws_openshift_daily_resource_matched_temp as aws
802
806
JOIN hive.{{schema | sqlsafe}}.aws_openshift_disk_capacities_temp AS aws_disk
803
807
ON aws_disk .usage_start = aws .usage_start
804
808
AND aws_disk .resource_id = aws .resource_id
805
- AND aws_disk .ocp_source = {{ocp_source_uuid}}
806
809
LEFT JOIN cte_total_pv_capacity as pv_cap
807
810
ON pv_cap .aws_resource_id = aws .resource_id
808
811
WHERE ocp .source = {{ocp_source_uuid}}
@@ -817,6 +820,9 @@ WHERE ocp.source = {{ocp_source_uuid}}
817
820
AND aws .data_transfer_direction IS NULL
818
821
AND ocp .namespace != ' Storage unattributed'
819
822
AND aws_disk .capacity != pv_cap .total_pv_capacity -- prevent inserting zero cost rows
823
+ AND aws_disk .year = {{year}}
824
+ AND aws_disk .month = {{month}}
825
+ AND aws_disk .ocp_source = {{ocp_source_uuid}}
820
826
GROUP BY aws .uuid , aws .resource_id
821
827
{% endif %}
822
828
;
@@ -933,7 +939,9 @@ SELECT aws.uuid as aws_uuid,
933
939
LEFT JOIN hive.{{schema | sqlsafe}}.aws_openshift_disk_capacities_temp AS aws_disk
934
940
ON aws_disk .usage_start = aws .usage_start
935
941
AND aws_disk .resource_id = aws .resource_id
936
- AND aws_disk .ocp_source = {{ocp_source_uuid}}
942
+ AND aws_disk .year = aws .year
943
+ AND aws_disk .month = aws .month
944
+ AND aws_disk .ocp_source = aws .ocp_source
937
945
WHERE ocp .source = {{ocp_source_uuid}}
938
946
AND ocp .year = {{year}}
939
947
AND lpad(ocp .month , 2 , ' 0' ) = {{month}} -- Zero pad the month when fewer than 2 characters
0 commit comments