Problem with Date Range filter to dashboards created by native query

I use Druid (imply-2.2.3) as data storage.

Created Metabase Questions I put on the dashboard and filter them all by Date Range.

When I try to add Date Range filter to question created by native query, metabase just can’t find timestamp field for filtering and says: ‘No valid fields

Same problem even if I convert question, created by UI constructor to native query by using “View native query” option:

Generated Native query to Druid:

{
    "intervals": ["1900-01-01/2100-01-01"],
    "granularity": {
        "type": "period",
        "period": "P1D",
        "timeZone": "UTC"
    },
    "context": {
        "timeout": 60000
    },
    "queryType": "timeseries",
    "dataSource": "DotmailerCampaign",
    "aggregations": [{
        "type": "javascript",
        "name": "sum",
        "fieldNames": ["numOpens"],
        "fnReset": "function() { return 0 ; }",
        "fnAggregate": "function(current, x) { return current + (parseFloat(x) || 0); }",
        "fnCombine": "function(x, y) { return x + y; }"
    }],
    "descending": false
}

What is missed?

Metabase doesn’t know the field types of the results of SQL/native queries, so in order to map dashboard filters to SQL/native cards you need to include a field filter variable in your query and map it to the field that you would like to filter on. See this doc for details: https://www.metabase.com/docs/latest/users-guide/13-sql-parameters.html

1 Like

Maz, thanks for your answer.

Looks like it’s not work for native Druid queries.
I don’t see Variables side panel of the native query builder for my defined variables:

I just add to query {{start_date}} and {{end_date}} variables.
Probably I need to do some special way to define a variable?

Operating system: Windows 10
Metabase version: Metabase 0.27.2
Metabase hosting environment: Windows 10, java version “1.8.0_131”
Metabase Application Database: mysql-5.6.38-winx64
external Data Storage: Druid (Imply 2.2.3)

@maz Is Field filter variable feature works for Druid?

Thanks.

This would be a really nice feature to have! Defining variables in custom Druid queries.

There’s an issue open for variable support in Druid:
https://github.com/metabase/metabase/issues/9184 - upvote by clicking :+1: on the first post