You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
aq.from([]).filter(d => d.key)
// or .derive({ test: d => d.key })
// or .groupby('key')
// or whatever
throws: Error: Invalid column reference: "d.key"
Why not return empty table if the input is empty?
My intuition from other libs (d3, lodash, Array.prototype) suggests, that if the input is empty, it should be safe.
d3.filter([], d => d.key) // → []
_.filter([], d => d.key) // → []
[].filter(d => d.key) // → []
If it's by design, what's the arquero way to handle empty inputs?
This seems like an awkward workaround:
Thanks for the question. Unlike an empty array (as with the other tools you mention) an empty table in Arquero has a schema describing which columns are defined. Disabling column checks for empty tables would introduce an inconsistency (and might possibly miss genuine errors!) and I'm unsure how much benefit it provides in return -- as soon as a table has one or more rows, the error would of course be raised.
To check if a table has zero rows you can use table.size or table.numRows(). Also feel free to describe your use case in more detail if you still see prevailing benefits for disabling column checks on zero-row tables.
Thanks for the clarification.
My use case is when I have no control on input data for aq.from(input). E.g. when it arrives from fetch or is filtered by brush on a chart.
So, sometimes the input array is empty during the interaction and it blows up the Observable notebook.
I understand, that the workaround to use here is arr.length ? aq.from(arr)... : [].
It just seems awkward in context of otherwise beautiful, declarative and chained flow that this great library provides.
Also in my mental model the schema have no sense for empty data. Whatever manipulation on empty data should produce the empty data. Like in multiplication on zero.
But in arquero it seems like whatever manipulation on empty data will produce error. It's like the empty data is wrong.
Anyway, thanks for your efforts! I'll update my mental model, so you can consider this issue resolved.
Minimal example:
throws:
Error: Invalid column reference: "d.key"
Why not return empty table if the input is empty?
My intuition from other libs (d3, lodash, Array.prototype) suggests, that if the input is empty, it should be safe.
If it's by design, what's the arquero way to handle empty inputs?
This seems like an awkward workaround:
The text was updated successfully, but these errors were encountered: