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

refactor(server/pypika): Make the percentage step return values between 0 and 1 TCTC-6157 #1867

Merged
merged 1 commit into from
Aug 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions server/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

### Changed

- Pypika: The `percentage` step now returns a value between 0 and 1 to be consistent with the mongo and pandas backends

## [0.35.5] - 2023-08-17

### Fixed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1384,7 +1384,6 @@ def percentage(

perc_column = (
functions.Cast(table[step.column], self.DATA_TYPE_MAPPING.float)
* 100
/ agg_query[sum_col_name]
).as_(new_col_name)

Expand Down
20 changes: 10 additions & 10 deletions server/tests/backends/fixtures/percentage/simple_pypika.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,34 +16,34 @@ expected:
data:
- name: Superstrong beer
price_per_l: 0.16
price_per_l_percentage: 26.4900662252
price_per_l_percentage: 0.264900662252
- name: Ninkasi Ploploplop
price_per_l: 0.054
price_per_l_percentage: 8.940397351
price_per_l_percentage: 0.08940397351
- name: Brewdog Nanny State Alcoholvrij
price_per_l: 0.005
price_per_l_percentage: 0.8278145695
price_per_l_percentage: 0.008278145695
- name: Ardwen Blonde
price_per_l: 0.056
price_per_l_percentage: 9.2715231788
price_per_l_percentage: 0.092715231788
- name: "Cuvée des Trolls"
price_per_l: 0.07
price_per_l_percentage: 11.5894039735
price_per_l_percentage: 0.115894039735
- name: Weihenstephan Hefe Weizen Alcoholarm
price_per_l: 0.005
price_per_l_percentage: 0.8278145695
price_per_l_percentage: 0.008278145695
- name: Bellfield Lawless Village IPA
price_per_l: 0.045
price_per_l_percentage: 7.4503311258
price_per_l_percentage: 0.074503311258
- name: Pauwel Kwak
price_per_l: 0.084
price_per_l_percentage: 13.9072847682
price_per_l_percentage: 0.139072847682
- name: Brasserie De Sutter Brin de Folie
price_per_l: 0.065
price_per_l_percentage: 10.761589404
price_per_l_percentage: 0.10761589404
- name: Brugse Zot blonde
price_per_l: 0.06
price_per_l_percentage: 9.9337748344
price_per_l_percentage: 0.099337748344
schema:
fields:
- name: price_per_l
Expand Down
20 changes: 10 additions & 10 deletions server/tests/backends/fixtures/percentage/with_groups_pypika.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,43 +20,43 @@ expected:
- beer_kind: Triple
name: Superstrong beer
price_per_l: 0.16
price_per_l_percentage: 100.0
price_per_l_percentage: 1.0
- beer_kind: India Pale Ale
name: Ninkasi Ploploplop
price_per_l: 0.054
price_per_l_percentage: 54.5454545455
price_per_l_percentage: 0.545454545455
- beer_kind: Sans alcool
name: Brewdog Nanny State Alcoholvrij
price_per_l: 0.005
price_per_l_percentage: 100.0
price_per_l_percentage: 1.0
- beer_kind: Best-sellers
name: Ardwen Blonde
price_per_l: 0.056
price_per_l_percentage: 100.0
price_per_l_percentage: 1.0
- beer_kind: Blonde
name: "Cuv\xE9e des Trolls"
price_per_l: 0.07
price_per_l_percentage: 35.8974358974
price_per_l_percentage: 0.358974358974
- beer_kind: Blanche & Weizen
name: Weihenstephan Hefe Weizen Alcoholarm
price_per_l: 0.005
price_per_l_percentage: 100.0
price_per_l_percentage: 1.0
- beer_kind: India Pale Ale
name: Bellfield Lawless Village IPA
price_per_l: 0.045
price_per_l_percentage: 45.4545454545
price_per_l_percentage: 0.454545454545
- beer_kind: Belge blonde forte & Golden Ale
name: Pauwel Kwak
price_per_l: 0.084
price_per_l_percentage: 100.0
price_per_l_percentage: 1.0
- beer_kind: Blonde
name: Brasserie De Sutter Brin de Folie
price_per_l: 0.065
price_per_l_percentage: 33.3333333333
price_per_l_percentage: 0.333333333333
- beer_kind: Blonde
name: Brugse Zot blonde
price_per_l: 0.06
price_per_l_percentage: 30.7692307692
price_per_l_percentage: 0.307692307692
schema:
fields:
- name: price_per_l
Expand Down