diff --git a/fe/fe-core/src/main/java/com/starrocks/sql/optimizer/rewrite/scalar/NormalizePredicateRule.java b/fe/fe-core/src/main/java/com/starrocks/sql/optimizer/rewrite/scalar/NormalizePredicateRule.java index 047e2cb028cc9..9c13c07eca766 100644 --- a/fe/fe-core/src/main/java/com/starrocks/sql/optimizer/rewrite/scalar/NormalizePredicateRule.java +++ b/fe/fe-core/src/main/java/com/starrocks/sql/optimizer/rewrite/scalar/NormalizePredicateRule.java @@ -186,7 +186,8 @@ private Optional getOptimizedCompoundTree(CompoundPredicateOpera parent.setCompoundTreeUniqueLeaves(compoundTreeUniqueLeaves); // this tree can be optimized - if (compoundTreeUniqueLeaves.size() != parent.getCompoundTreeLeafNodeNumber()) { + if (compoundTreeUniqueLeaves != null && + compoundTreeUniqueLeaves.size() != parent.getCompoundTreeLeafNodeNumber()) { ScalarOperator newTree = Utils.createCompound(parent.getCompoundType(), compoundTreeUniqueLeaves.stream().map( node -> { diff --git a/fe/fe-core/src/test/java/com/starrocks/sql/optimizer/rewrite/scalar/NormalizePredicateRuleTest.java b/fe/fe-core/src/test/java/com/starrocks/sql/optimizer/rewrite/scalar/NormalizePredicateRuleTest.java index d92662dba2088..545747fa1171b 100644 --- a/fe/fe-core/src/test/java/com/starrocks/sql/optimizer/rewrite/scalar/NormalizePredicateRuleTest.java +++ b/fe/fe-core/src/test/java/com/starrocks/sql/optimizer/rewrite/scalar/NormalizePredicateRuleTest.java @@ -142,4 +142,20 @@ public void testCompound1() { ScalarOperator res = operatorRewriter.rewrite(compoundPredicateOperator, Lists.newArrayList(new NormalizePredicateRule())); } + + @Test + public void testCompound2() { + InPredicateOperator inOp = new InPredicateOperator( + false, + ConstantOperator.createInt(1063), + new ColumnRefOperator(0, Type.INT, "col1", false), + new ColumnRefOperator(1, Type.INT, "col2", false), + new ColumnRefOperator(2, Type.INT, "col3", false), + new ColumnRefOperator(3, Type.INT, "col4", false) + ); + + ScalarOperatorRewriter operatorRewriter = new ScalarOperatorRewriter(); + ScalarOperator res = + operatorRewriter.rewrite(inOp, Lists.newArrayList(new NormalizePredicateRule())); + } } \ No newline at end of file