prestodb/presto · error · PrestoException
INVALID_SPATIAL_PARTITIONING
INVALID_SPATIAL_PARTITIONING
Error message
Expected exactly one row for table %s, but got none
What it means
ExtractSpatialJoins builds a KDB-tree from a spatial partitioning table to split spatial joins. The helper checkSpatialPartitioningTable validates that the table contains exactly the expected rows; finding zero rows for the required table violates the spatial partitioning contract and throws INVALID_SPATIAL_PARTITIONING.
Source
Thrown at presto-main-base/src/main/java/com/facebook/presto/sql/planner/iterative/rule/ExtractSpatialJoins.java:644
catch (IOException e) {
throw new UncheckedIOException(e);
}
}
if (splitBatch.isLastBatch()) {
break;
}
}
}
checkSpatialPartitioningTable(kdbTree.isPresent(), "Expected exactly one row for table %s, but got none", name);
return kdbTree.get();
}
private static void checkSpatialPartitioningTable(boolean condition, String message, Object... arguments)
{
if (!condition) {
throw new PrestoException(INVALID_SPATIAL_PARTITIONING, format(message, arguments));
}
}
private static QualifiedObjectName toQualifiedObjectName(String name, String catalog, String schema)
{
ImmutableList<String> ids = ImmutableList.copyOf(Splitter.on('.').split(name));
if (ids.size() == 3) {
return new QualifiedObjectName(ids.get(0), ids.get(1), ids.get(2));
}
if (ids.size() == 2) {
return new QualifiedObjectName(catalog, ids.get(0), ids.get(1));
}
if (ids.size() == 1) {
return new QualifiedObjectName(catalog, schema, ids.get(0));
}
View on GitHub (pinned to 55bb57d202)
Solutions
- Verify the spatial partitioning table contains exactly one row with a valid KDB-tree blob
- Re-populate the table by regenerating the KDB tree (e.g. via spatial_partitioning procedure)
- Check the join hint / session property points at the correct catalog.schema.table
Example fix
// before
SELECT a, b FROM t1 JOIN t2 ON ST_Contains(t1.geom, t2.geom); -- partitioning table empty
// after
CALL system.create_empty_partitioning('spatial_partitioning_table');
-- then re-run join with correct spatial_partitioning_table_name hint Defensive patterns
Strategy: validation
Validate before calling
SELECT count(*) FROM <spatial_partitioning_table>; -- must be exactly 1
Type guard
null
Try / catch
try {
return spatialJoinQuery();
} catch (PrestoException e) {
if (e.getErrorCode() == INVALID_SPATIAL_PARTITIONING.toErrorCode()) {
// fall back to plain join without spatial partitioning hint
} else throw e;
} Prevention
- Always populate the KDB-tree partitioning table before using the hint
- Validate the table has exactly one row before enabling the spatial join optimization
- Keep the partitioning table in sync with data distribution
When it happens
Trigger: A spatial join optimization is attempted and the configured spatial partitioning table (e.g. from 'spatial_partitioning_table_name' join hint or catalog config) exists but returns no rows when read.
Common situations: User pointed the spatial partitioning property at an empty or wrong table; table was truncated/never populated; misconfigured catalog/schema in the hint value.
Related errors
AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04).
Data as JSON: /api/errors/b8ea991f2b187fac.
Report an issue: GitHub.