DB_CAST

Syntax

DB_CAST( expression, native_type [ , param_1 [ , param_2 ] ] )

Description

Converts the expression expression to database's native type native_type.

The following type casts are supported:

Data sourceData typeNative data typeParameters for native typeComment
ClickHouseDateDate
ClickHouseDateDate32
ClickHouseFractional numberFloat32
ClickHouseFractional numberFloat64
ClickHouseFractional numberDecimalInteger, Integer
ClickHouseIntegerInt8
ClickHouseIntegerInt16
ClickHouseIntegerInt32
ClickHouseIntegerInt64
ClickHouseIntegerUInt8
ClickHouseIntegerUInt16
ClickHouseIntegerUInt32
ClickHouseIntegerUInt64
ClickHouseStringString
PostgreSQLArray of fractional numbersdouble precision[]
PostgreSQLArray of fractional numbersreal[]
PostgreSQLArray of fractional numbersnumeric[]Integer, Integer
PostgreSQLArray of integerssmallint[]
PostgreSQLArray of integersinteger[]
PostgreSQLArray of integersbigint[]
PostgreSQLArray of stringstext[]
PostgreSQLArray of stringscharacter varying[]
PostgreSQLArray of stringsvarchar[]
PostgreSQLFractional numberdouble precision
PostgreSQLFractional numberreal
PostgreSQLFractional numbernumericInteger, Integer
PostgreSQLIntegersmallint
PostgreSQLIntegerinteger
PostgreSQLIntegerbigint
PostgreSQLStringtext
PostgreSQLStringcharacterIntegerAlias: char
PostgreSQLStringcharacter varyingIntegerAlias: varchar
PostgreSQLStringcharIntegerAlias for character
PostgreSQLStringvarcharIntegerAlias for character varying

Argument types:

  • expressionArray of fractional numbers | Array of integers | Array of strings | Date | Fractional number | Integer | String
  • native_typeString
  • param_1Any
  • param_2Any

Return type: Same type as (expression)

Note

Only constant values are accepted for the arguments (native_type).

Examples

DB_CAST([float_value], "Decimal", 10, 5)
DB_CAST([float_value], "double precision")
DB_CAST([float_value], "numeric", 10, 5)

Data source support

ClickHouse 21.8, PostgreSQL 9.3.

Previous
Next