I try to create a variable and add date filter widget, here is the native SQL query as question:
select dbtime,count(*) from cdr where dbtime >= {{start_date}} group by dbtime;
Note: dbtime column in cdr table (postgreSQL) has data type as “timestamp without time zone”
And I have tried to configure “filed filter” , map variable “start_date” to table “cdr” column dbtime, select Field widget type to be “single date” with default date as “2020-03-01”, but I get below error when run query:
ERROR: operator does not exist: boolean = date Hint: No operator matches the given name and argument type(s). You might need to add explicit type casts. Position: 225
I’m not sure it’s a bug or not, hope someone has hint.
Hi @quinn
Which version of Metabase? Please post “Diagnostic Info” from Admin > Troubleshooting.
If you use Field Filter, then do not include the column in the query - it should just be: select dbtime,count(*) from cdr where {{start_date}} group by dbtime;
@flamber, thank you! you are right, after I do “where {{ start_date}}” , the error is gone.
However, I noticed the it took a long time to “do science”, if I use native SQL without variable, like "where dbtime = ‘2020-03-01’, the result is instant.
but when I use “where {{ start_date}}” , it took a long time to return result.
Any clue?
@quinn
Which version of Metabase? Please post “Diagnostic Info” from Admin > Troubleshooting.
I’m guess that you’re perhaps using a relative date in the filter, which means that it will not use indexes - there’s an issue open about that: https://github.com/metabase/metabase/issues/11837 - upvote by clicking on the first post