Skip to main content

Type Functions

SyntaxDescriptionExampleNormal QueryPushdown QueryDefined as Computed ColumnSuggested as Computed Column
CAST(value AS type)Converts a value to a given type.Example 1: Converts time to string
CAST(CURRENT_DATE as varchar)
= 2018-10-10
✔️✔️✔️✔️
DATE<String>Converts a string to DATE type,
equaling to CAST(string AS date)
Example 1:
DATE'2018-10-10'
= 2018-10-10

Example 2: Gets the corresponding month of the string (use with time function, MONTH() )
MONTH(DATE'2018-10-10')
= 10
✔️✔️
TIMESTAMP<String>Converts a string to TIMESTAMP type,
equaling to CAST(string AS timestamp)
Example 1:
TIMESTAMP'2018-10-10 15:57:07
= 2018-10-10 15:57:07

Example 2: Gets the corresponding second of the string (use with time function, SECOND() )
SECOND(TIMESTAMP'2018-10-10 15:57:07')
= 7
✔️✔️

Note:

  1. Only the following types of conversions are supported: char, varchar, boolean, int, integer, tinyint, smallint, bigint, float, double, decimal, numeric, date, time, timestamp
  2. However, conversion from bigint to timestamp is not supported at this time
  3. If converting from char to int, non-numeric values in char will return null
  4. Length n does not take effect when other data types are converted to char(n)/varchar(n)