How does Arcade handle nulls?

367
1
03-06-2022 11:48 PM
Bud
by
Notable Contributor

How does Arcade handle nulls?

Examples:

  1. Can we do math on nulls?
    • 1 + null = ?
  2. Can we concatenate nulls?
    • "foo" + null = ?
  3. How does aggregating on nulls work?
    • Average($layer, "flag_1")
    • If there are nulls in the "flag_1" field, will they be included in the average's count?
  4. Does null equal null?
  5. Does null not equal null?


Is there anything else about nulls that we should be aware of?

Thanks.

 

0 Kudos
1 Reply
JohannesLindner
MVP Frequent Contributor

Null values are basically handled like zero (or "" for strings), though I'm trying to get that changed.

 

 

Console("1 + null = " + (1 + null))
Console("'foo' + null = " + ('foo' + null))
Console("null == null = " + (null == null))
Console("null != null = " + (null != null))

Console("\nOther stuff:")
Console("Abs(null) = " + Abs(null))
Console("Min([null, 1, 2]) = " + Min([null, 1, 2]))

 

 

1 + null = 1
'foo' + null = foo
null == null = true
null != null = false

Other stuff:
Abs(null) = 0
Min([null, 1, 2]) = 0

 

How does aggregating on nulls work? If there are nulls in the "flag_1" field, will they be included in the average's count?

If you aggregate on a feature set, nulls will be filtered out (at least for Min). For arrays, You have to do it yourself.


Have a great day!
Johannes
0 Kudos