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

dagster-dbt: get_metadata() should accept MutableMapping instead of Mapping #27153

Open
sotte opened this issue Jan 16, 2025 · 0 comments
Open
Labels
integration: dbt Related to dagster-dbt type: bug Something isn't working

Comments

@sotte
Copy link

sotte commented Jan 16, 2025

What's the issue?

I wanted to add some custom metadata fields to dbt assets. For this I created a custom DagsterDbtTranslator and implemented the get_metadata() method.
The method is defined like this:

    def get_metadata(self, dbt_resource_props: Mapping[str, Any]) -> Mapping[str, Any]:

SRC

Mapping implies that one should not change the mapping (and of course your linters tell you not to if you try "__setitem__" method not defined on type "Mapping[str, Any]").
Given that the docs say that one should add custom metadata fields this way, I would expect dbt_resource_props to be of type MutableMapping.

I suggest to either change the type annotation to MutableMapping or to make the docs clearer.

What did you expect to happen?

I expected either a MutableMapping or documentation that would be clearer.

How to reproduce?

Write your own translator like this:

class CustomDagsterDbtTranslator(DagsterDbtTranslator):
    def get_metadata(self, dbt_resource_props: Mapping[str, Any]) -> Mapping[str, Any]:
        metadata = super().get_metadata(dbt_resource_props)
        metadata["foo"] = "bar"
        return metadata

Dagster version

dagster, version 1.9.2

Deployment type

None

Deployment details

No response

Additional information

No response

Message from the maintainers

Impacted by this issue? Give it a 👍! We factor engagement into prioritization.

@sotte sotte added the type: bug Something isn't working label Jan 16, 2025
@garethbrickman garethbrickman added the integration: dbt Related to dagster-dbt label Jan 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
integration: dbt Related to dagster-dbt type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants