{"record":{"id":"727f9a6d7e1e5946","repo":"prestodb/presto","slug":"function-implementation-error-727f9a","errorCode":"FUNCTION_IMPLEMENTATION_ERROR","errorMessage":"Row ID ordinal not found","messagePattern":"Row ID ordinal not found","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"presto-accumulo/src/main/java/com/facebook/presto/accumulo/io/AccumuloPageSink.java","lineNumber":101,"sourceCode":"    private long numRows;\n\n    public AccumuloPageSink(\n            Connector connector,\n            AccumuloTable table,\n            String username)\n    {\n        requireNonNull(table, \"table is null\");\n\n        this.columns = table.getColumns();\n\n        // Fetch the row ID ordinal, throwing an exception if not found for safety\n        Optional<Integer> ordinal = columns.stream()\n                .filter(columnHandle -> columnHandle.getName().equals(table.getRowId()))\n                .map(AccumuloColumnHandle::getOrdinal)\n                .findAny();\n\n        if (!ordinal.isPresent()) {\n            throw new PrestoException(FUNCTION_IMPLEMENTATION_ERROR, \"Row ID ordinal not found\");\n        }\n\n        this.rowIdOrdinal = ordinal.get();\n        this.serializer = table.getSerializerInstance();\n\n        try {\n            // Create a BatchWriter to the Accumulo table\n            BatchWriterConfig conf = new BatchWriterConfig();\n            writer = connector.createBatchWriter(table.getFullTableName(), conf);\n\n            // If the table is indexed, create an instance of an Indexer, else empty\n            if (table.isIndexed()) {\n                indexer = Optional.of(\n                        new Indexer(\n                                connector,\n                                connector.securityOperations().getUserAuthorizations(username),\n                                table,\n                                conf));","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-accumulo/src/main/java/com/facebook/presto/accumulo/io/AccumuloPageSink.java#L83-L119","documentation":"Thrown in the AccumuloPageSink constructor when no column in the table's column list has a name matching the table's configured rowId. The sink maps rows to Accumulo mutations by ordinal, so it must know which column ordinal holds the Accumulo row ID; if the row ID column is missing from the sink's column handles, this internal consistency error (FUNCTION_IMPLEMENTATION_ERROR) is raised.","triggerScenarios":"Creating an AccumuloPageSink for a table whose columnHandles list does not contain any AccumuloColumnHandle whose getName() equals table.getRowId(); typically caused by stale or truncated column metadata (e.g. connector metadata not matching the table's registered row ID column after schema changes).","commonSituations":"Table row_id renamed or columns dropped in Accumulo metadata without updating Presto's column handles; a query selecting a subset of columns passed as sink columns instead of the full table column list; deserialization/upgrade issues where old table metadata lacks the row ID column.","solutions":["Verify the table's row_id in Presto metadata matches an existing column name via SHOW CREATE TABLE or the metadata JSON","Re-register or repair the table metadata so the column list includes the row ID column with the correct ordinal","Drop and recreate the Accumulo table registration in Presto if metadata is corrupted","If writing a custom connector path, always pass the full table column list to the sink, not a filtered subset"],"exampleFix":"// before\n// sink columns built from projection only, missing rowid column\nList<AccumuloColumnHandle> cols = handles.stream().filter(h -> projectionUses(h)).collect(toList());\n// after\n// always include the row ID column\nList<AccumuloColumnHandle> cols = new ArrayList<>(handles);\nhandles.stream().filter(h -> h.getName().equals(table.getRowId()))\n       .filter(h -> cols.stream().noneMatch(c -> c.getName().equals(h.getName())))\n       .forEach(cols::add);","handlingStrategy":"validation","validationCode":"boolean rowIdPresent = columns.stream()\n    .anyMatch(c -> c.getName().equals(table.getRowId()));\nif (!rowIdPresent) {\n    throw new IllegalStateException(\"Sink column handles missing row ID column: \" + table.getRowId());\n}","typeGuard":null,"tryCatchPattern":"try {\n    AccumuloPageSink sink = new AccumuloPageSink(...);\n} catch (PrestoException e) {\n    if (e.getMessage().contains(\"Row ID ordinal not found\")) {\n        // metadata drift: re-fetch table metadata or re-register the table\n        throw new IllegalStateException(\"Table metadata is out of sync; run SHOW CREATE TABLE and repair row_id column\", e);\n    }\n    throw e;\n}","preventionTips":["Always pass the full table column list to the page sink, never a projection-filtered subset","Verify SHOW CREATE TABLE includes the row_id column matching an actual column name","Re-create table metadata after upgrades or manual Accumulo-side changes","Keep the user_tables_mapping and column metadata consistent when renaming columns"],"tags":["accumulo","metadata","row-id","connector-bug"],"backgroundTag":"row-id-column-missing","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"}