{"record":{"id":"f54fa9fa1dab16f5","repo":"prestodb/presto","slug":"fieldtype-gettypesignature-type-is-not-order","errorCode":null,"errorMessage":"fieldType.getTypeSignature() + \" type is not orderable\"","messagePattern":"fieldType\\.getTypeSignature\\(\\) \\+ \" type is not orderable\"","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"presto-common/src/main/java/com/facebook/presto/common/type/RowType.java","lineNumber":319,"sourceCode":"                return false;\n            }\n        }\n\n        return true;\n    }\n\n    @Override\n    public int compareTo(Block leftBlock, int leftPosition, Block rightBlock, int rightPosition)\n    {\n        Block leftRow = leftBlock.getBlock(leftPosition);\n        Block rightRow = rightBlock.getBlock(rightPosition);\n\n        for (int i = 0; i < leftRow.getPositionCount(); i++) {\n            checkElementNotNull(leftRow.isNull(i));\n            checkElementNotNull(rightRow.isNull(i));\n            Type fieldType = fields.get(i).getType();\n            if (!fieldType.isOrderable()) {\n                throw new UnsupportedOperationException(fieldType.getTypeSignature() + \" type is not orderable\");\n            }\n            int compareResult = fieldType.compareTo(leftRow, i, rightRow, i);\n            if (compareResult != 0) {\n                return compareResult;\n            }\n        }\n\n        return 0;\n    }\n\n    @Override\n    public long hash(Block block, int position)\n    {\n        Block arrayBlock = block.getBlock(position);\n        long result = 1;\n        for (int i = 0; i < arrayBlock.getPositionCount(); i++) {\n            Type elementType = fields.get(i).getType();\n            result = 31 * result + TypeUtils.hashPosition(elementType, arrayBlock, i);","sourceCodeStart":301,"sourceCodeEnd":337,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-common/src/main/java/com/facebook/presto/common/type/RowType.java#L301-L337","documentation":"RowType's row comparison requires every field type to be orderable. During compareTo, if the field at the current position has isOrderable() == false, UnsupportedOperationException(\"<signature> type is not orderable\") is thrown. Rows containing unorderable element types (e.g. maps, rows containing maps) cannot be compared for <, >, sorting.","triggerScenarios":"Calling RowType.compareTo (or equality/ordering machinery) on a row whose field type is not orderable, e.g. ORDER BY on a column containing MAP elements or ROWs with map fields.","commonSituations":"ORDER BY or min/max on row-typed columns with map members; GROUP BY with row keys containing maps; comparator-based operators receiving nested unorderable types.","solutions":["Restrict comparisons to rows whose fields are all orderable (primitives, strings, arrays of orderable types).","Reorder comparison so unorderable fields are compared element-wise manually via type-specific functions (e.g. map_keys).","Use hash-based equality/distinct instead of ordering when fields are only hashable but not orderable."],"exampleFix":"// before\nORDER BY row_col\n// after\nORDER BY row_col[\"orderable_field\"], map_keys(row_col.m) -- avoid comparing map field directly","handlingStrategy":"type-guard","validationCode":"for (RowType.Field f : rowType.getFields()) { if (!f.getType().isOrderable()) throw new IllegalArgumentException(\"unorderable field\"); }","typeGuard":"boolean isOrderableRow(RowType t) { return t.getFields().stream().allMatch(f -> f.getType().isOrderable()); }","tryCatchPattern":"try { rowType.compareTo(left, right); } catch (UnsupportedOperationException e) { /* use element-wise or hash comparison instead */ }","preventionTips":["Avoid ORDER BY / min-max on ROW columns containing MAP or other unorderable types.","Check Type.isOrderable() before registering comparators in custom operators.","Prefer equality (DISTINCT) via hash semantics when ordering is not required."],"tags":["comparison","unsupported-operation","row-type"],"backgroundTag":"type-not-orderable","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"}