diff --git a/core/trino-parser/src/main/java/io/trino/type/TypeCalculation.java b/core/trino-parser/src/main/java/io/trino/type/TypeCalculation.java index 674d2a867169..d8ecc734cf57 100644 --- a/core/trino-parser/src/main/java/io/trino/type/TypeCalculation.java +++ b/core/trino-parser/src/main/java/io/trino/type/TypeCalculation.java @@ -125,8 +125,6 @@ public BigInteger visitIfExpression(TypeCalculationParser.IfExpressionContext ct { BigInteger left = visit(ctx.left); BigInteger right = visit(ctx.right); - BigInteger ifTrue = visit(ctx.ifTrue); - BigInteger ifFalse = visit(ctx.ifFalse); boolean condition = switch (ctx.operator.getText()) { case ">" -> left.compareTo(right) > 0; @@ -138,7 +136,11 @@ public BigInteger visitIfExpression(TypeCalculationParser.IfExpressionContext ct default -> throw new IllegalStateException("Unsupported if operator " + ctx.operator.getText()); }; - return condition ? ifTrue : ifFalse; + if (condition) { + return visit(ctx.ifTrue); + } + + return visit(ctx.ifFalse); } @Override