https://dagster.io/ logo
#ask-community
Title
# ask-community
e

Eric Larson

06/01/2022, 2:32 PM
With software defined assets, is there a way for an asset to access it’s previous value/materialization of itself? Two use cases would be to record metadata about what has changed since the last materialization, and the other as an option to just return the previous version if it is determined no update is needed, in the case of an expensive operation.
🤖 1
o

owen

06/01/2022, 4:20 PM
there's not a built-in way, but you can query the dagster db from inside the body of your asset. this would look something like:
Copy code
@asset
def my_querying_asset(context, some_upstream_asset):
    last_materialization = context.instance.get_latest_materialization_events(asset_keys=[AssetKey("my_querying_asset")])
    # ... do something
e

Eric Larson

06/01/2022, 4:58 PM
Thanks for the suggestion. If the idea is something other people find useful, an elegant way to handle it might be in the input argument to the asset if it includes itself, then it gets passed in a previous value if it exists and has a little loop arrow back to itself on the graph.
Copy code
@asset 
def my_asset(upstream_asset, my_asset):
1
2 Views