materialize icon indicating copy to clipboard operation
materialize copied to clipboard

sql: support `trunc`

Open andrioni opened this issue 3 years ago • 1 comments

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.

andrioni avatar Apr 11 '22 13:04 andrioni

Hi @andrioni. I have a few clarifying questions

  1. 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 not date_trunc (https://www.postgresql.org/docs/current/functions-datetime.html#FUNCTIONS-DATETIME-TRUNC).
  2. 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 )

chaas avatar Aug 08 '22 17:08 chaas

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.

chaas avatar Aug 12 '22 17:08 chaas