-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[COST-4589] Correctly get end of month data for Azure Metering (#4897)
* move SQL to files per provider, case statement for Azure to handle EoM scenario
- Loading branch information
Showing
10 changed files
with
272 additions
and
184 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
SELECT DISTINCT lineitem_usageaccountid | ||
FROM hive.{{schema | sqlsafe}}.aws_line_items | ||
WHERE source={{source_uuid}} | ||
AND year={{year}} | ||
AND month={{month}} | ||
{% if excluded_ids %} | ||
AND lineitem_usageaccountid NOT IN {{excluded_ids | inclause}} | ||
{% endif %} |
12 changes: 12 additions & 0 deletions
12
koku/subs/trino_sql/aws/determine_resource_ids_for_usage_account.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
SELECT lineitem_resourceid, max(lineitem_usagestartdate) | ||
FROM hive.{{schema | sqlsafe}}.aws_line_items | ||
WHERE source={{source_uuid}} | ||
AND year={{year}} | ||
AND month={{month}} | ||
AND lineitem_productcode = 'AmazonEC2' | ||
AND strpos(lower(resourcetags), 'com_redhat_rhel') > 0 | ||
AND lineitem_usageaccountid = {{usage_account}} | ||
{% if excluded_ids %} | ||
AND lineitem_usageaccountid NOT IN {{excluded_ids | inclause}} | ||
{% endif %} | ||
GROUP BY lineitem_resourceid |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
SELECT count(*) | ||
FROM | ||
hive.{{schema | sqlsafe}}.aws_line_items | ||
WHERE | ||
source = {{ source_uuid }} | ||
AND year = {{ year }} | ||
AND month = {{ month }} | ||
AND lineitem_productcode = 'AmazonEC2' | ||
AND lineitem_lineitemtype IN ('Usage', 'SavingsPlanCoveredUsage') | ||
AND product_vcpu != '' | ||
AND strpos(lower(resourcetags), 'com_redhat_rhel') > 0 | ||
AND ( | ||
{% for item in resources %} | ||
( | ||
lineitem_resourceid = {{item.rid}} AND | ||
lineitem_usagestartdate >= {{item.start}} AND | ||
lineitem_usagestartdate <= {{item.end}} | ||
) | ||
{% if not loop.last %} | ||
OR | ||
{% endif %} | ||
{% endfor %} | ||
) |
Oops, something went wrong.