{"record":{"id":"b8ea991f2b187fac","repo":"prestodb/presto","slug":"invalid-spatial-partitioning","errorCode":"INVALID_SPATIAL_PARTITIONING","errorMessage":"Expected exactly one row for table %s, but got none","messagePattern":"Expected exactly one row for table (.+?), but got none","errorType":"error_code","errorClass":"PrestoException","httpStatus":null,"severity":"error","filePath":"presto-main-base/src/main/java/com/facebook/presto/sql/planner/iterative/rule/ExtractSpatialJoins.java","lineNumber":644,"sourceCode":"                    catch (IOException e) {\n                        throw new UncheckedIOException(e);\n                    }\n                }\n\n                if (splitBatch.isLastBatch()) {\n                    break;\n                }\n            }\n        }\n\n        checkSpatialPartitioningTable(kdbTree.isPresent(), \"Expected exactly one row for table %s, but got none\", name);\n        return kdbTree.get();\n    }\n\n    private static void checkSpatialPartitioningTable(boolean condition, String message, Object... arguments)\n    {\n        if (!condition) {\n            throw new PrestoException(INVALID_SPATIAL_PARTITIONING, format(message, arguments));\n        }\n    }\n\n    private static QualifiedObjectName toQualifiedObjectName(String name, String catalog, String schema)\n    {\n        ImmutableList<String> ids = ImmutableList.copyOf(Splitter.on('.').split(name));\n        if (ids.size() == 3) {\n            return new QualifiedObjectName(ids.get(0), ids.get(1), ids.get(2));\n        }\n\n        if (ids.size() == 2) {\n            return new QualifiedObjectName(catalog, ids.get(0), ids.get(1));\n        }\n\n        if (ids.size() == 1) {\n            return new QualifiedObjectName(catalog, schema, ids.get(0));\n        }\n","sourceCodeStart":626,"sourceCodeEnd":662,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-main-base/src/main/java/com/facebook/presto/sql/planner/iterative/rule/ExtractSpatialJoins.java#L626-L662","documentation":"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.","triggerScenarios":"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.","commonSituations":"User pointed the spatial partitioning property at an empty or wrong table; table was truncated/never populated; misconfigured catalog/schema in the hint value.","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"],"exampleFix":"// before\nSELECT a, b FROM t1 JOIN t2 ON ST_Contains(t1.geom, t2.geom); -- partitioning table empty\n// after\nCALL system.create_empty_partitioning('spatial_partitioning_table');\n-- then re-run join with correct spatial_partitioning_table_name hint","handlingStrategy":"validation","validationCode":"SELECT count(*) FROM <spatial_partitioning_table>; -- must be exactly 1","typeGuard":"null","tryCatchPattern":"try {\n    return spatialJoinQuery();\n} catch (PrestoException e) {\n    if (e.getErrorCode() == INVALID_SPATIAL_PARTITIONING.toErrorCode()) {\n        // fall back to plain join without spatial partitioning hint\n    } else throw e;\n}","preventionTips":["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"],"tags":["spatial","join","configuration"],"backgroundTag":"invalid-spatial-partitioning","analyzedSha":"55bb57d202de3b926896fa966c2c4a44c779634e","analyzedAt":"2026-09-04T12:50:26.162Z","contentChangedAt":"2026-09-04T12:50:26.162Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}