Skip to content

Commit

Permalink
Rename saved query group_bys to group_by
Browse files Browse the repository at this point in the history
In dbt-labs/dbt-semantic-interfaces#186 we
renamed `group_bys` to `group_by` in DSI (which went out in DSI 0.4.0).
The original `group_bys` naming was a typo. This fixes that. This is a
non-breaking change from the core perspective because saved queries
are being introduced in 1.7.0, which has not been cut yet.
  • Loading branch information
QMalcolm committed Nov 1, 2023
1 parent ab238f2 commit 49edc69
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions core/dbt/contracts/graph/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1746,7 +1746,7 @@ def same_contents(self, old: Optional["SemanticModel"]) -> bool:
@dataclass
class SavedQueryMandatory(GraphNode):
metrics: List[str]
group_bys: List[str]
group_by: List[str]
where: Optional[WhereFilterIntersection]


Expand All @@ -1769,8 +1769,8 @@ def depends_on_nodes(self):
def same_metrics(self, old: "SavedQuery") -> bool:
return self.metrics == old.metrics

def same_group_bys(self, old: "SavedQuery") -> bool:
return self.group_bys == old.group_bys
def same_group_by(self, old: "SavedQuery") -> bool:
return self.group_by == old.group_by

def same_description(self, old: "SavedQuery") -> bool:
return self.description == old.description
Expand All @@ -1795,7 +1795,7 @@ def same_contents(self, old: Optional["SavedQuery"]) -> bool:

return (
self.same_metrics(old)
and self.same_group_bys(old)
and self.same_group_by(old)
and self.same_description(old)
and self.same_where(old)
and self.same_label(old)
Expand Down
2 changes: 1 addition & 1 deletion core/dbt/contracts/graph/unparsed.py
Original file line number Diff line number Diff line change
Expand Up @@ -727,7 +727,7 @@ class UnparsedSavedQuery(dbtClassMixin):
description: Optional[str] = None
label: Optional[str] = None
metrics: List[str] = field(default_factory=list)
group_bys: List[str] = field(default_factory=list)
group_by: List[str] = field(default_factory=list)
where: Optional[Union[str, List[str]]] = None
config: Dict[str, Any] = field(default_factory=dict)

Expand Down
2 changes: 1 addition & 1 deletion core/dbt/parser/manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -1113,7 +1113,7 @@ def process_saved_queries(self, config: RuntimeConfig):
for saved_query in self.manifest.saved_queries.values():
# TODO:
# 1. process `where` of SavedQuery for `depends_on`s
# 2. process `group_bys` of SavedQuery for `depends_on``
# 2. process `group_by` of SavedQuery for `depends_on``
_process_metrics_for_node(self.manifest, current_project, saved_query)

def update_semantic_model(self, semantic_model) -> None:
Expand Down
2 changes: 1 addition & 1 deletion core/dbt/parser/schema_yaml_readers.py
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,7 @@ def parse_saved_query(self, unparsed: UnparsedSavedQuery) -> None:
description=unparsed.description,
label=unparsed.label,
fqn=fqn,
group_bys=unparsed.group_bys,
group_by=unparsed.group_by,
metrics=unparsed.metrics,
name=unparsed.name,
original_file_path=self.yaml.path.original_file_path,
Expand Down
2 changes: 1 addition & 1 deletion tests/functional/saved_queries/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
label: Test Saved Query
metrics:
- simple_metric
group_bys:
group_by:
- "Dimension('user__ds')"
where:
- "{{ Dimension('user__ds', 'DAY') }} <= now()"
Expand Down
2 changes: 1 addition & 1 deletion tests/functional/saved_queries/test_saved_query_parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def test_semantic_model_parsing(self, project):
saved_query = manifest.saved_queries["saved_query.test.test_saved_query"]
assert saved_query.name == "test_saved_query"
assert len(saved_query.metrics) == 1
assert len(saved_query.group_bys) == 1
assert len(saved_query.group_by) == 1
assert len(saved_query.where.where_filters) == 2
assert len(saved_query.depends_on.nodes) == 1
assert saved_query.description == "My SavedQuery Description"
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_graph_selector_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ def make_saved_query(pkg: str, name: str, metric: str, path=None):
path=path,
description="Test Saved Query",
metrics=[metric],
group_bys=[],
group_by=[],
where=None,
unique_id=f"saved_query.{pkg}.{name}",
original_file_path=path,
Expand Down

0 comments on commit 49edc69

Please sign in to comment.