returnType property
Optional if language = "SQL"; required otherwise.
Cannot be set if routine_type = "TABLE_VALUED_FUNCTION". If absent, the
return type is inferred from definition_body at query time in each query
that references this routine. If present, then the evaluated result will
be cast to the specified returned type at query time. For example, for the
functions created with the following statements: * CREATE FUNCTION Add(x FLOAT64, y FLOAT64) RETURNS FLOAT64 AS (x + y);
* CREATE FUNCTION Increment(x FLOAT64) AS (Add(x, 1));
* CREATE FUNCTION Decrement(x FLOAT64) RETURNS FLOAT64 AS (Add(x, -1));
The return_type is {type_kind: "FLOAT64"}
for Add
and Decrement
, and is absent for Increment
(inferred as FLOAT64 at query time). Suppose the function Add
is
replaced by CREATE OR REPLACE FUNCTION Add(x INT64, y INT64) AS (x + y);
Then the inferred return type of Increment
is automatically changed to
INT64 at query time, while the return type of Decrement
remains FLOAT64.
Implementation
StandardSqlDataType? returnType;