prestodb/presto · error · NotSupportedException
ROW comparison not supported for fields with null elements
Error message
ROW comparison not supported for fields with null elements
What it means
RowType comparison/equality refuses to compare ROW values whose fields contain null elements: checkElementNotNull throws NotSupportedException("ROW comparison not supported for fields with null elements"). SQL semantics for comparing rows with nulls are undefined here, so the library fails explicitly rather than returning a possibly wrong result.
Source
Thrown at presto-common/src/main/java/com/facebook/presto/common/type/RowType.java:345
return 0;
}
@Override
public long hash(Block block, int position)
{
Block arrayBlock = block.getBlock(position);
long result = 1;
for (int i = 0; i < arrayBlock.getPositionCount(); i++) {
Type elementType = fields.get(i).getType();
result = 31 * result + TypeUtils.hashPosition(elementType, arrayBlock, i);
}
return result;
}
private static void checkElementNotNull(boolean isNull)
{
if (isNull) {
throw new NotSupportedException("ROW comparison not supported for fields with null elements");
}
}
}
View on GitHub (pinned to 55bb57d202)
Solutions
- Use COALESCE/null-safe semantics: IS NOT DISTINCT FROM or fill nulls with sentinel values before comparison.
- Flatten the row and use IS DISTINCT FROM per field instead of comparing whole rows.
- Rewrite the query so comparison keys exclude nullable components.
Example fix
// before WHERE row_col = ROW(1, NULL) // after WHERE row_col IS NOT DISTINCT FROM CAST(ROW(1, NULL) AS ROW(int, int))
Defensive patterns
Strategy: validation
Validate before calling
if (row.isNull(i)) { /* resolve nulls before comparison */ } Type guard
boolean isComparableRow(Block a, Block b) { for (int i = 0; i < a.getPositionCount(); i++) { if (a.isNull(i) || b.isNull(i)) return false; } return true; } Try / catch
try { rowType.equalTo(left, right); } catch (NotSupportedException e) { /* treat as not-equal or use IS NOT DISTINCT FROM semantics */ } Prevention
- Use IS NOT DISTINCT FROM / null-safe comparisons on ROW columns.
- COALESCE null fields to sentinels before struct comparisons.
- Avoid nullable fields in join/group-by keys of type ROW.
When it happens
Trigger: Calling RowType.equalTo or RowType.compareTo on two rows where any corresponding element is NULL (isNull(i) true).
Common situations: GROUP BY / DISTINCT / equality checks on ROW columns with nullable members; ORDER BY on struct columns containing NULLs; joins on row-typed keys where fields can be null.
Related errors
- fieldType.getTypeSignature() + " type is not orderable"
- Expected all parameters to be named type, but got %s
- INVALID_FUNCTION_ARGUMENT
- NOT_SUPPORTED
- NOT_SUPPORTED
AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04).
Data as JSON: /api/errors/f6423f9355160d1d.
Report an issue: GitHub.