From fa2961093855b2537bba5b2d5681e486b132d1f7 Mon Sep 17 00:00:00 2001 From: Kishore Kumar M V Date: Thu, 21 Nov 2024 12:10:23 +0530 Subject: [PATCH] [BugFix] Fix for npe NormalizePredicateRule (#52326) Signed-off-by: Kishore Kumar M V --- .../rewrite/scalar/NormalizePredicateRule.java | 3 ++- .../scalar/NormalizePredicateRuleTest.java | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) 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