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

fix(formula): BI-5959 apply mutations before adding formula to global dimensions during validation #733

Merged
merged 3 commits into from
Dec 2, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,38 @@ def test_dimensions_in_window_function_identical_to_dims_in_query(self, control_

assert result_resp.status_code == HTTPStatus.OK, result_resp.json

def test_const_ops_in_window_ordering_dimension(self, control_api, data_api, saved_dataset):
ds = add_formulas_to_dataset(
api_v1=control_api,
dataset=saved_dataset,
formulas={
"order_day_in_year": "[order_date] - DATETRUNC([order_date], 'year')",
"order_period": """
IF [order_day_in_year] <= (365 * 1 / 2) THEN "H1"
ELSE "H2"
END
""",
"Group Sales": "SUM([sales])",
"RSum": "RSUM([Group Sales])",
},
)

result_resp = data_api.get_result(
dataset=ds,
fields=[
ds.find_field(title="order_period"),
ds.find_field(title="RSum"),
],
order_by=[
ds.find_field(title="order_period"),
],
fail_ok=True,
)
assert result_resp.status_code == HTTPStatus.OK, result_resp.json

data_rows = get_data_rows(result_resp) # [['H1', '161667.14076359986'], ['H2', '228798.99612549983']]
assert len(data_rows) == 2

def test_order_by_multilevel_window_function(self, control_api, data_api, saved_dataset):
ds = add_formulas_to_dataset(
api_v1=control_api,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -868,7 +868,7 @@ def _validate_field_formula(
for dim_field_id in self._group_by_ids:
dim_field = self._fields.get(id=dim_field_id)
try:
dim_formula_obj = self._process_field_stage_aggregation(dim_field, collect_errors=collect_errors)
dim_formula_obj = self._process_field_stage_mutation(dim_field, collect_errors=collect_errors)
except formula_exc.FormulaError:
# error has been registered, so when the field will be rendered explicitly the error will be raised
# here we can just skip it since there's nothing to register as a dimension
Expand Down
Loading