Description
When passing in columns, I'd like to be able to select data from an object when the keys in that object include full-stops.
For example, here is an entity from a KRM with 'annotations':
{ entity: { metadata: { annotations: { "example.com/custom-1": "foo"}}}
in this case I might want to try using a field
attribute of entity.metadata.annotations["example.com/custom-1"]
.
This syntax works for numbers (e.g. a[1]
), and KIND OF works for strings, as long as it doesn't contain full-stops.
This appears to come down to an implementation for 'byString' which first converts array syntax (a['key']
) to object notation (a.key
) before processing here:
Line 7 in 0899171
Background
I'm using a data Table through another tool, specifically Backstage. And Kubernetes Resource Models (KRM) is the standard notation for defining entities. This leads to objects like in the above example.
Suggested solution
I think there are two solutions, either:
- make field work for strings with array syntax with full-stops in keys
- allow an array to be passed in, that explicitly declares the keys
Whilst the first option is possible it has the potential to change behaviour for existing consumers (not that I can think of a scenario where a consumer would want the current behaviour if they have a key with a full-stop).
So I'd suggest (and have a PR ready) to implement the latter. But also happy to see this added in any way, and if not I've found a hack solution to work around (by passing in an object with an overloaded 'split' method).
Thanks
Thank-you for considering this issue. I'll follow up with a PR shortly.