Skip to main content

Data types

Column types in DDL​

CREATE TABLE maps PostgreSQL types to LakeSoul's Arrow schema:

PostgreSQL typeStored asNotes
smallint, int2Int16
integer, int, int4Int32
bigint, int8Int64Required for primary-key columns of indexed tables
real, float4Float32
double precision, float8Float64
float(p)Float32 for p <= 24, Float64 for p <= 53Precision only
boolean, boolBoolean
text, varchar, charUtf8varchar(n)/char(n) keep their length in pg.typmod and enforce it on writes
uuidUtf8 + pg.type=uuidCanonical lowercase hyphenated text; UUID OID on the wire
one-dimensional array, e.g. INT[]List<element>Element type must be a supported scalar type; multidimensional arrays and array primary keys/partitions are rejected
jsonUtf8 + arrow.jsonOriginal JSON text is preserved
jsonbUtf8 + arrow.json + pg.jsonCanonical JSON text; duplicates and key order are normalized
dateDate32
time(p)Arrow Time32/Time64p 0, 3 or 6; other precisions are rejected
timestamp(p)Arrow Timestampp 0, 3 or 6; default is 6. Fractional digits beyond the unit are truncated
timestamptz(p)Arrow Timestamp in UTCSame precision rules
byteaBinary
numeric(p, s), decimal(p, s)Decimal128 for p <= 38, Decimal256 for 39 <= p <= 761 <= p <= 76, 0 <= s <= p
moneyDecimal128(19,2) + pg.type=moneyMONEY OID on the wire

numeric without a precision and scale is rejected; precision above 76 is rejected rather than silently truncated. interval and inet columns are not supported: Arrow has an interval type but the Parquet/Vortex writers cannot persist it, and Arrow has no inet type. Interval expressions still work.

money values written by INSERT, UPDATE, UPSERT and COPY accept PostgreSQL's $1,234.56 input syntax. A cast inside a larger expression (for example SELECT '$1.50'::money) only accepts the plain decimal form, because the cast goes through the Arrow decimal parser.

JSON columns​

json and jsonb are stored as UTF-8 text with the Arrow canonical arrow.json extension. The PostgreSQL front end additionally stores a pg.json marker so it reports the original OID (114 for json, 3802 for jsonb) on SELECT and through pg_attribute.

  • json keeps the document exactly as written.
  • jsonb is parsed and canonicalized when it enters through the PostgreSQL front end (parameters, COPY ... FROM STDIN, subscription writes): duplicate object keys keep their last value, keys are sorted, and insignificant whitespace is removed.
  • ->, ->>, #>, #>> and ? are available over both types.
  • Spark 3.5 and Flink 1.20 see these columns as ordinary strings, so the same table remains readable and writable outside PostgreSQL.

jsonb equality and ordering in LakeSoul are string equality and ordering over the canonical text, not PostgreSQL's binary jsonb comparison. Comparison operators such as @> are not implemented yet.

Arrays are column types as well as expressions (ARRAY[...], INTEGER[], 1-based indexing), and the wire protocol encodes and decodes them. A supported array column is one-dimensional and uses a supported scalar element type. INSERT, UPDATE, UPSERT and COPY handle array literals element by element, so UUID text is canonicalized, money text is accepted, numeric precision is preserved (including numeric above 38 digits) and varchar(n)[] element lengths are checked. Array primary keys and partition columns are rejected.

Query-side behaviour​

  • NULL semantics follow SQL three-valued logic: NULL is distinct from the empty string, COUNT(*) counts rows while COUNT(col) skips NULLs.
  • Decimals are exact. The engine returns NUMERIC with the column's scale; DECIMAL/NUMERIC values are not routed through floating point.
  • Timestamps are microsecond precision; timestamptz is normalised to UTC.
  • Integer arithmetic follows the column width; division and remainder follow SQL semantics for the operand types.

Known boundaries​

A few type differences are intentional and documented rather than hidden:

CaseLakeSoulPostgreSQL
COALESCE(integer_col, -1)INT8INT4
rank() / row_number() without a castNUMERICINT8
numeric precisionUp to 76 digits (Decimal256)Wider NUMERIC
timestamp precisionSeconds, milliseconds or microseconds (0/3/6)Configurable 0-6
char(n) paddingLength is enforced, trailing-space padding is not emulatedBlank-padded and comparison-insensitive

Values match; the OIDs may differ. Cast explicitly in a query if a client depends on the PostgreSQL type.

Next​