-
Notifications
You must be signed in to change notification settings - Fork 92
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
Rename Identifier -> Entity #490
Conversation
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. |
7751fd3
to
ea39e77
Compare
b885b6f
to
442aae0
Compare
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.
Working through it, need to make dinner. Renaming things is so terrible, sorry.
class Entity(HashableBaseModel, ModelWithMetadataParsing): | ||
"""Describes a entity""" | ||
|
||
name: str | ||
description: Optional[str] | ||
type: EntityType | ||
role: Optional[str] | ||
entities: List[CompositeSubEntity] = [] | ||
expr: Optional[str] = None | ||
|
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.
I think we should leave the metadata key here for now, as it's how we track lineage internally.
@QMalcolm this might be the time to rename metadata
to something more descriptive, like lineage_metadata
or lineage_info
or something.
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.
Update: We've decided to keep it for now. We might not use it right away, and we might refine it slightly before we do. The metadata as a concept can be incredibly useful for user experience.
UNIQUE = "unique" | ||
|
||
|
||
class CompositeSubEntity(HashableBaseModel): |
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.
This makes everything so gnarly, but let's just move it over for now and decide what to do with it later.
@@ -294,16 +294,16 @@ def _convert_dimensions( | |||
select_columns=select_columns, | |||
) | |||
|
|||
def _create_identifier_instances( | |||
def _create_entity_instances( |
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.
I am up to here.
442aae0
to
0bf7676
Compare
role: Optional[str] | ||
entities: List[CompositeSubEntity] = [] | ||
expr: Optional[str] = None | ||
metadata: Optional[Metadata] = None |
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 had it as Optional[Metadata]
without a default value. I added the default of None
to allow not having to explicitly set it to None
if we don't pass this property in.
@@ -24,3 +24,23 @@ more-itertools = "8.10.0" | |||
[build-system] | |||
requires = ["poetry-core>=1.0.0"] | |||
build-backend = "poetry.core.masonry.api" | |||
|
|||
[tool.black] |
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.
@QMalcolm added this cause there was some CI issues with different black configurations between MF and this repo.
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.
Review of first 10 commits. Will review the rest after lunch.
dbt_semantic_interfaces/dbt_semantic_interfaces/objects/elements/entity.py
Outdated
Show resolved
Hide resolved
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.
Whew. Massive!
Test assertion change is odd, what's up there?
@@ -197,4 +197,4 @@ def test_local_linked_elements_for_metric(metric_semantics: MetricSemantics) -> | |||
def test_get_data_sources_for_entity(data_source_semantics: DataSourceSemantics) -> None: # noqa: D | |||
entity_reference = EntityReference(element_name="user") | |||
linked_data_sources = data_source_semantics.get_data_sources_for_entity(entity_reference=entity_reference) | |||
assert len(linked_data_sources) == 9 | |||
assert len(linked_data_sources) == 8 |
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.
Wait what? Why?
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.
So basically, when I removed the entity property on the Identifier
class, I removed all the entity
fields on the test models. One of them was this 200445c#diff-e939351cfbeb60d978e42432cbfb25ebba45ff60f4ca48457712dad0eefd0ce3 and from get_data_sources_for_entity("user")
, that bookings_source
data source is no longer returned from that function call.
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.
Ok cool, that makes sense, thanks!
3830f87
to
d6becba
Compare
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.
Finished my first pass! 😂
raise RuntimeError( | ||
f"Could not find identifier instance with name ({identifier_spec_in_right_node})" | ||
) | ||
raise RuntimeError(f"Could not find identifier instance with name ({entity_spec_in_right_node})") |
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.
f"Could not find identifier ...
-> f"Could not find entity ...
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.
Looks like you caught this already, nice!
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.
LGTM, assuming all of the various snapshot tests pass across engines and @QMalcolm doesn't turn up any issues.
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.
I think we should dub this "The Great Renamen-ing". This looks good to me! (contingent that the remaining references to identifers
/ identifer
are planned to go away in the renaming of DataSource
to SemanticModel
resolves dbt-labs/dbt-semantic-interfaces#9
Description
In the new world of dbt-core x MetricFlow
Identifiers
are becomingEntities
. Additionally some of the properties of the object are changing. The resulting object should have the following propertiesThe above properties are were pulled from dbt-labs/dbt-core#7456