Skip to main content

How do I add a label to all leaf nodes in my asset hierarchy?


Hi! We received this question from a partner and figured it could be useful for more of you, so sharing it here :)

 

Step 1

Create a label via the API

https://api.cognitedata.com/api/v1/projects/{project}/labels

Document Reference

https://docs.cognite.com/api/v1/#operation/createLabelDefinitions

 

Step 2

Run the following transformation query with the created label

select

  id, externalId,

  array("<created_label>") as labels

  from _cdf.assets

where id not in (select distinct parentId from _cdf.assets where parentId is not null)

 

E.g

Create label as “leaf_node”

select

  id, externalId,

  array("leaf_node") as labels

  from _cdf.assets

where id not in (select distinct parentId from _cdf.assets where parentId is not null)

0 replies

Be the first to reply!

Reply


Cookie Policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie Settings