@@ -418,23 +418,28 @@ cte_ocp_filtered_resources as (
418
418
AND aws .ocp_source = {{ocp_source_uuid}}
419
419
AND aws .year = {{year}}
420
420
AND aws .month = {{month}}
421
+ ),
422
+ calculated_capacity AS (
423
+ SELECT
424
+ aws .lineitem_resourceid as resource_id,
425
+ ROUND(MAX (aws .lineitem_unblendedcost ) / (MAX (aws .lineitem_unblendedrate ) / MAX (hours .in_month ))) AS capacity,
426
+ ocpaws .usage_start ,
427
+ {{ocp_source_uuid}} as ocp_source,
428
+ {{year}} as year,
429
+ {{month}} as month
430
+ FROM hive.{{schema | sqlsafe}}.aws_line_items as aws
431
+ INNER JOIN cte_ocp_filtered_resources as ocpaws
432
+ ON aws .lineitem_resourceid = ocpaws .resource_id
433
+ AND DATE (aws .lineitem_usagestartdate ) = ocpaws .usage_start
434
+ CROSS JOIN cte_hours as hours
435
+ WHERE aws .year = {{year}}
436
+ AND aws .month = {{month}}
437
+ AND aws .source = {{aws_source_uuid}}
438
+ GROUP BY aws .lineitem_resourceid , ocpaws .usage_start
421
439
)
422
- SELECT
423
- aws .lineitem_resourceid as resource_id,
424
- ROUND(MAX (aws .lineitem_unblendedcost ) / (MAX (aws .lineitem_unblendedrate ) / MAX (hours .in_month ))) AS capacity,
425
- ocpaws .usage_start ,
426
- {{ocp_source_uuid}} as ocp_source,
427
- {{year}} as year,
428
- {{month}} as month
429
- FROM hive.{{schema | sqlsafe}}.aws_line_items as aws
430
- INNER JOIN cte_ocp_filtered_resources as ocpaws
431
- ON aws .lineitem_resourceid = ocpaws .resource_id
432
- AND DATE (aws .lineitem_usagestartdate ) = ocpaws .usage_start
433
- CROSS JOIN cte_hours as hours
434
- WHERE aws .year = {{year}}
435
- AND aws .month = {{month}}
436
- AND aws .source = {{aws_source_uuid}}
437
- group by aws .lineitem_resourceid , ocpaws .usage_start
440
+ SELECT *
441
+ FROM calculated_capacity
442
+ WHERE capacity > 0
438
443
{% endif %}
439
444
;
440
445
0 commit comments