From 18892f6ad1758dd5aac34781e2118253694a5e54 Mon Sep 17 00:00:00 2001 From: zhangstar333 <2561612514@qq.com> Date: Tue, 2 Apr 2024 18:52:15 +0800 Subject: [PATCH] format --- .../rules/FoldConstantRuleOnBE.java | 3 ++ .../trees/expressions/LiteralTest.java | 30 ++++++++++++------- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/rules/FoldConstantRuleOnBE.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/rules/FoldConstantRuleOnBE.java index 8580d00b5e97d01..e907cbe845eb14a 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/rules/FoldConstantRuleOnBE.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/rules/FoldConstantRuleOnBE.java @@ -290,6 +290,9 @@ private static Map evalOnBE(Map> return resultMap; } + /** + * convert PValues which from BE to Expression of nereids + */ public static List getResultExpression(DataType type, PValues resultContent) { List res = new ArrayList<>(); if (type.isBooleanType()) { diff --git a/fe/fe-core/src/test/java/org/apache/doris/nereids/trees/expressions/LiteralTest.java b/fe/fe-core/src/test/java/org/apache/doris/nereids/trees/expressions/LiteralTest.java index 42948d2dd32bbd5..86856c0f8a09df2 100644 --- a/fe/fe-core/src/test/java/org/apache/doris/nereids/trees/expressions/LiteralTest.java +++ b/fe/fe-core/src/test/java/org/apache/doris/nereids/trees/expressions/LiteralTest.java @@ -33,7 +33,6 @@ import org.apache.doris.proto.Types.PGenericType.TypeId; import org.apache.doris.proto.Types.PValues; -import static org.apache.doris.nereids.rules.expression.rules.FoldConstantRuleOnBE.getResultExpression; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; @@ -81,7 +80,9 @@ public void testGetResultExpressionArrayInt() { resultContentBuilder.setType(typeBuilder.build()); resultContentBuilder.addChildElement(childValues); PValues resultContent = resultContentBuilder.build(); - List resultExpression = getResultExpression(arrayType, resultContent); + List resultExpression + = org.apache.doris.nereids.rules.expression.rules.FoldConstantRuleOnBE.getResultExpression(arrayType, + resultContent); Assertions.assertTrue(resultExpression.get(0).isLiteral()); } @@ -115,7 +116,9 @@ public void testGetResultExpressionArrayArrayInt() { outContentBuilder.setType(outTypeBuilder.build()); outContentBuilder.addChildElement(nestedResultContent); PValues resultContent = outContentBuilder.build(); - List resultExpression = getResultExpression(outArrayType, resultContent); + List resultExpression + = org.apache.doris.nereids.rules.expression.rules.FoldConstantRuleOnBE.getResultExpression(outArrayType, + resultContent); // [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]] Assertions.assertTrue(resultExpression.get(0) instanceof ArrayLiteral); System.out.println(resultExpression.get(0).toString()); @@ -156,7 +159,9 @@ public void testGetResultExpressionArrayArrayInt2() { outContentBuilder.setType(outTypeBuilder.build()); outContentBuilder.addChildElement(nestedResultContent); PValues resultContent = outContentBuilder.build(); - List resultExpression = getResultExpression(outArrayType, resultContent); + List resultExpression + = org.apache.doris.nereids.rules.expression.rules.FoldConstantRuleOnBE.getResultExpression(outArrayType, + resultContent); // [[0, 2, 4, 6, 8], [1, 3, 5, 7, 9]] Assertions.assertTrue(resultExpression.get(0) instanceof ArrayLiteral); System.out.println(resultExpression.get(0).toString()); @@ -189,7 +194,9 @@ public void testGetResultExpressionArrayNull() { resultContentBuilder.setType(typeBuilder.build()); resultContentBuilder.addChildElement(childValues); PValues resultContent = resultContentBuilder.build(); - List resultExpression = getResultExpression(arrayType, resultContent); + List resultExpression + = org.apache.doris.nereids.rules.expression.rules.FoldConstantRuleOnBE.getResultExpression(arrayType, + resultContent); // [0, NULL, 2, NULL, 4, NULL, 6, NULL, 8, NULL] Assertions.assertTrue(resultExpression.get(0).isLiteral()); System.out.println(resultExpression.get(0).toString()); @@ -230,9 +237,11 @@ public void testGetResultExpressionStruct() { resultContentBuilder.addChildElement(childValues1); resultContentBuilder.addChildElement(childValues2); PValues resultContent = resultContentBuilder.build(); - List resultExpression = getResultExpression(structType, resultContent); + List resultExpression + = org.apache.doris.nereids.rules.expression.rules.FoldConstantRuleOnBE.getResultExpression(structType, + resultContent); Assertions.assertTrue(resultExpression.get(0).isLiteral()); - //STRUCT('col1':0,'col2':'str1') + // STRUCT('col1':0,'col2':'str1') System.out.println(resultExpression.get(0).toString()); } @@ -271,7 +280,6 @@ public void testGetResultExpressionStructArray() { arrayChildBuilder1.setType(childTypeBuilder3.build()); arrayChildBuilder2.setType(childTypeBuilder3.build()); - PValues childValues1 = childBuilder1.build(); PValues childValues2 = childBuilder2.build(); arrayChildBuilder1.addChildElement(childValues1); @@ -283,9 +291,11 @@ public void testGetResultExpressionStructArray() { resultContentBuilder.addChildElement(arrayChildValues1); resultContentBuilder.addChildElement(arrayChildValues2); PValues resultContent = resultContentBuilder.build(); - List resultExpression = getResultExpression(structType, resultContent); + List resultExpression + = org.apache.doris.nereids.rules.expression.rules.FoldConstantRuleOnBE.getResultExpression(structType, + resultContent); Assertions.assertTrue(resultExpression.get(0).isLiteral()); - //STRUCT('col1':[0, 2, 4, 6, 8],'col2':['str1', 'str3', 'str5', 'str7', 'str9']) + // STRUCT('col1':[0, 2, 4, 6, 8],'col2':['str1', 'str3', 'str5', 'str7', 'str9']) System.out.println(resultExpression.get(0).toString()); } }