How can I convert the AssetKey into array of strin...
# ask-ai
d
How can I convert the AssetKey into array of strings to get the subcomponents for constructing fqn
s
To convert an
AssetKey
into an array of strings that represent its subcomponents, you can access the
path
attribute of the
AssetKey
object. The
path
attribute is a sequence of strings that represents the hierarchical structure of the
asset_key
. Here's how you can do it based on the documentation:
Copy code
python from dagster import AssetKey  # Assuming you have an AssetKey object my_asset_key = AssetKey(["project", "dataset", "table"])  # To get the array of strings (subcomponents) subcomponents = my_asset_key.path  # subcomponents will be ["project", "dataset", "table"]
The
path
attribute will give you the list of strings that make up the hierarchical structure of the
AssetKey
. This list can be used to construct a fully qualified name (fqn) or for any other purpose where you need to access the individual components of the
AssetKey
.