I am trying to create the dbt semantic layer. Which provide schema for apache superset.
Everything is oke, except that the superset can’t read the out put query, created by dbt metric flow. This is complied query:
Some example code or error messages
CASE
WHEN lead_opportunity_type = 'resale'
AND DATE_TRUNC('MONTH', DATE_TRUNC('DAY', DATE(lead_created_datetime + INTERVAL '7' HOUR))) >=
DATE_TRUNC('MONTH', CAST(CURRENT_DATE AS TIMESTAMP) - INTERVAL '1' MONTH) - INTERVAL '7' HOUR
AND lead_contact_group_id <> 111
AND lead_current_step >= 0
THEN
CAST(
SUM(
CASE
WHEN lead_created_datetime >=
(DATE_TRUNC('MONTH', CAST(CURRENT_DATE AS TIMESTAMP) - INTERVAL '2' MONTH) - INTERVAL '7' HOUR)
AND lead_created_datetime <
(DATE_TRUNC('MONTH', CAST(CURRENT_DATE AS TIMESTAMP) - INTERVAL '1' MONTH) - INTERVAL '7' HOUR)
AND order_current_step = 1
THEN 1
ELSE 0
END
) AS DOUBLE
)
/
CAST(
NULLIF(
SUM(
CASE
WHEN lead_created_datetime >=
(DATE_TRUNC('MONTH', CAST(CURRENT_DATE AS TIMESTAMP) - INTERVAL '2' MONTH) - INTERVAL '7' HOUR)
AND lead_created_datetime <
(DATE_TRUNC('MONTH', CAST(CURRENT_DATE AS TIMESTAMP) - INTERVAL '1' MONTH) - INTERVAL '7' HOUR)
AND order_current_step = 0
THEN 1
ELSE 0
END
), 0
) AS DOUBLE
)
END
This warning Superset’s message:
Error: TrinoUserError(type=USER_ERROR, name=EXPRESSION_NOT_AGGREGATE, message="line 1:630: '((CASE WHEN ((lead_opportunity_type = 'resale') AND (DATE_TRUNC('MONTH', DATE_TRUNC('DAY', DATE((lead_created_datetime + INTERVAL '7' HOUR)))) >= (DATE_TRUNC('MONTH', (CAST(current_date AS timestamp) - INTERVAL '1' MONTH)) - INTERVAL '7' HOUR)) AND (lead_contact_group_id <> 111) AND (lead_current_step >= 0)) THEN CAST(SUM((CASE WHEN ((lead_created_datetime >= (DATE_TRUNC('MONTH', (CAST(current_date AS timestamp) - INTERVAL '2' MONTH)) - INTERVAL '7' HOUR)) AND (lead_created_datetime < (DATE_TRUNC('MONTH', (CAST(current_date AS timestamp) - INTERVAL '1' MONTH)) - INTERVAL '7' HOUR)) AND (order_current_step = 1)) THEN 1 ELSE 0 END)) AS DOUBLE) END) / CAST(NULLIF(SUM((CASE WHEN ((lead_created_datetime >= (DATE_TRUNC('MONTH', (CAST(current_date AS timestamp) - INTERVAL '2' MONTH)) - INTERVAL '7' HOUR)) AND
(lead_created_datetime < (DATE_TRUNC('MONTH', (CAST(current_date AS timestamp) - INTERVAL '1'
MONTH)) - INTERVAL '7' HOUR)) AND (order_current_step = 0)) THEN 1 ELSE 0 END)), 0) AS DOUBLE))'
must be an aggregate expression or appear in GROUP BY clause", query_id=20241206_103915_00246_azw4v)
Farther more, it just run when i remove the filter expression.
Please help, It realy hard to find any documents or example for this concept.