Find and apply suggestions to asset
As a data team ourselves, we understand that metadata curation can be time-consuming. To streamline this process, each time you fill in a metadata gap, Atlan looks for opportunities to reuse that information.
This is where trident suggestions 🔱 come into play. It provides metadata suggestions for similar assets.
You add the description "Information about customers" to a table called CUSTOMER.
-
Atlan searches for other tables named
CUSTOMERthat lack a description. -
Atlan then suggests "Information about customers" as the description for these other
CUSTOMERtables.
In Atlan's SDK, you can use the Suggestions object to
find and apply these recommendations to your assets.
Find suggestions
Find suggestions for a given asset:
- Java
- Python
- Kotlin
Table table = Table.get(
"default/snowflake/1720661835/db/schema/table"
); // (1)
SuggestionResponse response = Suggestions.finder(table) // (2)
.include(Suggestions.TYPE.GroupOwners)
.include(Suggestions.TYPE.UserDescription)
.maxSuggestions(5)
.withOtherType(View.TYPE_NAME)
.includeArchived(false)
.get(); // (3)
assertNotNull(response); // (4)
assertNotNull(response.getOwnerGroups());
assertNotNull(response.getUserDescriptions());
-
First, you need to retrieve the asset for which you want to find suggestions.
-
Start by building a
Suggestionsrequest by chaining the following methods:-
finder: specify the asset for which you want to find suggestions. -
include: add criteria to specify the types of suggestions to include in the search results. For this example, we're retrieving suggestions forGroupOwnersandUserDescription.Want to find suggestions for ALL types?
-
To include all suggestion types
(description, owner, tags, and terms):
Suggestions.includes(Arrays.asList(Suggestions.TYPE.values()))
:::
-
maxSuggestions: (Optional) specify the maximum number of suggestions to return. Defaults to5. -
includeArchived: (Optional) specify whether to include archived assets in the suggestions (true) or not (false). Defaults tofalse. -
withOtherType: (Optional) add a criterion to include another asset type in the suggestions.withOtherType
By default, we will only look for suggestions on
assets of the same type. You may want to expand this,
for example, by including View(s) when looking
for suggested metadata for Table(s).
:::
where: (Optional) add a criterion that must be present in every search result. (NOTE: These are translated to filters.)whereNot: (Optional) add a criterion that must not be present in any search result.
- Finally, to retrieve the suggestions, call the
.get()method. - The suggestion response contains a list of
suggestions for the requested types. You can access
specific suggestions by directly referencing the response attributes,
such as
response.getOwnerGroups()andresponse.getUserDescriptions().
from pyatlan.client.atlan import AtlanClient
from pyatlan.model.assets import Table
from pyatlan.model.suggestions import Suggestions
client = AtlanClient()
asset = client.asset.get_by_qualified_name(
qualified_name="default/snowflake/1720661835/db/schema/table",
asset_type=Table
) # (1)
response = (
Suggestions() # (2)
.finder(asset)
.include(Suggestions.TYPE.GROUP_OWNERS)
.include(Suggestions.TYPE.USER_DESCRIPTION)
.max_suggestion(5)
.with_other_type("View")
.include_archive(False)
.get(client=client) # (3)
)
assert response # (4)
assert response.owner_groups and response.owner_groups[0]
assert response.user_descriptions and response.user_descriptions[0]
-
First, you need to retrieve the asset for which you want to find suggestions.
-
Start by instantiating the
Suggestions()object. You can then build a suggestion request by chaining the following methods:-
finder: specify the asset for which you want to find suggestions. -
include: add criteria to specify the types of suggestions to include in the search results. For this example, we're retrieving suggestions forGROUP_OWNERSandUSER_DESCRIPTION.Want to find suggestions for ALL types?
-
To include all suggestion types
(description, owner, tags, and terms),
you can directly pass Suggestions.TYPE.all() to the Suggestions:
Suggestions(includes=Suggestions.TYPE.all())
:::
-
max_suggestion: (Optional) specify the maximum number of suggestions to return. Defaults to5. -
include_archive: (Optional) specify whether to include archived assets in the suggestions (True) or not (False). Defaults toFalse. -
with_other_type: (Optional) add a criterion to include another asset type in the suggestions.with_other_type
By default, we will only look for suggestions on
assets of the same type. You may want to expand this,
for example, by including View(s) when looking
for suggested metadata for Table(s).
:::
where: (Optional) add a criterion that must be present in every search result. (NOTE: These are translated to filters.)where_not: (Optional) add a criterion that must not be present in any search result.
- Finally, to retrieve the suggestions, call the
.get()method. - The suggestion response contains a list of
suggestions for the requested types. You can access
specific suggestions by directly referencing the response attributes,
such as
response.owner_groupsandresponse.user_descriptions.
var table = Table.get(
"default/snowflake/1720661835/db/schema/table"
); // (1)
var response = Suggestions.finder(table) // (2)
.include(Suggestions.TYPE.GroupOwners)
.include(Suggestions.TYPE.UserDescription)
.maxSuggestions(5)
.withOtherType(View.TYPE_NAME)
.includeArchived(false)
.get(); // (3)
assertNotNull(response); // (4)
assertNotNull(response.getOwnerGroups());
assertNotNull(response.getUserDescriptions());
-
First, you need to retrieve the asset for which you want to find suggestions.
-
Start by building a
Suggestionsrequest by chaining the following methods:-
finder: specify the asset for which you want to find suggestions. -
include: add criteria to specify the types of suggestions to include in the search results. For this example, we're retrieving suggestions forGroupOwnersandUserDescription.Want to find suggestions for ALL types?
-
To include all suggestion types
(description, owner, tags, and terms):
Suggestions.includes(Suggestions.TYPE.values().toList())
:::
-
maxSuggestions: (Optional) specify the maximum number of suggestions to return. Defaults to5. -
includeArchived: (Optional) specify whether to include archived assets in the suggestions (true) or not (false). Defaults tofalse. -
withOtherType: (Optional) add a criterion to include another asset type in the suggestions.withOtherType
By default, we will only look for suggestions on
assets of the same type. You may want to expand this,
for example, by including View(s) when looking
for suggested metadata for Table(s).
:::
where: (Optional) add a criterion that must be present in every search result. (NOTE: These are translated to filters.)whereNot: (Optional) add a criterion that must not be present in any search result.
- Finally, to retrieve the suggestions, call the
.get()method. - The suggestion response contains a list of
suggestions for the requested types. You can access
specific suggestions by directly referencing the response attributes,
such as
response.getOwnerGroups()andresponse.getUserDescriptions().
Apply suggestions
Apply suggestions to a given asset:
- Java
- Python
- Kotlin
Table table = Table.get(
"default/snowflake/1720661835/db/schema/table"
); // (1)
SuggestionResponse response = Suggestions.finder(table) // (2)
.include(Suggestions.TYPE.GroupOwners)
.include(Suggestions.TYPE.UserDescription)
.maxSuggestions(5)
.withOtherType(View.TYPE_NAME)
.includeArchived(false)
.apply(true); // (3)
assertNotNull(response); // (4)
assertNotNull(response.getUpdatedAssets())
- First, retrieve the asset for which you want to apply suggestions.
- Start by building
Suggestionsrequest in the same way as described in Find suggestions section, since here we first find the suggestions and then apply them. - To apply the suggestions, call the
.apply()method. Optionally, you can setallowMultipletotrueto allow multiple suggestions to be applied to the asset (up to themaxSuggestionsrequested), such as for owners, terms, and tags. - The
AssetMutationResponsewill contain the updated asset entities.
from pyatlan.client.atlan import AtlanClient
from pyatlan.model.assets import Table
from pyatlan.model.suggestions import Suggestions
client = AtlanClient()
asset = client.asset.get_by_qualified_name(
qualified_name="default/snowflake/1720661835/db/schema/table",
asset_type=Table
) # (1)
response = (
Suggestions() # (2)
.finder(asset)
.include(Suggestions.TYPE.GROUP_OWNERS)
.include(Suggestions.TYPE.USER_DESCRIPTION)
.max_suggestion(5)
.with_other_type("View")
.include_archive(False)
.apply(client=client, allow_multiple=True) # (3)
)
assert response and response.mutated_entities # (4)
assert response.mutated_entities.UPDATE
assert response.mutated_entities.UPDATE[0]
- First, retrieve the asset for which you want to apply suggestions.
- Start by instantiating the
Suggestions()object. You can then build a suggestion request in the same way as described in Find suggestions section, since here we first find the suggestions and then apply them. - To apply the suggestions, call the
.apply()method. Optionally, you can setallow_multipletoTrueto allow multiple suggestions to be applied to the asset (up to themax_suggestionsrequested), such as for owners, terms, and tags. - The
AssetMutationResponsewill contain the mutated asset entities.
var table = Table.get(
"default/snowflake/1720661835/db/schema/table"
); // (1)
var response = Suggestions.finder(table) // (2)
.include(Suggestions.TYPE.GroupOwners)
.include(Suggestions.TYPE.UserDescription)
.maxSuggestions(5)
.withOtherType(View.TYPE_NAME)
.includeArchived(false)
.apply(true); // (3)
assertNotNull(response); // (4)
assertNotNull(response.getUpdatedAssets())
- First, retrieve the asset for which you want to apply suggestions.
- Start by building
Suggestionsrequest in the same way as described in Find suggestions section, since here we first find the suggestions and then apply them. - To apply the suggestions, call the
.apply()method. Optionally, you can setallowMultipletotrueto allow multiple suggestions to be applied to the asset (up to themaxSuggestionsrequested), such as for owners, terms, and tags. - The
AssetMutationResponsewill contain the updated asset entities.