Defaulting mandatory fields from a canonical type


#1

We are loading some data with Canonicals that have mandatory fields defined, but they were never delivered by the source system. This was fine for version 7.2 as there wasn’t any strict checking during the load, but now that we are migrating to 7.6, this is causing issues.

Is there a way we can remix the existing canonicals where we have issues, to provide a default value for those fields that aren’t provided by the source system?


#2
type CanonicalType {
  fieldA: !string
  fieldB: !string
}
remix CanonicalType {
  field: ~ post default 'default_value'
  field: string = 'default_value'
}

#3

even when defaulting the value in that way, the dataload still seems to be expecting the field, and is complaining it is not there in the input file.
So the main question is, is it possible to indicate that this actually isn’t mandatory anymore.


#4

Just to add to this, as a conclusion. You can remix your canonical type to indicate it is not mandatory anymore as such:

remix CanonicalType {
@constraint(required=false)
field: ~
}

This results in it not required in your input file. You could still define a default value if you want, and think it is needed for further processing, but for us, this didn’t seem to be necessary for the way we were using the data.