Reducing with 0 when value is not there
question for the non-existent values:
when we sum over an attribute, say payment and for some records that this value is non-existent (which i believe typedb doesn't create any instance of that attribute for that particular entity?), how can i set 0 for those cases in my sum? I don't care about my entity just in my sum i want to replace n/e with 0.
here is a query, where $pa could be non-existent for some records:
(originally from @Reza )
3 Replies
@Reza sneak peak preview of optionals coming in 3.7.0 - but already available in the
match patterns in 3.5.x (undocumented until fully implemented):
try that, im not entirely sure how stable it is since we added tests for it for the next major releasethanks josh at least i didn't get any syntax error 🙂
does that ignore non-existent values or set it to 0? i don't want them to be ignored
try running
$pa will be None when not present, which in reduce is treated as 0