materialize
materialize copied to clipboard
sql: support `trunc`
Feature request
trunc is a Postgres function that truncates (rounds towards zero) numbers to a specific amount of decimal places, defaulting to zero if the second argument is missing.
Tableau uses trunc in its generated SQL code when extracting date components, and so this is required for Tableau support.
Hi @andrioni. I have a few clarifying questions
- Since you mentioned dates, I wanted to confirm the needed function is the numerical
trunc(https://www.postgresql.org/docs/current/functions-math.html) and notdate_trunc(https://www.postgresql.org/docs/current/functions-datetime.html#FUNCTIONS-DATETIME-TRUNC). - Assuming
trunc, do we need support for the two-argument function? Implementing the single-argument trunc (round to zero decimal places) is a lot less work, so ideally we could implement only that one to unblock Tableau.
Thanks! (cc @nmeagan11 )
Added support for single-param trunc function. Confirmed with @andrioni that Tableau only needs the single param function. Feel free to re-open or create a new ticket if we end up needing the two-param version.