Canonical transform exist condition annotation

#1

Let’s suppose I have a canonical transform:

@canonicalTransform(condition=‘exists(assetId)’)
type TransformCanonicalXToAsset mixes Asset transforms CanonicalX {

id: ~ expression ‘assetId’

Is it needed to add the condition since it is mapped to the id? If assetId is undefined and the condition does not exist what will happen: Will it simply ignore the row or create an error?

Setting the id of a type through a stored calc
#2

The condition ensures that the transform TransformCanonicalXToAsset is executed only if assetId has a value in CanonicalX. If the condition does not exist, then the TransformCanonicalXToAsset is executed everytime CanonicalX is transformed. If entity type Asset does not have any required fields, then a new asset with system generated id would be created. If the entity type Asset has any required fields and those values are not supplied, then the TransformCanonicalXToAsset would error out.

#3

Thank you.
Since id will be required the canonical transform will error out if I don’t add the condition?

#4

To be clear id is not a required field; i.e. you CAN create an object without providing id value (platform will assign unique id in this case). So to answer original question is, yes, explicit condition is needed in such cases.