Releases: metabase/mbql
MBQL 1.4.3
MBQL 1.4.2
- Fix normalization of native queries that are maps (e.g. MongoDB or Druid) (#25)
MBQL 1.4.0
- Switch to using
java.time
instead ofjava.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
- Add filter clause desugaring and negation logic. Two new functions:
mbql.u/desugar-filter-clause
andmbql.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
- Allow arbitrary keys in Join maps.
MBQL 1.3.3
- 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
MBQL 1.3.1
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
: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
- Added
:interval
clause. :+
expressions now support:interval
clause, currently only as the second argument.