Question

Access to date dimensions from SQL:

  • 28 August 2021
  • 0 replies
  • 8 views

Why I can access to number or string fields, but not to Date fields?

view: test2 {
derived_table: {
sql:
WITH EX AS (
SELECT 1 as ID, 1 as age, 'Oleg' as name, PARSE_DATE("%Y-%m-%d", "2021-01-01") as dt
) SELECT * FROM EX ;;
}
dimension: name {
sql: ${TABLE}.name ;;
}
dimension: dt {
type: date
sql: ${TABLE}.dt ;;
}

measure: sum_by_name {
label: "SUM by name "
type: number
sql: (
select sum(age) from test2 as X
where TRUE
{% if test2Explore.name._in_query %} and X.name=${TABLE}.name {% endif %} -- OK
{% if test2Explore.gender._in_query %} and X.gender=${TABLE}.gender {% endif %} --OK
{% if test2Explore.dt._in_query %} and X.dt= ${TABLE}.dt {% endif %} -- ERROR
-- Query execution failed: - WHERE clause expression references
-- test2Explore.dt which is neither grouped nor aggregated at [33:39]
) ;;
}


 

 


This topic has been closed for comments