-
Notifications
You must be signed in to change notification settings - Fork 14
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: Referencing entities in where filter causes an error.
#258
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
kind: Fixes | ||
body: Referencing entities in where filter causes an error. | ||
time: 2024-01-29T11:00:34.690723-08:00 | ||
custom: | ||
Author: plypaul | ||
Issue: "256" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,7 +26,7 @@ class ParameterSetFactory: | |
@staticmethod | ||
def _exception_message_for_incorrect_format(element_name: str) -> str: | ||
return ( | ||
f"Name is in an incorrect format: '{element_name}'. It should be of the form: " | ||
f"Name is in an incorrect format: {repr(element_name)}. It should be of the form: " | ||
f"<primary entity name>__<dimension_name>" | ||
) | ||
|
||
|
@@ -87,14 +87,17 @@ def create_dimension(dimension_name: str, entity_path: Sequence[str] = ()) -> Di | |
@staticmethod | ||
def create_entity(entity_name: str, entity_path: Sequence[str] = ()) -> EntityCallParameterSet: | ||
"""Gets called by Jinja when rendering {{ Entity(...) }}.""" | ||
group_by_item_name = DunderedNameFormatter.parse_name(entity_name) | ||
if len(group_by_item_name.entity_links) > 0 or group_by_item_name.time_granularity is not None: | ||
structured_dundered_name = DunderedNameFormatter.parse_name(entity_name) | ||
if structured_dundered_name.time_granularity is not None: | ||
raise ParseWhereFilterException( | ||
f"Entity name is in an incorrect format: '{entity_name}'. " | ||
f"It should not contain any dunders (double underscores, or __)." | ||
f"Name is in an incorrect format: {repr(entity_name)}. " f"It should not contain a time grain suffix." | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: weird formatting with 2 separate strings on one line |
||
) | ||
|
||
additional_entity_path_elements = tuple( | ||
EntityReference(element_name=entity_path_item) for entity_path_item in entity_path | ||
) | ||
|
||
return EntityCallParameterSet( | ||
entity_path=tuple(EntityReference(element_name=arg) for arg in entity_path), | ||
entity_reference=EntityReference(element_name=entity_name), | ||
entity_path=additional_entity_path_elements + structured_dundered_name.entity_links, | ||
entity_reference=EntityReference(element_name=structured_dundered_name.element_name), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Curious why we don't allow passing granularity in the where filter?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We want to eliminate
entity__dimension__time_granularity
formats altogether, because it causes a ton of confusion for us and requires theoretically unbounded future restrictions on user names for things - like today you can't call a date columnday
. I mean, you shouldn't, but companies totally do this. Really, they can't call thingsextract_day
, either, but I suspect that's a rare corner case.Ideally, for input, the dunder will only ever establish a link between a primary entity and some attribute it points to (dimension, entity, whatever), rather than being "that thing that glues together a bunch of arbitrary stuff that we can't distinguish from user-land names for things."