Accessing fields with special characters
Problem / use case
You want to access fields with special characters such as periods (.
), dashes (-
), spaces (), or emojis, etc...
Solution - $d
You usually donโt need to use $d
to access data fields in DataPrime. Itโs the default namespace, so fields like status_code
are automatically interpreted as $d.status_code
.
But in these cases with special characters using $d
is required.
1. Field names with dots
If your field name includes a dot (.
), DataPrime treats it as a nested path unless you use bracket notation. This can lead to unexpected behavior.
For example:
To access the field with a literal dot in the name (kubernetes.namespace
), use:
result
To access the nested field inside the kubernetes
object (kubernetes.namespace
), use:
result
2. Field names with spaces
Dot notation doesnโt support spaces. Use bracket notation:
3. Field names with emojis or non-ASCII characters
Fields with special characters require brackets:
create face from case_equals {
$m.severity,
DEBUG -> '๐ง',
VERBOSE -> '๐ถโ๐ซ๏ธ',
INFO -> '๐',
WARNING -> '๐ฌ',
ERROR -> '๐ฉ',
CRITICAL -> '๐',
_ -> '๐คท'
}
| countby face as $d['๐'] into $d['# of times I made this face']
Output:
"๐" | "# of times I made this face" |
---|---|
๐ | 17275 |
๐ฉ | 55821 |
๐ฌ | 13084 |
๐ถโ๐ซ๏ธ | 318376 |
๐ | 2958063 |
๐ง | 3727783 |