Skip to content

Commit

Permalink
Rename group_bys field in SavedQueries to group_by.
Browse files Browse the repository at this point in the history
In the Github issue describing the saved query feature (#765), there was a typo
in the field name.
  • Loading branch information
plypaul committed Oct 24, 2023
1 parent a00ee84 commit 9d011fe
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion dbt_semantic_interfaces/implementations/saved_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def _implements_protocol(self) -> SavedQuery:

name: str
metrics: List[str]
group_bys: List[str] = []
group_by: List[str] = []
where: Optional[PydanticWhereFilterIntersection] = None

description: Optional[str] = None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@
"description": {
"type": "string"
},
"group_bys": {
"group_by": {
"items": {
"type": "string"
},
Expand Down
2 changes: 1 addition & 1 deletion dbt_semantic_interfaces/parsing/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@
"type": "array",
"items": {"type": "string"},
},
"group_bys": {
"group_by": {
"type": "array",
"items": {"type": "string"},
},
Expand Down
2 changes: 1 addition & 1 deletion dbt_semantic_interfaces/protocols/saved_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def metrics(self) -> Sequence[str]: # noqa: D

@property
@abstractmethod
def group_bys(self) -> Sequence[str]: # noqa: D
def group_by(self) -> Sequence[str]: # noqa: D
pass

@property
Expand Down
2 changes: 1 addition & 1 deletion dbt_semantic_interfaces/validations/saved_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class SavedQueryRule(SemanticManifestValidationRule[SemanticManifestT], Generic[
def _check_group_bys(valid_group_by_element_names: Set[str], saved_query: SavedQuery) -> Sequence[ValidationIssue]:
issues: List[ValidationIssue] = []

for group_by_item in saved_query.group_bys:
for group_by_item in saved_query.group_by:
# TODO: Replace with more appropriate abstractions once available.
parameter_sets: FilterCallParameterSets
try:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ saved_query:
metrics:
- bookings
- instant_bookings
group_bys:
group_by:
- TimeDimension('metric_time', 'DAY')
- Dimension('listing__capacity_latest')
where:
Expand Down
14 changes: 7 additions & 7 deletions tests/parsing/test_saved_query_parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,17 +86,17 @@ def test_saved_query_metrics_parsing() -> None:
assert {"test_metric_a", "test_metric_b", "test_metric_c"} == set(saved_query.metrics)


def test_saved_query_group_bys() -> None:
def test_saved_query_group_by() -> None:
"""Test for parsing group_bys in a saved query."""
yaml_contents = textwrap.dedent(
"""\
saved_query:
name: test_saved_query_group_bys
metrics:
- test_metric_a
group_bys:
- Dimension(test_entity__test_dimension_a)
- Dimension(test_entity__test_dimension_b)
group_by:
- Dimension('test_entity__test_dimension_a')
- Dimension('test_entity__test_dimension_b')
"""
)
Expand All @@ -106,9 +106,9 @@ def test_saved_query_group_bys() -> None:

assert len(build_result.semantic_manifest.saved_queries) == 1
saved_query = build_result.semantic_manifest.saved_queries[0]
assert len(saved_query.group_bys) == 2
assert {"Dimension(test_entity__test_dimension_a)", "Dimension(test_entity__test_dimension_b)"} == set(
saved_query.group_bys
assert len(saved_query.group_by) == 2
assert {"Dimension('test_entity__test_dimension_a')", "Dimension('test_entity__test_dimension_b')"} == set(
saved_query.group_by
)


Expand Down
2 changes: 1 addition & 1 deletion tests/test_implements_satisfy_protocols.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@

SAVED_QUERY_STRATEGY = builds(
PydanticSavedQuery,
group_bys=from_type(List[str]),
group_by=from_type(List[str]),
where=from_type(List[PydanticWhereFilter]),
description=OPTIONAL_STR_STRATEGY,
metadata=OPTIONAL_METADATA_STRATEGY,
Expand Down
8 changes: 4 additions & 4 deletions tests/validations/test_saved_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def test_invalid_metric_in_saved_query( # noqa: D
name="Example Saved Query",
description="Example description.",
metrics=["invalid_metric"],
group_bys=["Dimension('booking__is_instant')"],
group_by=["Dimension('booking__is_instant')"],
where=PydanticWhereFilterIntersection(
where_filters=[PydanticWhereFilter(where_sql_template="{{ Dimension('booking__is_instant') }}")],
),
Expand All @@ -66,7 +66,7 @@ def test_invalid_where_in_saved_query( # noqa: D
name="Example Saved Query",
description="Example description.",
metrics=["bookings"],
group_bys=["Dimension('booking__is_instant')"],
group_by=["Dimension('booking__is_instant')"],
where=PydanticWhereFilterIntersection(
where_filters=[PydanticWhereFilter(where_sql_template="{{ invalid_jinja }}")],
),
Expand All @@ -89,7 +89,7 @@ def test_invalid_group_by_element_in_saved_query( # noqa: D
name="Example Saved Query",
description="Example description.",
metrics=["bookings"],
group_bys=["Dimension('booking__invalid_dimension')"],
group_by=["Dimension('booking__invalid_dimension')"],
where=PydanticWhereFilterIntersection(
where_filters=[PydanticWhereFilter(where_sql_template="{{ Dimension('booking__is_instant') }}")],
),
Expand All @@ -112,7 +112,7 @@ def test_invalid_group_by_format_in_saved_query( # noqa: D
name="Example Saved Query",
description="Example description.",
metrics=["bookings"],
group_bys=["invalid_format"],
group_by=["invalid_format"],
where=PydanticWhereFilterIntersection(
where_filters=[PydanticWhereFilter(where_sql_template="{{ Dimension('booking__is_instant') }}")],
),
Expand Down

0 comments on commit 9d011fe

Please sign in to comment.