EmmyMiao87 commented on a change in pull request #2799: Return NullLiteral in 
castTo method instead of throwing a exception
URL: https://github.com/apache/incubator-doris/pull/2799#discussion_r368516189
 
 

 ##########
 File path: fe/src/test/java/org/apache/doris/analysis/SqlModeTest.java
 ##########
 @@ -76,4 +80,34 @@ public void testPipesAsConcatMode() {
         }
         Assert.assertEquals("(('a') OR ('b')) OR ('c')", expr.toSql());
     }
+
+    @Test
+    public void testPipesAsConcatModeNull() {
+        // Mode Active
+        String stmt = new String("SELECT ('10' || 'xy' > 1) + 2");
+        SqlParser parser = new SqlParser(new SqlScanner(new 
StringReader(stmt), SqlModeHelper.MODE_PIPES_AS_CONCAT));
+        SelectStmt parsedStmt = null;
+        try {
+            parsedStmt = (SelectStmt) parser.parse().value;
+        } catch (Exception e) {
+            Assert.fail(e.getMessage());
+        }
+        Expr expr = parsedStmt.getSelectList().getItems().get(0).getExpr();
+        if (!(expr.contains(FunctionCallExpr.class))) {
+            Assert.fail("Mode not working");
+        }
+
+        analyzer = AccessTestUtil.fetchAdminAnalyzer(false);
+        try {
+            parsedStmt.analyze(analyzer);
+            ExprRewriter rewriter = analyzer.getExprRewriter();
+            rewriter.reset();
+            parsedStmt.rewriteExprs(rewriter);
+
+            Expr result = 
parsedStmt.getSelectList().getItems().get(0).getExpr();
+            Assert.assertEquals(Expr.IS_NULL_LITERAL.apply(result), true);
 
 Review comment:
   what the different between IS_NULL_LITERAL  and result instance of 
NullLiteral  

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

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

Reply via email to