You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by GitBox <gi...@apache.org> on 2020/01/20 12:12:09 UTC

[GitHub] [incubator-doris] EmmyMiao87 commented on a change in pull request #2799: Return NullLiteral in castTo method instead of throwing a exception

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:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org