Skip to content
This repository was archived by the owner on Jun 13, 2025. It is now read-only.

Commit 833075e

Browse files
committed
fix: make inf percent change result null
previously if the result of aggregation for a column for the previous interval was 0 and the result for the current interval was not zero then we would get inf as the percent_change value for that column and that would break GQL
1 parent ace92d6 commit 833075e

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

graphql_api/types/flake_aggregates/flake_aggregates.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,11 @@ def flake_aggregates_with_percentage(
4242
merged_results: pl.DataFrame = pl.concat([past_aggregates, curr_aggregates])
4343

4444
merged_results = merged_results.with_columns(
45-
pl.all().pct_change().fill_nan(0).name.suffix("_percent_change")
45+
pl.all()
46+
.pct_change()
47+
.replace([float("inf"), None], None)
48+
.fill_nan(0)
49+
.name.suffix("_percent_change")
4650
)
4751
aggregates = merged_results.row(1, named=True)
4852

graphql_api/types/test_results_aggregates/test_results_aggregates.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,11 @@ def test_results_aggregates_with_percentage(
7171
# with_columns upserts the new columns, so if the name already exists it get overwritten
7272
# otherwise it's just added
7373
merged_results = merged_results.with_columns(
74-
pl.all().pct_change().fill_nan(0).name.suffix("_percent_change")
74+
pl.all()
75+
.pct_change()
76+
.replace([float("inf"), None], None)
77+
.fill_nan(0)
78+
.name.suffix("_percent_change")
7579
)
7680
aggregates = merged_results.row(1, named=True)
7781

0 commit comments

Comments
 (0)