yangzhg commented on a change in pull request #6504:
URL: https://github.com/apache/incubator-doris/pull/6504#discussion_r696228118



##########
File path: 
fe/fe-core/src/main/java/org/apache/doris/analysis/FunctionCallExpr.java
##########
@@ -322,6 +359,48 @@ private void analyzeBuiltinAggFunction(Analyzer analyzer) 
throws AnalysisExcepti
             }
             return;
         }
+        
+        if(fnName.getFunction().equalsIgnoreCase("json_array")) {
+            if (children.isEmpty()) {
+                throw new AnalysisException(
+                        "json_array is empty, need more parameters: " + 
this.toSql());
+            }
+            dealJsonTypeFun();
+            return;
+        }
+
+        if(fnName.getFunction().equalsIgnoreCase("json_object")) {
+            if (children.isEmpty()) {
+                throw new AnalysisException("json_object is empty, need more 
parameters: " + this.toSql());
+            }
+            if ((children.size()&1)==1 && (originChildNum == children.size())) 
{
+                throw new AnalysisException("json_object can't be odd 
parameters, need even parameters: " + this.toSql());
+            }
+            String res = "";
+            extra_mark = extra_mark + "#";
+            for (int i = 0; i < children.size(); ++i) {
+                Type type = getChild(i).getType();
+                if (type.isNull()) {
+                    if((i&1)==0){
+                        throw new AnalysisException("json_object key can't be 
NULL: " + this.toSql());
+                    }
+                    children.set(i, new StringLiteral("NULL"));
+                    res = res + "0";
+                } else if (type.isBoolean()) {
+                    res = res + "1";
+                } else if (type.isNumericType()) {
+                    res = res + "2";
+                } else if (type.isTime()) {
+                    res = res + "3";
+                } else {
+                    res = res + "4";
+                }
+            }
+            res = res + extra_mark;
+            children.add(new StringLiteral(res));
+            LOG.info(res + " sql: " + this.toSql());
+            return;
+        }

Review comment:
       Duplicated with dealJsonTypeFun?




-- 
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.

To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



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

Reply via email to