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

Update SemanticManifestTransformer to expect a generic bound by the SemanticManifest Protocol #21

Closed
Tracked by #7
QMalcolm opened this issue Apr 27, 2023 · 0 comments · Fixed by #77
Closed
Tracked by #7

Comments

@QMalcolm
Copy link
Collaborator

Currently the SemanticManifestTransformer (currently named ModelTransformer) expects and returns a UserConfiguredModel which is a concrete object. Initially we thought we should move to it expecting and returning a SemanticManifest protocol. However, in dbt-core we'll be writing nodes which extend the protocol definition. Additionally we want to be able to hand in raw-ish parsings and transform them into the final objects, meaning the input and return types should be different. If we want to be able to write transformation rules that can operate on the raw parsed objects, return the extended classes, and guarantee type safety, then we need to take it a step further. Thus the SemanticManifestTransformer should instead expect a generic and return a generic bound by the SemanticManifest protocol.

Something like...

from typing import TypeVar
from dbt_semantic_interfaces.protocols import SemanticManifest


T = TypeVar("T", bound="SemanticManifest")
U = TypeVar("U")

class SemanticManifestTransformer:
  ...

  @staticmethod
  def transform(
    raw_semantic_manifest: U,
    ordered_rule_sequences: Tuple[Sequence[SemanticManifestTransformRule], ...] = DEFAULT_RULES,
  ) -> T:
    ....
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant