So I need to create dynamic date aggregation (day, week, month) using date trunc as a text filter. But I always got an error
A valid date part name is required at [2:31]
My query would be kinda like this where {{aggregation}} is a text filter where the user is supposed to type day/week/month
SELECT date_trunc(order_date, {{aggregation}}) as period,
FROM table a
I believe this happened because text filter automatically add single quote to the typed string, but date_trunc format in big query does not need single quote for the date part, any idea how to solve this? Thank you