Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add alternate_group_by_column field to Project and Instance Type group by #1295

Conversation

eiffel777
Copy link
Contributor

This adds alternate_group_by_columns to the Project and Instance Type group bys. One place the column in alternate_group_by_column, when present, is used is in the group by WHERE clause to filter results. If alternate_group_by_column is not specified the column(s) in attribute_to_aggregate_table_key_map are used instead. For the Project and Instance Type group by's the correct column for WHERE clause is the display column not the instance_type_id specified in attribute_to_aggregate_table_key_map.

An example of the difference in the sql when alternate_group_by_column is used is shown in the Instance Type group by sql below.

Query before change:

SELECT
  duration.id as 'day_id',
  DATE(duration.day_start) as 'day_short_name',
  DATE(duration.day_start) as 'day_name',
  duration.day_start_ts as 'day_start_ts',
  instance_type.display as 'configuration_id',
  instance_type.display as 'configuration_short_name',
  instance_type.display as 'configuration_name',
  instance_type.display as 'configuration_order_id',
  COALESCE(SUM(agg.core_time) / 3600.0, 0) AS cloud_core_time
FROM
  modw_cloud.cloudfact_by_day agg,
  modw.days duration,
  modw_cloud.instance_type instance_type
WHERE
  duration.id = agg.day_id
  AND agg.day_id between 202000061 and 202000091
  AND instance_type.instance_type_id = agg.instance_type_id
  AND instance_type.instance_type_id IN ('c4.m16','c8.m16','c4.m8','c2.m4','c16.m64','c2.m8','c16.m32','c8.m32','c1.m4','c1.m1')
GROUP BY 
  duration.id,
  instance_type.instance_type_id
ORDER BY duration.id ASC,
  instance_type.instance_type_id ASC

Query after change:

SELECT
  duration.id as 'day_id',
  DATE(duration.day_start) as 'day_short_name',
  DATE(duration.day_start) as 'day_name',
  duration.day_start_ts as 'day_start_ts',
  instance_type.display as 'configuration_id',
  instance_type.display as 'configuration_short_name',
  instance_type.display as 'configuration_name',
  instance_type.display as 'configuration_order_id',
  COALESCE(SUM(agg.core_time) / 3600.0, 0) AS cloud_core_time
FROM
  modw_cloud.cloudfact_by_day agg,
  modw.days duration,
  modw_cloud.instance_type instance_type
WHERE
  duration.id = agg.day_id
  AND agg.day_id between 202000061 and 202000091
  AND instance_type.instance_type_id = agg.instance_type_id
  AND instance_type.display IN ('c4.m16','c8.m16','c4.m8','c2.m4','c16.m64','c2.m8','c16.m32','c8.m32','c1.m4','c1.m1')
GROUP BY 
  duration.id,
  instance_type.display
ORDER BY duration.id ASC,
  instance_type.instance_type_id ASC

I've updated my port (9008) on metrics-dev with the fix.

Tests performed

Tested on port 9008 on metrics-dev

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project as found in the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@eiffel777 eiffel777 requested a review from plessbd April 29, 2020 18:48
@eiffel777 eiffel777 self-assigned this Apr 29, 2020
@eiffel777 eiffel777 added bug Bugfixes Category:Cloud Cloud Realm labels Apr 29, 2020
@eiffel777 eiffel777 added this to the 9.0.0 milestone Apr 29, 2020
@eiffel777 eiffel777 merged commit a9f97a3 into ubccr:xdmod9.0 Apr 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bugfixes Category:Cloud Cloud Realm
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants