Code review comment: you need to modify exception message for you delete 'BinaryPredicate'

Code under review:
public void analyzeImpl(Analyzer analyzer) throws AnalysisException {
        
        Type whenType = null;
        
        Type returnType = null;
        
        Expr lastCompatibleThenExpr = null;
        Expr lastCompatibleWhenExpr = null;
        int loopEnd = children.size();
        if (hasElseExpr) {
            --loopEnd;
        }
        int loopStart;
        Expr caseExpr = null;
        
        if (hasCaseExpr) {
            loopStart = 1;
            caseExpr = children.get(0);
            caseExpr.analyze(analyzer);
            if (caseExpr instanceof Subquery && !caseExpr.getType().isScalarType()) {
                throw new AnalysisException("Subquery in case-when must return scala type");
            }
            whenType = caseExpr.getType();
            lastCompatibleWhenExpr = children.get(0);
        } else {
            whenType = Type.BOOLEAN;
            loopStart = 0;
        }

        
        for (int i = loopStart; i < loopEnd; i += 2) {
            Expr whenExpr = children.get(i);
            if (hasCaseExpr) {
                
                
                whenType = analyzer.getCompatibleType(whenType, lastCompatibleWhenExpr, whenExpr);
                lastCompatibleWhenExpr = whenExpr;
            } else {
                
                
                if (!Type.canCastTo(whenExpr.getType(), Type.BOOLEAN)) {
                    throw new AnalysisException("When expr '" + whenExpr.toSql() + "'"
                            + " is not of type boolean and not castable to type boolean.");
                }
                
                if (!whenExpr.getType().isBoolean()) {
                    castChild(Type.BOOLEAN, i);
                }
            }
            if (whenExpr instanceof Subquery && !whenExpr.getType().isScalarType()) {
                throw new AnalysisException("Subquery in case-when must return scala type");
            }
            if (whenExpr.contains(Predicates.instanceOf(Subquery.class))
                    && !((hasCaseExpr() && whenExpr instanceof Subquery || !checkSubquery(whenExpr)))) {
                throw new AnalysisException("Only support subquery in binary predicate in case statement.");
            }
            
            
            Expr thenExpr = children.get(i + 1);
            if (thenExpr instanceof Subquery && !thenExpr.getType().isScalarType()) {
                throw new AnalysisException("Subquery in case-when must return scala type");
            }
            returnType = analyzer.getCompatibleType(returnType, lastCompatibleThenExpr, thenExpr);
            lastCompatibleThenExpr = thenExpr;
        }
        if (hasElseExpr) {
            Expr elseExpr = children.get(children.size() - 1);
            if (elseExpr instanceof Subquery && !elseExpr.getType().isScalarType()) {
                throw new AnalysisException("Subquery in case-when must return scala type");
            }
            returnType = analyzer.getCompatibleType(returnType, lastCompatibleThenExpr, elseExpr);
        }

        
        if (hasCaseExpr) {
            
            if (children.get(0).type != whenType) {
                castChild(whenType, 0);
            }
            
            for (int i = loopStart; i < loopEnd; i += 2) {
                if (children.get(i).type != whenType) {
                    castChild(whenType, i);
                }
            }
        }
        
        for (int i = loopStart + 1; i < children.size(); i += 2) {
            if (children.get(i).type != returnType) {
                castChild(returnType, i);
            }
        }
        
        if (hasElseExpr) {
            if (children.get(children.size() - 1).type != returnType) {
                castChild(returnType, children.size() - 1);
            }
        }

        type = returnType;
    }

Line commented on: throw new AnalysisException("Only support subquery in binary predicate in case statement.");

Revised code:
public void analyzeImpl(Analyzer analyzer) throws AnalysisException {
        
        Type whenType = null;
        
        Type returnType = null;
        
        Expr lastCompatibleThenExpr = null;
        Expr lastCompatibleWhenExpr = null;
        int loopEnd = children.size();
        if (hasElseExpr) {
            --loopEnd;
        }
        int loopStart;
        Expr caseExpr = null;
        
        if (hasCaseExpr) {
            loopStart = 1;
            caseExpr = children.get(0);
            caseExpr.analyze(analyzer);
            if (caseExpr instanceof Subquery && !caseExpr.getType().isScalarType()) {
                throw new AnalysisException("Subquery in case-when must return scala type");
            }
            whenType = caseExpr.getType();
            lastCompatibleWhenExpr = children.get(0);
        } else {
            whenType = Type.BOOLEAN;
            loopStart = 0;
        }

        
        for (int i = loopStart; i < loopEnd; i += 2) {
            Expr whenExpr = children.get(i);
            if (hasCaseExpr) {
                
                
                whenType = analyzer.getCompatibleType(whenType, lastCompatibleWhenExpr, whenExpr);
                lastCompatibleWhenExpr = whenExpr;
            } else {
                
                
                if (!Type.canCastTo(whenExpr.getType(), Type.BOOLEAN)) {
                    throw new AnalysisException("When expr '" + whenExpr.toSql() + "'"
                            + " is not of type boolean and not castable to type boolean.");
                }
                
                if (!whenExpr.getType().isBoolean()) {
                    castChild(Type.BOOLEAN, i);
                }
            }
            if (whenExpr instanceof Subquery && !whenExpr.getType().isScalarType()) {
                throw new AnalysisException("Subquery in case-when must return scala type");
            }
            if (whenExpr.contains(Predicates.instanceOf(Subquery.class))
                    && !((hasCaseExpr() && whenExpr instanceof Subquery || !checkSubquery(whenExpr)))) {
                throw new AnalysisException("Only support subquery in binary predicate in case statement.");
            }
            
            
            Expr thenExpr = children.get(i + 1);
            if (thenExpr instanceof Subquery && !thenExpr.getType().isScalarType()) {
                throw new AnalysisException("Subquery in case-when must return scala type");
            }
            returnType = analyzer.getCompatibleType(returnType, lastCompatibleThenExpr, thenExpr);
            lastCompatibleThenExpr = thenExpr;
        }
        if (hasElseExpr) {
            Expr elseExpr = children.get(children.size() - 1);
            if (elseExpr instanceof Subquery && !elseExpr.getType().isScalarType()) {
                throw new AnalysisException("Subquery in case-when must return scala type");
            }
            returnType = analyzer.getCompatibleType(returnType, lastCompatibleThenExpr, elseExpr);
        }

        
        if (hasCaseExpr) {
            
            if (children.get(0).type != whenType) {
                castChild(whenType, 0);
            }
            
            for (int i = loopStart; i < loopEnd; i += 2) {
                if (children.get(i).type != whenType) {
                    castChild(whenType, i);
                }
            }
        }
        
        for (int i = loopStart + 1; i < children.size(); i += 2) {
            if (children.get(i).type != returnType) {
                castChild(returnType, i);
            }
        }
        
        if (hasElseExpr) {
            if (children.get(children.size() - 1).type != returnType) {
                castChild(returnType, children.size() - 1);
            }
        }

        type = returnType;
    }