prestodb/presto · error · PrestoException
GENERIC_INTERNAL_ERROR
GENERIC_INTERNAL_ERROR
Error message
all inequality expressions for inference must be < or <=
What it means
InequalityInference's constructor throws GENERIC_INTERNAL_ERROR if any supplied inequality expression is not < or <=. The class only implements inference over less-than style predicates, so other operators indicate an internal bug or misuse.
Source
Thrown at presto-main-base/src/main/java/com/facebook/presto/sql/planner/InequalityInference.java:71
import static java.util.Objects.requireNonNull;
import static java.util.stream.Collectors.toList;
public class InequalityInference
{
// inequalityExpressions include the inequalities from the current join predicate
// and those inherited from the join's parent
private final Set<RowExpression> inequalityExpressions;
private final FunctionAndTypeManager functionAndTypeManager;
private final ExpressionEquivalence expressionEquivalence;
// 'outerVariables' is the variable set projected from the outer input for left or right join,
// or EMPTY if the join is an inner join
private final Optional<Collection<VariableReferenceExpression>> outerVariables;
public InequalityInference(Set<RowExpression> inequalityExpressions, FunctionAndTypeManager functionAndTypeManager, ExpressionEquivalence expressionEquivalence, Optional<Collection<VariableReferenceExpression>> outerVariables)
{
if (inequalityExpressions.stream()
.anyMatch(e -> !isOperation(e, LESS_THAN, functionAndTypeManager) && !isOperation(e, LESS_THAN_OR_EQUAL, functionAndTypeManager))) {
throw new PrestoException(GENERIC_INTERNAL_ERROR, "all inequality expressions for inference must be < or <=");
}
this.inequalityExpressions = requireNonNull(inequalityExpressions, "inequalityExpressions is null");
this.functionAndTypeManager = requireNonNull(functionAndTypeManager, "functionAndTypeManager is null");
this.expressionEquivalence = requireNonNull(expressionEquivalence, "expressionEquivalence is null");
this.outerVariables = requireNonNull(outerVariables, "outerVariables is null");
}
// Basic idea is to pairwise compare each predicate with all other predicates.
// Since any inferred predicates may trigger other inferences, keep comparing until no new predicates are generated
public Set<RowExpression> inferInequalities()
{
if (inequalityExpressions.size() < 2) {
return ImmutableSet.of();
}
Set<RowExpression> allInferredInequalities = new HashSet<>();
Set<RowExpression> inequalitiesInferredInCurrentTraversal = new HashSet<>(inequalityExpressions);
Set<Set<RowExpression>> exploredCombinations = new HashSet();View on GitHub (pinned to 55bb57d202)
Solutions
- Upgrade Presto; check for a fixed bug in the relevant optimizer rule.
- Work around by rewriting query predicates so inequality join conditions are written with < or <=.
- File an issue with the query and plan.
Example fix
// before JOIN b ON a.x > b.x // after JOIN b ON b.x < a.x
Defensive patterns
Strategy: validation
Validate before calling
boolean allLessThan = inequalities.stream().allMatch(e -> isOperation(e, LESS_THAN, ftm) || isOperation(e, LESS_THAN_OR_EQUAL, ftm)); if (!allLessThan) { throw new IllegalArgumentException("only < or <= supported"); } Type guard
boolean isSupportedInequality(RowExpression e, FunctionAndTypeManager m) { return isOperation(e, LESS_THAN, m) || isOperation(e, LESS_THAN_OR_EQUAL, m); } Try / catch
try { new InequalityInference(exprs, ftm, equiv, outer); } catch (PrestoException e) { if (e.getErrorCode() == StandardErrorCode.GENERIC_INTERNAL_ERROR.toErrorCode()) { /* normalize > to < and retry */ } else { throw e; } } Prevention
- Normalize all > and >= to flipped < and <= before building the inference
- Only feed inequalities from the intended optimizer call sites
- Add unit tests asserting operator precondition
When it happens
Trigger: Constructing InequalityInference (e.g. from join or predicate-pushdown optimizers) with expressions containing >, >=, or non-inequality predicates.
Common situations: Engine-internal: an optimizer passed unnormalized inequalities (e.g. > instead of flipped <) into the inference. Users cannot trigger it directly; it usually signals a bug.
Understand the failure class
Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.
Related errors
- CLICKHOUSE_QUERY_GENERATOR_FAILURE
- GENERIC_INTERNAL_ERROR
- GENERIC_INTERNAL_ERROR
- GENERIC_INTERNAL_ERROR
- GENERIC_INTERNAL_ERROR
AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04).
Data as JSON: /api/errors/53cc850e83185a0c.
Report an issue: GitHub.