Table of Contents
The temporal QUADBIN cell index type tquadbin represents the movement of objects as a sequence of QUADBIN square cell identifiers. CARTO's QUADBIN is a hierarchical square grid system built on the slippy-map (web-mercator) tile scheme: a single world cell at resolution 0 subdivides into four equal children at every finer resolution (up to 26). Each cell has a 64-bit integer identifier that encodes a header tag, the resolution, and the tile coordinates of the cell.
The tquadbin type shares its on-disk representation with tbigint: both store a temporal 64-bit integer. The distinct SQL type exists purely to let the type-checker reject quadbin-specific functions when applied to arbitrary bigint trajectories (and vice-versa). Casts to / from tbigint are explicit (AS ASSIGNMENT) and binary-coercion only — zero-cost at runtime but requiring an explicit :: in SQL.
As with other temporal types, tquadbin has four subtypes: Instant, discrete-sequence, continuous-sequence with step interpolation (QUADBIN cells are discrete — linear interpolation is meaningless), and SequenceSet.
Operational guidance on when to choose tquadbin over tgeompoint or tgeogpoint; the quadbin-specific hazards consumers should anticipate (int64 ordering arbitrary with respect to grid geometry, resolution mixing in operations, web-mercator latitude limit, antimeridian behaviour); and the durability and storage conventions are collected in the section called “Operational notes”.
A tquadbin value is entered using the standard temporal syntax with the underlying 64-bit QUADBIN cell identifier. The input parser accepts both the canonical hexadecimal form and the equivalent unsigned decimal. Hexadecimal is idiomatic in the QUADBIN ecosystem and is what the output function emits — all examples below use it. For reference, the hex value 480fffffffffffff used in the examples is the resolution-0 world cell, equal to the decimal value 5192650370358181887.
SELECT tquadbin '480fffffffffffff@2001-01-01';
SELECT tquadbin '{480fffffffffffff@2001-01-01, 48427fffffffffff@2001-01-02}';
SELECT tquadbin '[480fffffffffffff@2001-01-01, 48427fffffffffff@2001-01-02]';
SELECT tquadbin '{[480fffffffffffff@2001-01-01, 48427fffffffffff@2001-01-02],
[48a6227affffffff@2001-01-03, 485623ffffffffff@2001-01-04]}';
The type accepts type modifiers (typmod) to constrain a column to a specific subtype: Instant, Sequence, or SequenceSet.
SELECT tquadbin(Instant) '480fffffffffffff@2001-01-01';
SELECT tquadbin(SequenceSet) '{[480fffffffffffff@2001-01-01, 48427fffffffffff@2001-01-02]}';
-- ERROR: temporal type (Instant) does not match column type (Sequence)
SELECT tquadbin(Sequence) '480fffffffffffff@2001-01-01';
The function arrowRoundtrip converts a temporal QUADBIN index to the Arrow C Data Interface and reconstructs it, returning a value equal to the input.
SELECT arrowRoundtrip(tquadbin '480fffffffffffff@2001-01-01'); -- 480fffffffffffff@2001-01-01