Skip to main content

Data Types

Introduced or updated: v1.2.100

Databend stores data in strongly typed columns. This page summarizes the supported data types, how automatic/explicit conversions work, and what happens with NULL or default values.

Foundational Types

Data TypeAliasStorage / ResolutionMin ValueMax Value
BOOLEANBOOL1 byte
BINARYVARBINARYvariable
VARCHARSTRINGvariable
TINYINTINT81 byte-128127
SMALLINTINT162 bytes-3276832767
INTINT324 bytes-21474836482147483647
BIGINTINT648 bytes-92233720368547758089223372036854775807
FLOAT4 bytes (Float32)-3.40e383.40e38
DOUBLE8 bytes (Float64)-1.79e3081.79e308
DECIMAL16/32 bytes (precision ≤38/76)-(10^P-1)/10^S(10^P-1)/10^S

Date & Time Types

Data TypeAliasResolution / Notes
DATEDay precision
TIMESTAMPDATETIMEMicrosecond, session timezone output
TIMESTAMP_TZMicrosecond + stored offset
INTERVALMicroseconds, supports negative span

Structured & Semi-Structured Types

Data TypeSampleDescription
ARRAY[1, 2, 3]Ordered list of values with the same inner type.
TUPLE('2023-02-14','Valentine's Day')Fixed-length ordered list with declared element types.
MAP{'a': 1, 'b': 2}Key-value collection (internally tuples of key and value types).
VARIANT[1, {"name":"databend"}]JSON-like container that can mix primitives, arrays, and objects.
BITMAP<bitmap binary>Compressed bitmap optimized for membership and set operations.

Domain-Specific Types

Data TypeDescription
VECTORFloat32 embeddings for similarity search / ML workloads.
GEOMETRY / GEOGRAPHYSpatial objects stored in WKB/EWKB format.

Casting and Conversion

Explicit Casting

  • CAST(expr AS TYPE) uses ANSI syntax and fails when conversion is invalid.
  • expr::TYPE is the PostgreSQL-style shorthand.
  • TRY_CAST(expr AS TYPE) returns NULL instead of raising an error when conversion fails.

Implicit Casting (Coercion)

Databend performs automatic conversions in well-defined situations:

  1. Integers upcast to INT64. Example: UInt8 -> INT64.
  2. Numeric values upcast to FLOAT64 when necessary.
  3. Any type T can become Nullable(T) if a NULL appears in an expression.
  4. All types can upcast to VARIANT.
  5. Complex types coerce element-wise (Array<T> -> Array<U> when T -> U; same for tuples/maps).

When a target column is NOT NULL, explicitly cast to Nullable<T> or use TRY_CAST if your data may contain NULLs.

SELECT CONCAT('1', col);      -- safe (strings)
SELECT CONCAT(1, col); -- may fail if `col` can't coerce to number

NULL Handling and Defaults

Columns allow NULL values unless declared NOT NULL. When a NOT NULL column is omitted during INSERT, Databend writes a type-specific default value:

Type CategoryDefault
Integer0
Floating-point0.0
String / Binaryempty string / empty binary
Date1970-01-01
Timestamp1970-01-01 00:00:00
BooleanFALSE

Example:

CREATE TABLE test (
id INT64,
name STRING NOT NULL,
age INT32
);

INSERT INTO test (id, name, age) VALUES (2, 'Alice', NULL); -- allowed
INSERT INTO test (id, name) VALUES (1, 'John'); -- age becomes NULL
INSERT INTO test (id, age) VALUES (3, 45); -- name uses default ''

Use DESC test or SHOW CREATE TABLE test to inspect column defaults and nullability at any time.

Try Databend Cloud for FREE

Multimodal, object-storage-native warehouse for BI, vectors, search, and geo.

Snowflake-compatible SQL with automatic scaling.

Sign up and get $200 in credits.

Try it today