TugQL

TugQL vs Malloy

Compare TugQL queries and TugQT trees with Malloy sources, views and analytical modeling.

Two read-query examples

These examples show each language's shape. They are not a claim that the two queries run against the same source or produce identical results.

TugQL

from Invoice as i
group by i.CustomerId
select i.CustomerId, COUNT(*) as InvoiceCount

Malloy

run: flights -> {
  group_by: carrier
  aggregate: flight_count
}

The Malloy example is from the Malloy query reference and assumes a defined flights source with a flight_count measure. The TugQL form follows the TugQL syntax reference; its aggregate still needs support in the chosen implementation and adapter.

Model and execution path

Malloy queries start from a source and transform it through views and stages. Its model can define reusable dimensions, measures and join relationships. Malloy compiles queries to SQL for supported database connections. The query reference and source reference describe those concepts.

TugQL is a SQL-like read-query language with a structured YAML/JSON representation called TugQT. Its Go implementation resolves a query to DALgo's model, then uses an adapter. That includes non-SQL paths such as Git-backed inGitDB, subject to feature and adapter support. TugQT can be reviewed as a query tree in Git; it is not a replacement for Malloy's semantic modeling features.

Which one fits?

Choose Malloy when the main task is reusable analytical modeling and exploration over its supported SQL connections. Consider TugQL when a caller needs a read-query representation that can target DALgo-backed sources, including a Git-backed source, or wants to save and diff the structured query itself. Verify the specific backend and language feature before relying on portability.

Sources: Malloy query reference; TugQL specification; DALgo TugQL implementation.

All documentation