cube-js / cube

📊 Cube — Universal semantic layer platform for AI, BI, spreadsheets, and embedded analytics
https://cube.dev
Other
18.01k stars 1.78k forks source link

Question: use it for datatable #624

Closed apuntovanini closed 3 years ago

apuntovanini commented 4 years ago

Couldn't find a category under which posting this, hope it's not completely off-topic. This is the scenario: our customers receive - let's say - donations to their specific campaigns. We provide them a nice table view which lists the donations. Users can filter, sort and group them like you expect from a view like this. Then our customers can build custom dashboards meshing donations data, contacts info, analytics, etc. For this case we're evaluating Cubejs, which seems addressing this scenario perfectly. So far so good.

Now, our table view allows to add custom fields, hide/show columns, etc. likewise Airtable does. Each column has its own "type" that defines its behaviour (again, like Airtable fields). For this we defined a fields / columns schema: donation campaign has a name column of type string, a category of type singleSelect (that maps to string but offers options), etc.

Being a schema that loops through all the possible columns, we asked ourself, what if we could use our fields definition as Cubejs dimensions and migrate to Cubejs schemas as to fulfill both the purposes (datatable and dashboard)? Does something like this make sense? Has Cubejs ever been applied to such a use-case? In the datatable view dimensions are not necessarily related to measure, and in a classic view the underlying query might just be "SELECT * from donation_campaigns", but it seems to us (even if we don't see it yet) that something more DRY can be done. Plus, dimensions cannot contain metadata right? Something I can add to the schema and read when needed in the availableDimensions (for instance)?

I struggle to make it clear, I'm sorry for that, I tried to look around for usages like this, couldn't find any, that's why I'm posting this...

paveltiunov commented 4 years ago

@apuntovanini Hey Andrea! Thanks for posting this! It's really great question! Actually what you describe as data table is OLTP use case when users operate on transactional data. And Cube.js is designed for OLAP use case when users operate on data in aggregated manner. Even if your UI looks the same under the hood those two problems are very different.

If you have highly dynamic schema you can just use schema generation to address it: https://cube.dev/docs/schema-generation#top, https://cube.dev/docs/schema-execution-environment.

apuntovanini commented 4 years ago

Thank you very much @paveltiunov for completely addressing my question, things are much clearer now (I missed some theory on this). We'll then maintain the two schemas, one for OLTP and one for OLAP, the latter with CubeJs. We may use our fields definition for some nice default dimensions and measures for user-defined fields (you can sum/average an integer, for instance). Thank you!