Function table / Pass-through SQL / RAWSQL_DATETIME

RAWSQL_DATETIME: from Tableau to SQL

Evaluates a permitted scalar SQL expression with positional substitutions. Below, 8 sample rows go through the calculation and through the SQL, and both return the same numbers.

Calculated field

RAWSQL_DATETIME("CAST(%1 AS TIMESTAMP)", '2026-10-14 09:30:00')

Sample data

labelquantityamountflag
cedar cedar 6512.8True
ORCHID-west66-7.6False
maple-east670null
willow north6825.3True
birch-birch694.9False
pine/south70-1.2null
ash719True
nullnullnullnull

The same calculation as SQL

SELECT TIMESTAMP '2026-10-14 09:30:00' AS result FROM input

Runs the example above.

Result

result
2026-10-14 09:30:00
2026-10-14 09:30:00
2026-10-14 09:30:00
2026-10-14 09:30:00
2026-10-14 09:30:00
2026-10-14 09:30:00
2026-10-14 09:30:00
2026-10-14 09:30:00

Same rows from the calculation and from the SQL in DuckDB.

Where a naive translation goes wrong

  • RAWSQL embeds source-dialect SQL; replace the template for the target database.

    Naive SQL

    SELECT TIMESTAMP '2026-10-14 00:00:00' AS result FROM input
    result
    2026-10-14 00:00:00
    2026-10-14 00:00:00
    2026-10-14 00:00:00
    2026-10-14 00:00:00
    2026-10-14 00:00:00
    2026-10-14 00:00:00
    2026-10-14 00:00:00
    2026-10-14 00:00:00

    Matches the calculation

    SELECT TIMESTAMP '2026-10-14 09:30:00' AS result FROM input
    result
    2026-10-14 09:30:00
    2026-10-14 09:30:00
    2026-10-14 09:30:00
    2026-10-14 09:30:00
    2026-10-14 09:30:00
    2026-10-14 09:30:00
    2026-10-14 09:30:00
    2026-10-14 09:30:00

Signature

RAWSQL_DATETIME(constant_sql, [argument, ...])