Data Types

This page describes the data types that are available in Polars SQL.

Boolean

BOOLEAN

The boolean type has the values true and false.

SELECT TRUE, FALSE;
-- true, false

Integer

SMALLINT

Accepted as an integer type. It uses the same value range and behavior as INTEGER.

INTEGER

A signed integer type. The name INT is also available for this type.

BIGINT

A signed 64-bit integer type.

SELECT
    CAST(1 AS SMALLINT),
    CAST(1 AS INTEGER),
    CAST(1 AS INT),
    CAST(1 AS BIGINT);
-- 1, 1, 1, 1

Floating-Point

REAL

A single-precision floating-point type.

DOUBLE

A double-precision floating-point type.

SELECT CAST('1.5' AS REAL), CAST('1.5' AS DOUBLE);
-- 1.5, 1.5

String

VARCHAR

Variable length character data. Polars SQL accepts VARCHAR as the primary string type.

CHAR

Accepted as a string type alias. Polars SQL does not document fixed-length CHAR(x) padding and comparison semantics as supported.

Polars SQL supports ordinary string literals, escaped single quotes, and Unicode string literals with U& escapes.

SELECT CAST('abc' AS VARCHAR), CAST('abc' AS CHAR(7)), U&'A\0042';
-- abc, abc, AB

Date and Time

DATE

Calendar date.

Example: DATE '2024-03-15'

TIME

Time of day without a time zone.

Example: TIME '10:20:30'

TIMESTAMP

Date and time without a time zone.

Example: TIMESTAMP '2024-03-15 10:20:30'

SELECT
    DATE '2024-03-15',
    TIME '10:20:30',
    TIMESTAMP '2024-03-15 10:20:30';
-- 2024-03-15, 10:20:30, 2024-03-15 10:20:30.0