githubocto / flat-ui

MIT License
373 stars 23 forks source link

Support Apache Arrow tables #18

Closed domoritz closed 2 years ago

domoritz commented 2 years ago

Apache Arrow support a row iterator but not .map. It would be great if you could add explicit support for Apache Arrow as an efficient format for tabular data.

Here is a small example that doesn't work right now.

const int32_vector = arrow.Int32Vector.from([1,2,3]);
const my_table = arrow.Table.new(
  arrow.Column.new('column', int32_vector))

export default function App() {
  return <Grid data={my_table} />;
}
Wattenberger commented 2 years ago

I'm not super familiar with Apache Arrow, but it seems like an Apache-Arrow-specific fork of this library might be the best solution here. Happy to look at a PR if anyone knows differently, though!

domoritz commented 2 years ago

I think I disagree that we need a fork. Arrow tables are almost like arrays of objects but they don't have a map method. Since Arrow is emerging as a standard for tabular data in memory, I think it's be awesome if it worked out of the box with Flat UI.

As a work-around (albeit not very performant since we have to make a lot of copies), I got a working Grid with

<Grid data={[...my_table].map(Object.fromEntries)} />
Wattenberger commented 2 years ago

To provide a bit more of my reasoning, it looks as if the changes are much more than "use x instead of .map()". The performance enhancements of Arrow tables would be completely negated by the way flat-ui is handling the data, especially when it gets passed to react-window (which is necessary for rendering large tables). Since that's the case, your solution seems like the right way to combine the two, unless there were another fork of flat-ui that uses Apache Arrow under the hood, which I would love to see! Closing for now, but I'd love to see a PR that tackles this, if there's a simple solution that I'm missing!