Skip to content
This repository has been archived by the owner on Aug 11, 2020. It is now read-only.

Releases: metabase/mbql

MBQL 1.4.3

13 Dec 23:49
086a5c2
Compare
Choose a tag to compare
  • Bumped metabase/common dependency from 1.0.4 to 1.0.6

MBQL 1.4.2

06 Dec 03:01
d3e078b
Compare
Choose a tag to compare
  • Fix normalization of native queries that are maps (e.g. MongoDB or Druid) (#25)

MBQL 1.4.0

04 Nov 22:03
a4ec087
Compare
Choose a tag to compare
  • Switch to using java.time instead of java.sql classes for temporal values (this primary affects internal clauses such as :absolute-datetime and QP code; i.e., it affects Metabase backend code but not frontend client code)

MBQL 1.3.6

24 Sep 21:36
1304ed7
Compare
Choose a tag to compare
  • Add filter clause desugaring and negation logic. Two new functions: mbql.u/desugar-filter-clause and mbql.u/negate-filter-clause.

From 1.3.5, which I forgot to add a release for:

  • Fixed an issue with normalizing the :parameters key in native queries (#20)

MBQL 1.3.4

01 Aug 01:30
6ab1a9c
Compare
Choose a tag to compare
  • Allow arbitrary keys in Join maps.

MBQL 1.3.3

22 Jul 18:55
9b8eed5
Compare
Choose a tag to compare
  • Fix metabase.util/expression-with-name so it properly handles either keyword or string expression names, and provides better debugging output. (See 432197e)

MBQL 1.3.2

19 Jul 01:18
Compare
Choose a tag to compare
  • Allow multiple interval arguments when doing datetime arithmetics (#14)
  • Make expression-with-name work with nested queries (#13)

MBQL 1.3.1

12 Jul 19:46
a1d46ff
Compare
Choose a tag to compare

Replace :named aggregation clauses with new :aggregation-options clause.

Prior to Metabase 0.33.0, you could specifiy custom names for aggregations in MBQL by wrapping the clause in a
:named clause:

[:named [:count] \"My Count\"]

This name was used for both the :display_name in the query results, and for the :name used as an alias in the query (e.g. the right-hand side of a SQL AS expression). Because some custom display names weren't allowed by some drivers, or would be transformed in some way (for example, Redshift always lowercases custom aliases), this method was needed so we could match the name we had given the column with the one in the query results.

In 0.33.0, we started using :named internally to alias aggregations in middleware in all queries to prevent issues with referring to multiple aggregations of the same type when that query was used as a source query. See #9767 for more details. After this change, it became desirable to differentiate between such internally-generated aliases and display names, which need not be used in the query at all; thus in MBQL 1.3.x :named was replaced by the more general :aggregation-options. Because user-generated names are no longer used as aliases in native queries themselves, this method is no longer needed and will be removed in a future release.

MBQL 1.2.0

02 Jul 18:44
f4f5c85
Compare
Choose a tag to compare

:named aggregation clause now supports and optional third parameter, options. It looks like this:

[:named <aggregation-clause> "custom name" {:use-as-display-name? <boolean>}]

:use-as-display-name? means whether the custom name should be used as both the display name and the underlying column :name in the query. By default, this is true; for internally-generated :named this can be set to false so we can still use nice auto-generated names like sum of Price.

Background

Previously, we did not automatically alias all aggregations (except in certain drivers like BigQuery), so a query like

{:aggregation [[:sum [:field-id field-1]]
               [:sum [:field-id field-2]]]}

would result in :cols in QP results like

{:cols [{:name "sum", :display-name "sum of Field 1"}
        {:name "sum", :display-name "sum of Field 2"}]}

Ambiguous/duplicate column names meant these aggregations could not be referred to using the :field-literal clause if the query was used as a source query -- see metabase/metabase#9767.

To fix this, new pre-alias-aggregations middleware was added to Metabase 0.33.0, which transformed the query to the following:

{:aggregation [[:named [:sum [:field-id field-1]] "sum"]
               [:named [:sum [:field-id field-2]] "sum_2"]]}

However, the results lost the "nice" auto-generated display names:

{:cols [{:name "sum",   :display-name "sum"}
        {:name "sum_2", :display-name "sum_2"}]}

To resolve this issue, the options map was added to :named, and the utility function metabase.mbql.util/pre-alias-and-uniquify-aggregations now adds {:use-as-display-name? false} by default. Thus the middleware now produces:

{:aggregation [[:named [:sum [:field-id field-1]] "sum"   {:use-as-display-name? false}]
               [:named [:sum [:field-id field-2]] "sum_2" {:use-as-display-name? false}]]}

which gives us the results:

{:cols [{:name "sum",   :display-name "sum"}
        {:name "sum_2", :display-name "sum of Price"}]}

MBQL 1.1.0

26 Jun 21:35
e0f411a
Compare
Choose a tag to compare
  • Added :interval clause.
  • :+ expressions now support :interval clause, currently only as the second argument.