This is an automated email from the ASF dual-hosted git repository.

yiguolei pushed a commit to branch branch-2.1
in repository https://gitbox.apache.org/repos/asf/doris.git

commit 378ced72dbb9de51dd955ea25aea2f1d1db27f7d
Author: morrySnow <[email protected]>
AuthorDate: Tue Feb 27 14:32:12 2024 +0800

    [chore](Nereids) more reasonable parse select list only query (#31346)
---
 .../doris/nereids/parser/LogicalPlanBuilder.java   |  3 ++-
 .../rules/analysis/FunctionRegistryTest.java       | 27 +++++++++++-----------
 .../doris/nereids/trees/expressions/UdfTest.java   | 24 +++++++++----------
 3 files changed, 27 insertions(+), 27 deletions(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/parser/LogicalPlanBuilder.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/parser/LogicalPlanBuilder.java
index bbec47aaeef..551e8f60b4d 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/parser/LogicalPlanBuilder.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/parser/LogicalPlanBuilder.java
@@ -1220,7 +1220,8 @@ public class LogicalPlanBuilder extends 
DorisParserBaseVisitor<Object> {
                 if (columnCtx.EXCEPT() != null) {
                     throw new ParseException("select-except cannot be used in 
one row relation", selectCtx);
                 }
-                relation = withOneRowRelation(columnCtx);
+                relation = new 
UnboundOneRowRelation(StatementScopeIdGenerator.newRelationId(),
+                        ImmutableList.of(new UnboundAlias(Literal.of(0))));
             } else {
                 relation = visitFromClause(ctx.fromClause());
             }
diff --git 
a/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/analysis/FunctionRegistryTest.java
 
b/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/analysis/FunctionRegistryTest.java
index 5f2c839d722..851189cf0aa 100644
--- 
a/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/analysis/FunctionRegistryTest.java
+++ 
b/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/analysis/FunctionRegistryTest.java
@@ -46,7 +46,7 @@ import java.util.Map;
 
 // this ut will add more test case later
 public class FunctionRegistryTest implements MemoPatternMatchSupported {
-    private ConnectContext connectContext = 
MemoTestUtils.createConnectContext();
+    private final ConnectContext connectContext = 
MemoTestUtils.createConnectContext();
 
     @Test
     public void testDefaultFunctionNameIsClassName() {
@@ -55,8 +55,8 @@ public class FunctionRegistryTest implements 
MemoPatternMatchSupported {
         PlanChecker.from(connectContext)
                 .analyze("select year('2021-01-01')")
                 .matches(
-                        logicalOneRowRelation().when(r -> {
-                            Year year = (Year) r.getProjects().get(0).child(0);
+                        logicalProject().when(project -> {
+                            Year year = (Year) 
project.getProjects().get(0).child(0);
                             Assertions.assertEquals("2021-01-01",
                                     ((Literal) 
year.getArguments().get(0).child(0)).getValue());
                             return true;
@@ -72,14 +72,14 @@ public class FunctionRegistryTest implements 
MemoPatternMatchSupported {
         PlanChecker.from(connectContext)
                 .analyze("select substring('abc', 1, 2), 
substr(substring('abcdefg', 4, 3), 1, 2)")
                 .matches(
-                        logicalOneRowRelation().when(r -> {
-                            Substring firstSubstring = (Substring) 
r.getProjects().get(0).child(0);
+                        logicalProject().when(project -> {
+                            Substring firstSubstring = (Substring) 
project.getProjects().get(0).child(0);
                             Assertions.assertEquals("abc", ((Literal) 
firstSubstring.getSource()).getValue());
                             Assertions.assertEquals(1, ((Literal) 
firstSubstring.getPosition()).getValue());
                             Assertions.assertEquals(2, ((Literal) 
firstSubstring.getLength().get()).getValue());
 
-                            Substring secondSubstring = (Substring) 
r.getProjects().get(1).child(0);
-                            Assertions.assertTrue(secondSubstring.getSource() 
instanceof Substring);
+                            Substring secondSubstring = (Substring) 
project.getProjects().get(1).child(0);
+                            Assertions.assertInstanceOf(Substring.class, 
secondSubstring.getSource());
                             Assertions.assertEquals(1, ((Literal) 
secondSubstring.getPosition()).getValue());
                             Assertions.assertEquals(2, ((Literal) 
secondSubstring.getLength().get()).getValue());
                             return true;
@@ -95,13 +95,13 @@ public class FunctionRegistryTest implements 
MemoPatternMatchSupported {
         PlanChecker.from(connectContext)
                 .analyze("select substr('abc', 1), substring('def', 2, 3)")
                 .matches(
-                        logicalOneRowRelation().when(r -> {
-                            Substring firstSubstring = (Substring) 
r.getProjects().get(0).child(0);
+                        logicalProject().when(project -> {
+                            Substring firstSubstring = (Substring) 
project.getProjects().get(0).child(0);
                             Assertions.assertEquals("abc", ((Literal) 
firstSubstring.getSource()).getValue());
                             Assertions.assertEquals(1, ((Literal) 
firstSubstring.getPosition()).getValue());
                             
Assertions.assertTrue(firstSubstring.getLength().isPresent());
 
-                            Substring secondSubstring = (Substring) 
r.getProjects().get(1).child(0);
+                            Substring secondSubstring = (Substring) 
project.getProjects().get(1).child(0);
                             Assertions.assertEquals("def", ((Literal) 
secondSubstring.getSource()).getValue());
                             Assertions.assertEquals(2, ((Literal) 
secondSubstring.getPosition()).getValue());
                             Assertions.assertEquals(3, ((Literal) 
secondSubstring.getLength().get()).getValue());
@@ -111,7 +111,7 @@ public class FunctionRegistryTest implements 
MemoPatternMatchSupported {
     }
 
     @Test
-    public void testAddFunction() throws Exception {
+    public void testAddFunction() {
         FunctionRegistry functionRegistry = new FunctionRegistry() {
             @Override
             protected void afterRegisterBuiltinFunctions(Map<String, 
List<FunctionBuilder>> name2builders) {
@@ -136,9 +136,8 @@ public class FunctionRegistryTest implements 
MemoPatternMatchSupported {
         };
 
         // currently we can not support the override same arity function with 
difference types
-        Assertions.assertThrowsExactly(AnalysisException.class, () -> {
-            functionRegistry.findFunctionBuilder("abc", 
ImmutableList.of(Literal.of(1)));
-        });
+        Assertions.assertThrowsExactly(AnalysisException.class,
+                () -> functionRegistry.findFunctionBuilder("abc", 
ImmutableList.of(Literal.of(1))));
     }
 
     public static class ExtendFunction extends BoundFunction implements 
UnaryExpression, PropagateNullable,
diff --git 
a/fe/fe-core/src/test/java/org/apache/doris/nereids/trees/expressions/UdfTest.java
 
b/fe/fe-core/src/test/java/org/apache/doris/nereids/trees/expressions/UdfTest.java
index db75479bf68..13834642091 100644
--- 
a/fe/fe-core/src/test/java/org/apache/doris/nereids/trees/expressions/UdfTest.java
+++ 
b/fe/fe-core/src/test/java/org/apache/doris/nereids/trees/expressions/UdfTest.java
@@ -71,8 +71,8 @@ public class UdfTest extends TestWithFeService implements 
PlanPatternMatchSuppor
         PlanChecker.from(connectContext)
                 .analyze(sql)
                 .matches(
-                        logicalOneRowRelation()
-                                .when(relation -> 
relation.getProjects().get(0).child(0).equals(expected))
+                        logicalProject()
+                                .when(project -> 
project.getProjects().get(0).child(0).equals(expected))
                 );
 
         connectContext.setDatabase("test_1");
@@ -80,8 +80,8 @@ public class UdfTest extends TestWithFeService implements 
PlanPatternMatchSuppor
         PlanChecker.from(connectContext)
                 .analyze(sql)
                 .matches(
-                        logicalOneRowRelation()
-                                .when(relation -> 
relation.getProjects().get(0).child(0).equals(expected1))
+                        logicalProject()
+                                .when(project -> 
project.getProjects().get(0).child(0).equals(expected1))
                 );
 
         sql = "select test.f(3)";
@@ -89,8 +89,8 @@ public class UdfTest extends TestWithFeService implements 
PlanPatternMatchSuppor
         PlanChecker.from(connectContext)
                 .analyze(sql)
                 .matches(
-                        logicalOneRowRelation()
-                                .when(relation -> 
relation.getProjects().get(0).child(0).equals(expected2))
+                        logicalProject()
+                                .when(project -> 
project.getProjects().get(0).child(0).equals(expected2))
                 );
     }
 
@@ -129,9 +129,9 @@ public class UdfTest extends TestWithFeService implements 
PlanPatternMatchSuppor
         PlanChecker.from(connectContext)
                 .analyze(sql)
                 .matches(
-                        logicalOneRowRelation()
-                                .when(relation -> 
relation.getProjects().size() == 1
-                                        && 
relation.getProjects().get(0).child(0).equals(expected))
+                        logicalProject()
+                                .when(project -> project.getProjects().size() 
== 1
+                                        && 
project.getProjects().get(0).child(0).equals(expected))
                 );
     }
 
@@ -172,9 +172,9 @@ public class UdfTest extends TestWithFeService implements 
PlanPatternMatchSuppor
         PlanChecker.from(connectContext)
                 .analyze(sql)
                 .matches(
-                        logicalOneRowRelation()
-                                .when(relation -> 
relation.getProjects().size() == 1
-                                        && 
relation.getProjects().get(0).child(0).equals(expected))
+                        logicalProject()
+                                .when(project -> project.getProjects().size() 
== 1
+                                        && 
project.getProjects().get(0).child(0).equals(expected))
                 );
     }
 


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to