Spatial SQL and query-shape support#
The generated matrix below is the admission index for the SQL frontend. Look up the statement, relation, scope, expression or group-key entry that matches your query, then check its exclusions and diagnostics. An admitted form has passed frontend checks. Admission alone does not establish that a GPU execution route exists for your operation and input declarations.
The matrix is emitted by support_matrix() and checked against the published fixture. It records matrix version 13, the PostgreSQL 17 parser (pg_query 6.1.1), the postgis:3.6.4:geometry:xy reference profile and the canonical catalog digest. It contains one statement, 22 relations, nine scopes, 67 expressions, eight group-key types, 21 exclusions and 17 acceptance groups. The digest is supplied by the emitter’s catalog. Use the generated matrix for its value.
Frontend admission#
The frontend admits exactly one bounded SELECT. Overload resolution uses the pinned reference catalog and its effective namespace before canonical admission. Declarations, including type and profile information, therefore matter independently of the SQL spelling. For the layer and geometry declarations needed by a file, see File formats, layers and coordinate metadata.
Find a query shape#
Lookup |
Admission and interpretation |
|---|---|
Relations and scopes |
Look here for declared and derived sources, bounded nonrecursive CTEs and scoped reads. A CTE is lowered as a shared derived relation. Later references get fresh output fields. |
Predicate subqueries |
Top-level |
Joins |
Inner, cross, comma and left joins are admitted. A right join is rewritten as a left join with swapped inputs while preserving the written output order. Full, natural and |
Nearest-neighbor LATERAL |
The admitted form orders ascending by distance with |
Grouping and aggregates |
Check group-key types and aggregate entries separately. The matrix describes null handling, result types, aggregate |
Windows |
|
Constants and casts |
Look up typed parameters and nulls, literal forms, permitted casts and type modifiers. Admission of a cast does not mean that rounding, truncation or arbitrary modifier checks are supported. |
Timestamps and decimals |
Look up timestamp, date and interval literal and arithmetic entries, and the decimal constant, conversion and aggregate entries. Time-zoned timestamps and calendar-month interval values outside the stated window-frame use are excluded. |
Scalar overloads |
Match argument types and optional arguments to the exact expression entry. For example, |
Geometry and geography execution#
Operation and input |
Verified execution or limit |
|---|---|
|
Planar geometry distance is distinct from geography distance. The |
|
The documented point overload measures lon/lat points on a sphere. The optional radius selects the sphere. Without it, the WGS 84 mean sphere returns metres. The entry specifies SRID and empty-input behavior. |
Geometry cast to geography, and |
Live tests cover WGS 84 Point, LineString, Polygon, their multi families and nested GeometryCollection. Distance and radius use metres. The optional strict |
|
The frontend admits the Geometry/Geometry signature. GPU execution constructs a LineString from XY Point operands, each a row value or a constant; present non-Point or non-XY operands are refused. The line can be returned or passed to consumers such as |
|
Literal target SRID admission is not itself evidence of a runtime transformation route. |
Other admitted forms |
Runtime coverage is unverified where an operation and its input declarations lack route evidence. Consult the matrix’s operation-specific limits and the execution tests before relying on a route. |
The geography coverage is checked in the live tests for distance, distance within a radius and geometry families.
Diagnostics#
The frontend reports Compiled, NeedsBindings or Invalid, with stable codes and byte offsets when the raw parser exposes them. The generated diagnostic and exclusion entries describe frontend outcomes. Execution can still refuse an admitted form when the required backend capability or input route is unavailable.
SQL support fixture SHA-256: d0c63348c207377f1f289ff9a7c6de4f632f1dcb3cd609ba0269de8fe0275cb4
Generated from support matrix version 13. SQL is parsed with the PostgreSQL 17 grammar; the reference profile is postgis:3.6.4:geometry:xy. The entries use the SQL frontend’s own terms: int4, int8 and float8 are integer, bigint and double precision, and lowered to or rewritten as names the equivalent form cuGeo evaluates.
Spatial functions at a glance#
Every spatial function the frontend admits in some form.
GeometryType, ST_Area, ST_AsBinary, ST_AsEWKB, ST_AsEWKT, ST_AsText, ST_Boundary, ST_Buffer, ST_Centroid, ST_Collect, ST_CollectionExtract, ST_Contains, ST_ConvexHull, ST_CoveredBy, ST_Covers, ST_Difference, ST_Distance, ST_DistanceSphere, ST_DWithin, ST_Envelope, ST_Equals, ST_GeometryType, ST_GeomFromText, ST_GeomFromWKB, ST_Intersection, ST_Intersects, ST_IsEmpty, ST_KNN (Apache Sedona), ST_Length, ST_MakeEnvelope, ST_MakeLine, ST_MakePoint, ST_MakeValid, ST_NPoints, ST_Point, ST_SetSRID, ST_SRID, ST_SymDifference, ST_Touches, ST_Transform, ST_UnaryUnion, ST_Union, ST_Within, ST_X, ST_XMax, ST_XMin, ST_Y, ST_YMax, ST_YMin
Statements#
one read-only SELECT
Query shapes#
Relations, joins, grouping, ordering and limits the frontend admits.
a table named in the query
non-LATERAL derived SELECT, aliased or not (an unaliased one’s columns resolve only unqualified)
bounded nonrecursive CTE lowered as one derived relation shared by every reference; later references rename outputs to fresh fields
SELECT without FROM
a SELECT list over any admitted input
WHERE, keeping the rows whose condition is TRUE
inner/cross/comma join
left join
right join, which cuGeo rewrites to a left join with swapped inputs and the written output order
planar per-left fixed-k
ST_KNNinner join over queries and targets of any geometry family, with positive literal int8 k and literal FALSE use_spheroidCROSS/INNER JOIN LATERAL or comma LATERAL (SELECT targets FROM … [WHERE …] ORDER BY outer <-> inner LIMIT k), k a literal in 1..=2147483647 and the key <-> or two-argument
ST_Distanceover one geometry of the enclosing FROM items and one of the lateral FROM items, ascending NULLS LAST, as the same planar per-left fixed-k KNN join with NULL distances (a NULL or EMPTY operand, or a distance not below the binary32 maximum) ranked last, so each outer row gets min(k, inner rows) rows; the targets are evaluated over the kept pairs only; INNER JOIN LATERAL ON filters the pairs and reads only that join’s inputs; a JOIN LATERAL comma item may read the comma items before itCROSS/INNER/comma LATERAL (SELECT scalar expressions) with no inner FROM, WHERE, ORDER BY or LIMIT, lowered to one projection per outer row with correlated fields and chained aliases
aggregation with or without GROUP BY
SELECT DISTINCT over every output, lowered to a keys-only aggregate
SELECT DISTINCT ON with ordering and whole-row selection
nonnegative literal bigint LIMIT
ORDER BY, including keys the select list drops (sorted below the projection, with or without LIMIT; not with DISTINCT or aggregates)
ORDER BY plus LIMIT
window functions in the SELECT list (ROW_NUMBER, RANK, DENSE_RANK, PERCENT_RANK, CUME_DIST, NTILE, LAG/LEAD with a constant (or NULL) offset and optional default, FIRST_VALUE, LAST_VALUE, and count/sum/avg/min/max) over PARTITION BY/ORDER BY, inline or through a named WINDOW clause, with ROWS and GROUPS frames (constant bigint offsets) and RANGE frames bounded by UNBOUNDED, CURRENT ROW or constant offsets of the type PostgreSQL’s in_range takes for the single ORDER BY key (int4/int8, numeric over a constrained numeric key, float8 with NaN and infinities, and intervals over date, timestamp and interval keys, calendar months included: PostgreSQL’s timestamp ± interval over date and timestamp keys, a month of 30 days over interval keys), over the grouped, HAVING-filtered rows with PostgreSQL 17 result types
uncorrelated one-column scalar expression subquery
uncorrelated EXISTS as a Boolean value
EXISTS, IN, op ANY and op ALL subqueries as top-level WHERE conjuncts under any number of NOTs, decorrelated into SEMI/ANTI joins (each input row kept at most once) on the subquery’s correlated WHERE conjuncts and the written comparison; NOT IN/ALL also remove rows whose comparison is UNKNOWN, as PostgreSQL does; a conjunct-free test is one scalar EXISTS; LIMIT 0 empties the subquery and other LIMITs are irrelevant to EXISTS
Spatial expressions#
ST_Intersects/ST_Contains/ST_Within/ST_Covers/ST_CoveredBy/ST_Touches/ST_Equals/ST_DWithingeometry overloads with at least one known geometry operandST_Distanceplanar Geometry/Geometry to nullable float8, distinct from DWithin; the PostGIS geometry <-> operator binds asST_Distance(its procedure is the same function)ST_DistanceSphere(geometry, geometry [, float8 radius]) great-circle distance between lon/lat Points to float8: on a sphere of the given radius (-1 for an EMPTY operand), or without a radius on WGS 84’s mean sphere in metres (NULL for an EMPTY operand; executes over operands of SRID 4326 or 0)ST_X/ST_Yover any Geometry to nullable float8: an empty Point is NULL and a present non-Point raises in the operation bodyST_MakeLineplanar Geometry/Geometry to LineString (Points and LineStrings join; another present family raises in the operation body), andST_Lengthplanar Geometry to float8 (0 for Point and polygonal families); stage execution constructs planar XY Point/Point LineStrings for results and supported consumers, while present non-Point or non-XY operands are refusedST_Intersection,ST_Difference, two-argumentST_UnionandST_SymDifferenceplanar Geometry/Geometry (no grid size),ST_ConvexHullplanar Geometry, andST_Areaplanar Geometry to float8ST_Unionover one Geometry expression as PostGIS’s aggregate: NULL inputs ignored, NULL with no present input, all-EMPTY inputs give EMPTY of the highest type among them, one nonempty polygon is returned unchanged, otherwise the planar XY union of Polygon and MultiPolygon inputs (other families are refused at run time; never over a window)ST_Collectover one Geometry expression, including normalizedST_Collect(ARRAY_AGG(Geometry)), as a duplicate-preserving, non-flattening, NULL-ignoring aggregateST_GeomFromWKBover binary values, with an optional literal integer SRID; explicit zero overrides encoded labels and remains distinct from unary; canonical GPU decode preserves coordinates, NULL/EMPTY and source declarations; native admission requires lineage to a READ-produced field and refuses decodes over aggregate results at Execution with CUGEO_GEOMETRY_CUDF_NOT_EXECUTABLE (missing_capability), even when Select admits them; over Geometry unary preserves the operand and its SRID, family, NULL/EMPTY and row domain, and a non-NULL int4 literal relabels it asST_SetSRIDdoes (PostGIS resolves it through the implicit geometry-to-bytea cast)a Binary/bytea source column where PostgreSQL’s overload resolution applies the implicit geometry(bytea) cast, as the same
ST_GeomFromWKBdecode; a call where geometry and geography overloads both match is ambiguous (42725) and one no overload accepts is undefined (42883), as in PostgreSQLST_GeomFromTextover a valid nonempty XY POINT or POLYGON string literal, retained exactly as a typed Geometry literalST_GeomFromText(text, 0),ST_MakePoint(x, y),ST_Point(x, y [, 0]) andST_MakeEnvelope(xmin, ymin, xmax, ymax [, 0]) lowered to catalog constructors over float8 ordinates; Normalize folds all-literal operands to the same typed WKT literal and a NULL operand to a typed NULL geometryST_SetSRID(geometry, int4 literal or NULL) uses canonical SRID labeling without coordinate transformation: negative labels clear CRS, labels above 999999 use PostGIS remapping, and NULL is STRICT; nonzero labels remain graph calls that GPU execution evaluates; a labeled source column is computed geometry: joins of labeled Point and Region columns run, whileST_DWithin/ST_Distancebetween two labeled per-row columns, joins of labeled columns of undeclared families and KNN joins refuse itsearched CASE and simple CASE (CASE x WHEN v: each WHEN is x = v under PostgreSQL equality, so a NULL x or v matches no WHEN), ELSE optional (a typed NULL when absent), lowered to ordered lazy CaseWhen occurrences over float8 or over one Boolean, int4, int8, Decimal, numeric, binary-comparison text, timestamp or interval type under PostgreSQL common-type resolution (exact numerics of different Decimal types resolve to unconstrained numeric), or over geometry values (the result covers the arms’ families and axes, and a NULL arm takes the other arm’s type)
COALESCE as one lazy n-ary catalog coalesce over the arguments’ common type (float8, one Boolean, int4, int8, Decimal, numeric, binary-comparison text, date, timestamp or interval type, or geometry), each argument evaluated only where every earlier one is NULL
GREATEST and LEAST over the common type COALESCE resolves: the largest (smallest) non-NULL argument under the type’s btree order (int4, int8, float8 with NaN above every value, numeric, date, timestamp, interval), the earliest of equal ones, NULL only when every argument is NULL; NULL constant arguments are dropped and a single remaining argument of any type is the result; two or more lower to one variadic canonical greatest/least call (two or more Boolean, text, bytea or geometry arguments are refused as unsupported, arguments with no common type as invalid)
ST_IsEmptyover any Geometry, NULL for a NULL operandST_Centroid,ST_EnvelopeandST_Buffer(geometry, float8 [, literal Int32 or Text option]) over any Geometry to Geometry (ST_Bufferadmits round, both-sided quadrant counts 1..65536, defaulting to 8, from an Int32 literal or Text style; typed NULL options are strict; other valid styles are Unsupported and invalid styles retain demanded XX000 errors; execution requires a distance constant over the rows; and buffers every family from GEOS 3.14’s offset curves; a row the engine cannot node in floating point is snap-rounded on its own grid, and only a row whose offset curves no grid holds is refused at run time),ST_NPointsto int4,GeometryType/ST_GeometryTypeto text,ST_AsTextandST_AsEWKT(geometry [, int4 maxdecimaldigits]) to PostGIS ISO and extended WKT text (STRICT; execution requires maxdecimaldigits constant over the rows),ST_XMin/ST_YMin/ST_XMax/ST_YMaxto float8ST_SRIDover any Geometry to int4, its stored SRID (0 without one);ST_AsBinaryto ISO WKB andST_AsEWKBto PostGIS EWKB bytea over any Geometry, little-endian or, for a text literal byte order beginning xdr or XDR, big-endian; NULL for a NULL operand or byte orderST_Boundary(Geometry) returns the planar boundary through the shared scalar executor and typed geometry Result; GPU execution admits XY Point, Polygon and MultiPolygon, preserves exact copied coordinates, SRID, ring/member order, NULL and typed EMPTY, and refuses other demanded input profiles as missing capabilityST_UnaryUnion(Geometry) dissolves XY Polygon/MultiPolygon components independently per row; strict NULL, stored typed EMPTY and CRS; operation-body errors follow CASE demand; other families and grid-size overloads remain capability gapsST_CollectionExtract(Geometry, literal int4 3) copies polygon components at every nesting depth without dissolving them; strict NULL, atomic Polygon or multipart/collection MultiPolygon, possibly EMPTY; retains CRS and stored axes; other selectors and the one-argument overload are UnsupportedST_MakeValid(geometry [, text literal]) over XY Geometry to nullable Geometry of any family, GeometryCollection included (GEOS MakeValid, default linework method); a parameter string PostGIS rejects binds and raises XX000 on each evaluated non-NULL row, a typed NULL parameter is strict, and every string PostGIS accepts (the default method spelled out included) and a non-XY operand are refused as unadmitted formsa strict spatial function of a NULL constant folds to a typed NULL, and COALESCE drops NULL constant arguments, as PostgreSQL’s constant folding does
declared geometry typmods and output modifier lineage; bare geometry casts strip typmods
explicit declared Geography sources and Geometry-to-Geography construction; WGS84 geography
ST_DistanceandST_DWithinover Point, LineString, Polygon, their Multi families and nested GeometryCollection; binary64 meters, optional strict Boolean use_spheroid defaulting to true, exact inclusive radius comparison; WKB preserves stored Z/M through explicit construction; non-WGS84 measurements require a different execution capabilityST_Transform(Geometry, int4 literal or NULL) preserves structure, EMPTY, Z/M and ordering, changes XY and exact target SRID; strict guarded operation-body errors and equal nonzero no-op precede full stored-SRID catalog lookup; compilation/reference emission do not provide runtime transformation
Other expressions, aggregates and literals#
SQL AND/OR/NOT
Boolean/int4/int8/float8/numeric/date/timestamp/interval/text equality and inequality over the common operand type (int4 < int8 < numeric < float8), and </>/<=/>= and [NOT] BETWEEN [SYMMETRIC] (rewritten as PostgreSQL does to >= AND <=) over int8/float8/numeric/date/timestamp/interval as canonical less_than/less_equal with reversed operands for >/>=; int4 orders as int8
value-list IN/NOT IN as PostgreSQL’s parser rewrites it: two or more items without column references as one canonical in_list over their common operand type with the left operand, ORed with x = item for each item with a column reference in written order (otherwise every item its own x = item), NOT IN its negation
PostgreSQL float8 addition/subtraction/multiplication with fixed AST association
PostgreSQL float8 NULLIF equality, including signed zero and NaN
Decimal(15,5) NULLIF consumed as float8, against NULL, integer, Decimal(15,5) or in-domain decimal literal comparands, lowered to float8 NULLIF
NULLIF(a, b) returns NULL when a = b, otherwise the first argument after PostgreSQL’s equality-operator conversions (numeric for an integer compared with numeric); int4 compared with int8 keeps the first argument’s integer type
float8 division: guarded by a nonzero literal or NULLIF(value, zero) (including structurally proven searched-CASE zero guards), otherwise checked, raising division by zero for a present zero divisor as PostgreSQL float8div
FLOOR over float8
text || text (PostgreSQL textcat) and replace(text, text, text) (every non-overlapping occurrence, left to right; an empty search string returns the input), NULL when any operand is NULL; an untyped literal, NULL or parameter operand is text; || with a non-text operand (anynonarray || text) is refused as a missing capability
IS [NOT] DISTINCT FROM over the equality contract of =, lowered to the catalog NULL-safe equality not_distinct (never NULL; plain equality when neither operand can be NULL); as a join conjunct between one column of each input it is a NULL-safe equality key
IS [NOT] TRUE/FALSE/UNKNOWN over Boolean, never NULL: not_distinct(x, TRUE/FALSE) or x IS NULL, negated for NOT
an untyped NULL constant takes the type of the other CASE results, COALESCE arguments or comparison operand
EXTRACT(field FROM timestamp or date) to numeric and date_part(text, timestamp or date) to float8 for a literal PostgreSQL field
IS NULL/IS NOT NULL
count(*)
count(expression)
sum over int4/int8/numeric/float8/interval with PostgreSQL result types (int8, exact numeric, float8, interval)
min/max over Boolean/int4/int8/float8/numeric/timestamp/interval, UTF-8 binary-collation text and bytea (unsigned bytes, a proper prefix first)
bool_and/every/bool_or as Boolean min/max (FALSE < TRUE), NULL-skipping and NULL over no present value
avg(float8) with PostgreSQL NULL/empty/nonfinite and finite-overflow semantics
avg(decimal) with PostgreSQL Numeric division/scale/rounding
avg(Duration) with PostgreSQL interval accumulation/division/rounding
aggregate FILTER (WHERE c) folded into the argument as CASE WHEN c THEN x END (COUNT(*) as COUNT(CASE WHEN c THEN TRUE END))
DISTINCT aggregates when every aggregate of the block is DISTINCT over one grouping-key argument, as an Aggregate over an inner Aggregate grouped by the keys and that argument; MIN/MAX(DISTINCT x) is MIN/MAX(x)
Timestamp subtraction (any units) to exact microsecond Duration; date ± int4 and int4 + date to date, date - date to int4 days, with PostgreSQL date range errors
PostgreSQL’s implicit date to timestamp cast wherever a date meets a timestamp (comparisons, IN lists, join keys, CASE/COALESCE values, subtraction) and in explicit casts; a date literal folds to its midnight
DATE_TRUNC with a non-null literal PostgreSQL unit (microseconds through millennium, any PostgreSQL spelling) and millisecond/microsecond Timestamp, producing exact microsecond Timestamp
expressions around groups/aggregates
HAVING, including unambiguous output-alias references
typed positional parameters
int4/int8/Boolean/text constants
exact numeric constants (non-integer, beyond int8, or in a numeric context; at most 38 digits)
TIMESTAMP literals in PostgreSQL’s DateStyle-independent input forms (Y..Y-MM-DD or Y..Y/MM/DD with three or more year digits, Y..YMMDD, J<Julian day>[.fraction], epoch; a time HH:MM[:SS[.fraction]] after a space or T, AM/PM, allballs; UTC/GMT/Z or numeric zones checked and ignored; BC/AD) and unknown strings in timestamp context
DATE literals in the same input forms, ‘…’::date and unknown strings in date context
INTERVAL constants and unknown strings in interval context (postgres-style quantities; months and longer only as RANGE frame offsets)
typed NULL, including NULL casts with type modifiers (numeric(p,s), varchar(n), timestamp(p), interval(p))
casts with a type modifier the value already satisfies exactly (a Decimal literal at a wider scale, a short varchar literal, a timestamp column or literal at the modifier’s precision)
identity casts (including numeric over Decimal and timestamp/interval over any unit), int4 to int8 widening, int4/int8/Decimal/Numeric to float8 conversion, int4/int8 to text or varchar as the decimal text of int4out/int8out (NULL for NULL)
contextual decimal/unknown-string float8 constants, IEEE signed zero/NaN/infinity
Grouping key types#
GROUP BY and SELECT DISTINCT keys can have these types.
Boolean
int4
int8
float8
numeric
date
timestamp
text (UTF-8, binary comparison)
Names and scopes#
qualified names
quoted identifiers
table/column/join/derived-table/CTE aliases
star expansion
self joins
ordered nonrecursive CTE namespaces with forward-reference rejection
uncorrelated derived tables and scalar expression subqueries
predicate subqueries correlated with the immediately enclosing query through WHERE conjuncts of a FROM/WHERE subquery
GROUP BY input-name precedence, output names and ordinals
Refused as unsupported#
The frontend refuses these forms with an Unsupported diagnostic.
recursive/materialized/data-modifying/unreferenced CTEs; LATERAL derived tables other than scalar no-FROM projections or the nearest-neighbor shape (LEFT JOIN LATERAL, scalar WHERE/ORDER BY/LIMIT, other nearest-neighbor ORDER BY keys or directions, OFFSET, WITH TIES, nonliteral LIMIT, correlation outside the nearest-neighbor ORDER BY key, a JOIN LATERAL nested in a join tree or under a join alias that reads earlier comma items, geography operands, grouping/aggregates/windows/DISTINCT/WITH inside), correlated scalar/derived subqueries, correlation beyond the immediately enclosing query or through a grouped/aggregated/set-operation/OFFSET subquery, correlated EXISTS outside a top-level WHERE conjunct
table functions
set operations
window RANGE offsets over an unconstrained numeric ordering key and NaN or infinite numeric offsets, EXCLUDE, frame offsets that are not constants or are type-modified casts (or float8 for ROWS/GROUPS), DISTINCT/FILTER/ORDER BY inside window calls, window min/max over bytea, window calls outside the SELECT list and nested window calls
ORDER BY OFFSET
aggregate ORDER BY (valid SQL that cuGeo does not support: its aggregates have no ordered form); aggregate FILTER the CASE vocabulary cannot express (over a geometry collection); DISTINCT aggregates beside other aggregates, over different arguments or over a non-grouping-key type
USING/NATURAL/full joins
IN/ANY/ALL subqueries outside top-level WHERE conjuncts; row-valued NOT IN/ALL over nullable values; row-valued subquery comparisons other than = and <>
Point/Envelope/GeomFromText constructors with nonzero SRIDs; nonliteral SRIDs or WKT; Z/M coordinate constructors
calendar-month interval values outside RANGE frame offsets, time-zoned timestamps and special timestamp values
text ordering operators
ST_KNNspheroid TRUE mode, nonliteral/invalid k, scalar use, and outer joinsarithmetic beyond float8 add/subtract/multiply, timestamp subtraction, date ± int4 / date - date and guarded float8 division/general casts; date/timestamp ± interval
DATE_TRUNC with a nonliteral unit or a time zone
CASE, COALESCE and NULLIF selecting between bytea, geography or opaque source values (refused as a missing capability), or between geometry values that declare different interpretation properties such as CRS (refused as unsupported), timestamps or intervals of different units, or float8 beside non-numeric values
SELECT DISTINCT and GROUP BY keys of interval, geometry or bytea type (refused as unsupported, not invalid)
geography operations beyond Distance, DWithin and Geometry-to-Geography construction
opaque equality/grouping
domains, casts that round, truncate or check a value against a type modifier, constrained geometry casts and unresolved inheritance/views/RLS
zero-column SQL outputs
ST_Transformtext projection overloads