@@ -743,12 +743,14 @@ INSERT INTO hive.{{schema | sqlsafe}}.reporting_ocpawscostlineitem_project_daily
743
743
WITH cte_total_pv_capacity as (
744
744
SELECT
745
745
aws_resource_id,
746
- SUM (combined_requests .capacity ) as total_pv_capacity
746
+ SUM (combined_requests .capacity ) as total_pv_capacity,
747
+ count (distinct cluster_id) as cluster_count
747
748
FROM (
748
749
SELECT
749
750
ocp .persistentvolume ,
750
751
max (ocp .persistentvolumeclaim_capacity_gigabyte ) as capacity,
751
- aws .resource_id as aws_resource_id
752
+ aws .resource_id as aws_resource_id,
753
+ ocp .cluster_id
752
754
FROM hive.{{schema | sqlsafe}}.reporting_ocpusagelineitem_daily_summary as ocp
753
755
JOIN hive.{{schema | sqlsafe}}.aws_openshift_daily_resource_matched_temp as aws
754
756
ON (aws .usage_start = ocp .usage_start )
@@ -762,7 +764,7 @@ WITH cte_total_pv_capacity as (
762
764
AND aws .ocp_source = {{ocp_source_uuid}}
763
765
AND aws .year = {{year}}
764
766
AND aws .month = {{month}}
765
- GROUP BY ocp .persistentvolume , aws .resource_id
767
+ GROUP BY ocp .persistentvolume , aws .resource_id , ocp . cluster_id
766
768
) as combined_requests group by aws_resource_id
767
769
)
768
770
SELECT cast(uuid() as varchar ) as aws_uuid, -- need a new uuid or it will deduplicate
@@ -785,14 +787,14 @@ SELECT cast(uuid() as varchar) as aws_uuid, -- need a new uuid or it will dedup
785
787
max (aws .unit ) as unit,
786
788
cast(NULL as double) as usage_amount,
787
789
max (aws .currency_code ) as currency_code,
788
- (max (aws_disk .capacity ) - max (pv_cap .total_pv_capacity )) / max (aws_disk .capacity ) * max (aws .unblended_cost ) as unblended_cost,
789
- ((max (aws_disk .capacity ) - max (pv_cap .total_pv_capacity )) / max (aws_disk .capacity ) * max (aws .unblended_cost )) * cast({{markup}} as decimal (24 ,9 )) as markup_cost,
790
- (max (aws_disk .capacity ) - max (pv_cap .total_pv_capacity )) / max (aws_disk .capacity ) * max (aws .blended_cost ) as blended_cost,
791
- ((max (aws_disk .capacity ) - max (pv_cap .total_pv_capacity )) / max (aws_disk .capacity ) * max (aws .blended_cost )) * cast({{markup}} as decimal (24 ,9 )) as markup_cost_blended,
792
- (max (aws_disk .capacity ) - max (pv_cap .total_pv_capacity )) / max (aws_disk .capacity ) * max (aws .savingsplan_effective_cost ) as savingsplan_effective_cost,
793
- ((max (aws_disk .capacity ) - max (pv_cap .total_pv_capacity )) / max (aws_disk .capacity ) * max (aws .savingsplan_effective_cost )) * cast({{markup}} as decimal (24 ,9 )) as markup_cost_savingsplan,
794
- (max (aws_disk .capacity ) - max (pv_cap .total_pv_capacity )) / max (aws_disk .capacity ) * max (aws .calculated_amortized_cost ) as calculated_amortized_cost,
795
- ((max (aws_disk .capacity ) - max (pv_cap .total_pv_capacity )) / max (aws_disk .capacity ) * max (aws .calculated_amortized_cost )) * cast({{markup}} as decimal (24 ,9 )) as markup_cost_amortized,
790
+ (max (aws_disk .capacity ) - max (pv_cap .total_pv_capacity )) / max (aws_disk .capacity ) * max (aws .unblended_cost ) / max ( pv_cap . cluster_count ) as unblended_cost,
791
+ ((max (aws_disk .capacity ) - max (pv_cap .total_pv_capacity )) / max (aws_disk .capacity ) * max (aws .unblended_cost )) * cast({{markup}} as decimal (24 ,9 )) / max ( pv_cap . cluster_count ) as markup_cost,
792
+ (max (aws_disk .capacity ) - max (pv_cap .total_pv_capacity )) / max (aws_disk .capacity ) * max (aws .blended_cost ) / max ( pv_cap . cluster_count ) as blended_cost,
793
+ ((max (aws_disk .capacity ) - max (pv_cap .total_pv_capacity )) / max (aws_disk .capacity ) * max (aws .blended_cost )) * cast({{markup}} as decimal (24 ,9 )) / max ( pv_cap . cluster_count ) as markup_cost_blended,
794
+ (max (aws_disk .capacity ) - max (pv_cap .total_pv_capacity )) / max (aws_disk .capacity ) * max (aws .savingsplan_effective_cost ) / max ( pv_cap . cluster_count ) as savingsplan_effective_cost,
795
+ ((max (aws_disk .capacity ) - max (pv_cap .total_pv_capacity )) / max (aws_disk .capacity ) * max (aws .savingsplan_effective_cost )) * cast({{markup}} as decimal (24 ,9 )) / max ( pv_cap . cluster_count ) as markup_cost_savingsplan,
796
+ (max (aws_disk .capacity ) - max (pv_cap .total_pv_capacity )) / max (aws_disk .capacity ) * max (aws .calculated_amortized_cost ) / max ( pv_cap . cluster_count ) as calculated_amortized_cost,
797
+ ((max (aws_disk .capacity ) - max (pv_cap .total_pv_capacity )) / max (aws_disk .capacity ) * max (aws .calculated_amortized_cost )) * cast({{markup}} as decimal (24 ,9 )) / max ( pv_cap . cluster_count ) as markup_cost_amortized,
796
798
max (aws .resource_id_matched ) as resource_id_matched,
797
799
{{ocp_source_uuid}} as ocp_source,
798
800
max (aws .year ) as year,
0 commit comments