Skip to content
Open
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
10 changes: 5 additions & 5 deletions scrunch/datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -1129,7 +1129,7 @@ def create_fill_values(self, variables, name, alias, description=''):
if "variable" in else_case and "name" in else_case:
raise ValueError("Else case can be either variable or category not both")

aliases = {c["variable"] for c in variables}
aliases = {c["var"] for c in variables}
vars_by_alias = self.resource.variables.by("alias")
types = {vars_by_alias[al]["type"] for al in aliases}
if types != {"categorical"}:
Expand Down Expand Up @@ -1162,13 +1162,13 @@ def create_fill_values(self, variables, name, alias, description=''):
})

expr = {"function": "case", "args": args}
fill_map = {str(cid): {"variable": vars_by_alias[v["variable"]]["id"]}
fill_map = {str(cid): {"var": v["var"]}
for cid, v in zip(cat_ids, variables)}

if "variable" in else_case:
if "var" in else_case:
# We are in the case of a default fill, replace the -1 with the new
# variable
fill_map["-1"] = {"variable": vars_by_alias[else_case["variable"]]["id"]}
fill_map["-1"] = {"var": else_case["var"]}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there still a vars_by_alias that's being fetched that we may not need anymore?


fill_expr = {
"function": "fill",
Expand Down Expand Up @@ -1873,7 +1873,7 @@ def combine_categorical(self, variable, map, categories=None, missing=None,
'alias': alias,
'description': description,
'derivation': combine_categories_expr(
variable.resource.self, combinations)
variable.alias, combinations)
})
return self._var_create_reload_return(payload)

Expand Down
213 changes: 67 additions & 146 deletions scrunch/expressions.py

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion scrunch/tests/test_cubes.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def test_pass_filter_expression(self, mock_fetch_cube):
"function": ">",
"args": [
{
"variable": "https://test.crunch.io/api/datasets/123456/variables/0001/"
"var": "var1_alias"
},
{"value": 1},
],
Expand Down
Loading