This directory contains user-defined functions
which mimic the behavior of proprietary functions in Teradata. Each UDF within this
directory will be automatically synchronized to the bqutil
project within the
td
dataset for reference in queries.
For example, if you'd like to reference the nullifzero
function within your query,
you can reference it like the following:
SELECT bqutil.td.nullifzero(0)
Returns the decimal representation of the first character in the string_expr
. Teradata docs
SELECT bqutil.td.ascii('y')
121
Returns the 1-based index of the first occurrence of string_expr2
inside string_expr1
. Teradata docs
SELECT bqutil.td.index('BigQuery', 'Query')
4
Returns the date of the last day in the month of the date_expr
. Teradata docs
SELECT bqutil.td.last_day('2019-07-05')
2019-07-31
Returns the number of months between date_expr1
and date_expr2
. Teradata docs
SELECT bqutil.td.months_between('2019-01-01', '2019-07-31')
, bqutil.td.months_between('2019-07-31', '2019-01-01')
-6, 6
Returns NUll
if the expr
evaluates to 0
. Teradata docs
SELECT bqutil.td.nullifzero(NULL)
, bqutil.td.nullifzero(0)
, bqutil.td.nullifzero(1)
NULL, NULL, 1
Returns 0
if the expr
evaluates to NULL
. Teradata docs
SELECT bqutil.td.zeroifnull(NULL)
, bqutil.td.zeroifnull(0)
, bqutil.td.zeroifnull(1)
0, 0, 1