Skip to content

Data Type Casting

You can explicitly cast an expression, such as a column or the result of a function, to a specific data type by using CAST (or ::). See Explicit Casting.

Yellowbrick supports implicit casting in many cases. For example, if a query compares an INTEGER column to a VARCHAR column, an implicit cast occurs automatically. For details, see Implicit Casting.

Data Type Compatibility

To some extent, the ability to do explicit or implicit casting depends on data type compatibility. Yellowbrick data types fall into the following categories.

  • Date/time types: DATE, TIME, TIMESTAMP, TIMESTAMPTZ, INTERVAL

Note that INTERVAL is not supported as a stored column type.

  • Numeric types: SMALLINT, INTEGER, BIGINT, DECIMAL (NUMERIC), REAL (FLOAT4), DOUBLE PRECISION (FLOAT8)
  • Boolean type: BOOLEAN
  • UUID type: UUID
  • IP address type: IPV4, IPV6
  • MAC address types: MACADDR, MACADDR8
  • String or character types: VARCHAR, CHAR

Within these categories, implicit casting is more likely to work and explicit casting is less likely to be required. However, some types can cross these boundaries; for example, character types can be cast implicitly to all other types. See the tables under Implicit Casting and Explicit Casting for details. If a specific combination of "from" and "to" types is not shown in either of these tables, no such cast is possible, explicitly or implicitly.

See SQL Data Types for general information about supported types.

In This Section

Parent topic:SQL Data Types