
Query Library: One Published Query Behind Many Charts
A query library is a shared catalog of queries that a team has checked and published for reuse. A chart refers to a query in the library and does not hold its own copy of the SQL. When ten charts need "monthly revenue", all ten read the same query, so all ten show the same number.
In analytics the term means stored queries, not a code package. Developers also use "query library" for software that helps an application fetch data, which is a different thing.
What Does a Query Library Contain?
- The query. The SQL, written once.
- A name and a description. What the query returns and what it counts, in words a non-author can follow.
- A status. Draft or published. Only published queries can be used.
- A version history. Every publish is a new version, and earlier versions are kept.
- A place. Folders or tags, so a query can be found again.
- Where it is used. The charts and dashboards that read from it.
How Charts Use a Query Library
A chart attaches a published query and then adds its own grouping, filters and chart type on top. The calculation stays in the library.
When the query changes, the edit is published as a new version. In a library with version pinning, each chart stays on the version it was built with until someone moves it, so a definition never changes under a dashboard unnoticed.
Query Library and Semantic Layer
Both give a metric one definition. A query library stores finished queries that people wrote. A semantic layer stores measures, dimensions and joins, and writes the query itself for each request.
A query library is faster to set up because it uses the SQL a team already has. A semantic layer answers a wider range of questions and needs the data to be modelled first.
Query Libraries in Customer-Facing Analytics
When a product lets its customers build their own charts, the library is the set of calculations they are allowed to build from. The customer picks the metric and how to show it. The SQL stays with the team that owns it. The article on how a query library keeps every chart on the same number explains this in full.
The library controls the calculation, not who sees which rows. Limiting each customer to their own data is a separate rule: see multi-tenancy and row-level security.
Query Library Limits
A query library repeats whatever the query says. If the source data is wrong, every chart is wrong in the same way. It also does not decide what a metric should mean, and it needs an owner: without one, near-duplicate queries pile up and the library stops being the one place to look.