Conversion Functions

The conversion functions allow you to manipulate the data types when retrieving data from the Query service.

FunctionReturn TypeInput ArgumentsDescription
cast(value as datatype)
  • Varchar
  • Integer
  • Real
  • Double
  • Fixed-precision decimal
  • value: Any of these data types: Varchar, Integer, Real, Double, Fixed-precision decimal
  • datatype: String
Use this function to convert an input value to specified datatype. The supported datatypes for conversion are varchar, integer, real, double, and fixed-precision decimal. For example:
  • SELECT cast(150 as varchar) returns 150 of type varchar
  • SELECT cast('1000' as integer) returns 1000 of type integer
try_cast(value as datatype)
  • Varchar
  • Integer
  • Real
  • Double
  • Fixed-precision decimal
  • Null
  • value: Any of these data types: Varchar, Integer, Real, Double, Fixed-precision decimal
  • datatype: String
Use this function to convert an input value to specified datatype. The supported datatypes for conversion are varchar, integer, real, double, and fixed-precision decimal. Returns null if the cast fails. For example:
  • SELECT try_cast(150 as varchar) returns 150 of type varchar
  • SELECT try_cast('1000' as integer) returns 1000 of type integer
typeof(arg)Data type of the input argument
  • arg: Any data type
Returns the data type of the input argument. For example:
  • SELECT typeof('cat') returns varchar(3)