Skip to content

Commit

Permalink
[COST-3814] Check instanceid column instead of instancename (#4835)
Browse files Browse the repository at this point in the history
  • Loading branch information
cgoodfred committed Dec 13, 2023
1 parent 1485f2f commit 9bb8c30
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions koku/subs/subs_data_extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,17 +64,17 @@

RESOURCE_SELECT_MAP = {
Provider.PROVIDER_AWS: " SELECT lineitem_resourceid, max(lineitem_usagestartdate) ",
Provider.PROVIDER_AZURE: " SELECT coalesce(NULLIF(resourceid, ''), instancename), date_add('day', -1, max(coalesce(date, usagedatetime))) ", # noqa E501
Provider.PROVIDER_AZURE: " SELECT coalesce(NULLIF(resourceid, ''), instanceid), date_add('day', -1, max(coalesce(date, usagedatetime))) ", # noqa E501
}

RESOURCE_ID_GROUP_BY_MAP = {
Provider.PROVIDER_AWS: " GROUP BY lineitem_resourceid",
Provider.PROVIDER_AZURE: " GROUP BY resourceid, instancename",
Provider.PROVIDER_AZURE: " GROUP BY resourceid, instanceid",
}

RESOURCE_ID_EXCLUSION_CLAUSE_MAP = {
Provider.PROVIDER_AWS: " AND lineitem_resourceid NOT IN {{excluded_ids | inclause}} ",
Provider.PROVIDER_AZURE: " and coalesce(NULLIF(resourceid, ''), instancename) NOT IN {{excluded_ids | inclause}} ",
Provider.PROVIDER_AZURE: " and coalesce(NULLIF(resourceid, ''), instanceid) NOT IN {{excluded_ids | inclause}} ",
}

RESOURCE_ID_SQL_CLAUSE_MAP = {
Expand All @@ -84,7 +84,7 @@
" AND lineitem_usagestartdate <= {{{{ end_date_{0} }}}}) "
),
Provider.PROVIDER_AZURE: (
" ( coalesce(NULLIF(resourceid, ''), instancename) = {{{{ rid_{0} }}}} "
" ( coalesce(NULLIF(resourceid, ''), instanceid) = {{{{ rid_{0} }}}} "
"AND coalesce(date, usagedatetime) >= {{{{ start_date_{0} }}}} "
"AND coalesce(date, usagedatetime) <= {{{{ end_date_{0} }}}}) "
),
Expand Down
2 changes: 1 addition & 1 deletion koku/subs/trino_sql/azure_subs_pre_or_clause.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ SELECT
with_timezone(date_add('day', 1, COALESCE(date, usagedatetime)), 'UTC') as subs_end_time,
json_extract_scalar(lower(additionalinfo), '$.vcpus') as subs_vcpu,
COALESCE(NULLIF(subscriptionid, ''), subscriptionguid) as subs_account,
regexp_extract(COALESCE(NULLIF(resourceid, ''), instancename), '([^/]+$)') as subs_resource_id,
regexp_extract(COALESCE(NULLIF(resourceid, ''), instanceid), '([^/]+$)') as subs_resource_id,
CAST(ceil(coalesce(nullif(quantity, 0), usagequantity)) AS INTEGER) as subs_usage_quantity,
CASE lower(json_extract_scalar(lower(tags), '$.com_redhat_rhel_variant'))
WHEN 'workstation' THEN 'Red Hat Enterprise Linux Workstation'
Expand Down

0 comments on commit 9bb8c30

Please sign in to comment.