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

Switch query parameter classes onto ExpandedTimeGranularity #1404

Merged
merged 2 commits into from
Sep 19, 2024

Conversation

tlento
Copy link
Contributor

@tlento tlento commented Sep 9, 2024

In preparation for supporting user-provided custom granularity names
at query time we need to update our query parameter processing
layer to use ExpandedTimeGranularities internally while accepting
string names from the original user input.

This change makes that update, although it is necessarily incomplete.
The TimeDimensionCallParameterSet, in particular, still uses an
enumeration-typed property for representing the user-requested grain,
but this interface is imported from dbt-semantic-interfaces and will
be updated in a later series of changes.

Follow-ups inside MetricFlow will enable lookups against custom granularity
values as we solidify our test layouts.

Copy link
Contributor Author

tlento commented Sep 9, 2024

Copy link

github-actions bot commented Sep 9, 2024

Thank you for your pull request! We could not find a changelog entry for this change. For details on how to document a change, see the contributing guide.

1 similar comment
Copy link

github-actions bot commented Sep 9, 2024

Thank you for your pull request! We could not find a changelog entry for this change. For details on how to document a change, see the contributing guide.

@@ -80,14 +81,18 @@ def spec_pattern(self, input_str: str, semantic_manifest_lookup: SemanticManifes
ParameterSetField.DATE_PART,
]

time_granularity = None
Copy link
Contributor

Choose a reason for hiding this comment

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

surprised this didn't require a type annotation 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good call, I'll add one just to make future errors less confusing.

As for why it's not required, MyPy works in mysterious ways...... but in this case the type assignment flow is simple. In the end it can only be None | ExpandedTimeGranularity because there's just that one conditional branch below. If someone inserts another branch with a new potential type assignment that'll alter the type to None | ExpandedTimeGranularity | whatever and we'll get a confusing type error at the point where we try to pass this variable into EntityLinkPatternParameterSet.from_parameters.

@@ -136,13 +120,10 @@ def match(self, candidate_specs: Sequence[InstanceSpec]) -> Sequence[LinkableIns
# Entity links could be a partial match, so it's handled separately.
if ParameterSetField.ENTITY_LINKS in self.parameter_set.fields_to_compare:
filtered_candidate_specs = self._match_entity_links(filtered_candidate_specs)
# Time granularities are special, so they are also handled separately.
Copy link
Contributor

Choose a reason for hiding this comment

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

So we just won't check this field anymore ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We check it via the standard comparison, see the change below to the set.difference() call.

@@ -261,8 +261,6 @@ def test_case(
if date_part or grain:
if date_part:
kwargs["date_part"] = DatePart(date_part)
if grain:
Copy link
Contributor

Choose a reason for hiding this comment

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

how did this not break anything 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the fix for a change to TimeDimensionParameter above.

We no longer need to convert the string input to a TimeGranularity in the TimeDimensionParameter initializer - it accepts string values - so without this change we were passing an incorrectly typed value in for that argument and weird runtime failures were cropping up.

@tlento tlento changed the base branch from make-semmantic-manifest-lookup-available-for-spec-patterns to graphite-base/1404 September 18, 2024 18:49
@tlento tlento force-pushed the move-parameter-classes-to-expanded-granularity branch from d1e9e0f to 387d2ec Compare September 18, 2024 18:54
@tlento tlento changed the base branch from graphite-base/1404 to main September 18, 2024 18:55
In preparation for supporting user-provided custom granularity names
at query time we need to update our query parameter processing
layer to use ExpandedTimeGranularities internally while accepting
string names from the original user input.

This change makes that update, although it is necessarily incomplete.
The TimeDimensionCallParameterSet, in particular, still uses an
enumeration-typed property for representing the user-requested grain,
but this interface is imported from dbt-semantic-interfaces and will
be updated in a later series of changes.

Follow-ups inside MetricFlow will enable lookups against custom granularity
values as we solidify our test layouts.
@tlento tlento force-pushed the move-parameter-classes-to-expanded-granularity branch from 387d2ec to 42c064e Compare September 18, 2024 18:55
@tlento tlento added the Run Tests With Other SQL Engines Runs the test suite against the SQL engines in our target environment label Sep 18, 2024
@tlento tlento temporarily deployed to DW_INTEGRATION_TESTS September 18, 2024 20:23 — with GitHub Actions Inactive
@tlento tlento temporarily deployed to DW_INTEGRATION_TESTS September 18, 2024 20:23 — with GitHub Actions Inactive
@tlento tlento temporarily deployed to DW_INTEGRATION_TESTS September 18, 2024 20:23 — with GitHub Actions Inactive
@tlento tlento temporarily deployed to DW_INTEGRATION_TESTS September 18, 2024 20:23 — with GitHub Actions Inactive
@github-actions github-actions bot removed the Run Tests With Other SQL Engines Runs the test suite against the SQL engines in our target environment label Sep 18, 2024
@tlento tlento merged commit ca16c13 into main Sep 19, 2024
26 checks passed
@tlento tlento deleted the move-parameter-classes-to-expanded-granularity branch September 19, 2024 17:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants