Settings

Theme

Ask HN: Open-Source Query Builder

2 points by iFelix 2 years ago · 2 comments · 1 min read

Reader

I'm looking for a frontend library that would take a database schema as input, and then provide a visual query builder like Metabase that supports filtering and aggregation. The output would be SQL that I would then send to the server to get data and render charts/tables.

I'm surprised that this doesn't exist as many SaaS want to provide self-serve analytics to their users.

I've found 2 react query builder libraries but they don't support aggregation at all [1] [2].

Did I miss something? Any reason why this doesn't exist? If we built this open-source, would you use it?

[1] https://github.com/react-querybuilder/react-querybuilder [2] https://github.com/ukrbublik/react-awesome-query-builder

jakeboone02 2 years ago

Maintainer of `react-querybuilder` here. Couple of things:

Firstly, both RQB and RAQB facilitate the `WHERE` clause of a query, not the `SELECT`, `FROM`, or other clauses that would control aggregation.

Secondly, I would strongly discourage you from passing SQL from the client to the server, even if you parameterize it. For RQB, we recommend passing the native query object as JSON to your API and using our provided export method on the server to transform it into SQL (or whatever format you need).

Once in a blue moon I get requests for aggregation support in RQB, so to address your last question: yes, I think there would be some demand for something like that.

  • iFelixOP 2 years ago

    Oh nice that you saw this (even though the post was flagged only a couple minutes after launch, not sure why). Thanks for your reply!

    We have a model with 1-schema per tenant + we can create a dedicated Postgres user, so we don't have the same security risk multi-tenant apps would have. And I felt like passing SQL was the right long-term direction with text-to-sql LLMs. But I get your point.

    I guess what we're looking for is more "open source frontend lib for embedded analytics" than just a query builder then. This does not exist but seems like a lot of work to build.

Keyboard Shortcuts

j
Next item
k
Previous item
o / Enter
Open selected item
?
Show this help
Esc
Close modal / clear selection