Context: I have a dataset in Superset of parts - item ids, order year, avg annual cost. I'm trying to create what should be a super simple line chart showing the avg annual part cost by item over a annual time series. I'm a first time Superset user and I keep hitting the below error:
PostgreSQL Error function date_trunc(unknown, bigint) does not exist LINE 1: SELECT DATE_TRUNC('year', "Order_Year") AS __timestamp, HINT: No function matches the given name and argument types. You might need to add explicit type casts. This may be triggered by: Issue 1002 - The database returned an unexpected error. See less
It looks like typing issue but I'm very unclear how to resolve the issue. Below is the query in SQL Lab that generates the error:
SELECT DATE_TRUNC('year', "Order_Year") AS __timestamp,
"COST_TYPE" AS "COST_TYPE",
sum("Average_Annual_Part_Cost") AS "SUM(Average_Annual_Part_Cost)"
FROM "Part_Pricing_Unpivoted"
GROUP BY "COST_TYPE",
DATE_TRUNC('year', "Order_Year")
ORDER BY "SUM(Average_Annual_Part_Cost)" DESC
LIMIT 10000;
Question: Seems the DATE_TRUNC
function is problematic - but why? Can someone please help me understand what I'm doing wrong?
Thanks @ a_horse_with_no_name, you're correct. I changed the type to a YYY-MM-DD format and the date_trunc function behaved as expected. Issue resolved.