Can an asset check depend upon an asset, or a part...
# ask-ai
b
Can an asset check depend upon an asset, or a partition of an asset?
s
Yes, an asset check can depend upon an asset or a partition of an asset. According to the documentation, the
AssetCheckSpec
is often used as an argument to decorators that decorate a function that can execute multiple checks, such as
@asset
and
@multi_asset
. It defines one of the checks that will be executed inside that function. The
additional_deps
parameter within
AssetCheckSpec
allows you to specify additional dependencies for the check. These dependencies indicate that the check relies on these assets in some way, but the result of the check only applies to the asset specified by the
asset
parameter. This means that an asset check can be written to test that an asset has matching data with an asset in
additional_deps
, which could be a partition of an asset. Furthermore, the documentation mentions that when loading a dbt project into the asset graph, Dagster’s dbt integration can load all dbt tests as Asset Checks, which makes it easier to visualize the success and failure of those tests as they now show up on the Dagster asset that corresponds to the dbt models they’re checking. This implies that asset checks can be associated with specific assets or partitions that are being tested. However, it's important to note that while you can write a check against a partitioned asset, as of a certain version of Dagster, per-partition checks were not supported. Instead, you would need to summarize the state of all partitions into one pass/fail for the asset. There is an example in the documentation showing how to write a check on a partitioned asset by summarizing the state of all partitions. This may have changed in more recent versions, so it's always a good idea to check the latest documentation or release notes for updates on this functionality.