xy720 commented on code in PR #16948:
URL: https://github.com/apache/doris/pull/16948#discussion_r1112482642


##########
fe/fe-core/src/main/java/org/apache/doris/analysis/MapLiteral.java:
##########
@@ -47,30 +47,18 @@ public MapLiteral(LiteralExpr... exprs) throws 
AnalysisException {
         Type keyType = Type.NULL;
         Type valueType = Type.NULL;
         children = new ArrayList<>();
-        int idx = 0;
-        // TODO(xy): limit key type to scalar type
-        for (LiteralExpr expr : exprs) {
-            if (idx % 2 == 0) {
-                if (keyType == Type.NULL) {
-                    keyType = expr.getType();
-                } else {
-                    keyType = Type.getAssignmentCompatibleType(keyType, 
expr.getType(), true);
-                }
-                if (keyType == Type.INVALID) {
-                    throw new AnalysisException("Invalid element type in Map");
-                }
-            } else {
-                if (valueType == Type.NULL) {
-                    valueType = expr.getType();
-                } else {
-                    valueType = Type.getAssignmentCompatibleType(valueType, 
expr.getType(), true);
-                }
-                if (valueType == Type.INVALID) {
-                    throw new AnalysisException("Invalid element type in Map");
-                }
+        for (int idx = 0; idx < exprs.length && idx + 1 < exprs.length; idx += 
2) {
+            // limit key type to scalar type
+            keyType = Type.getAssignmentCompatibleType(keyType, 
exprs[idx].getType(), true);
+            if (keyType == Type.INVALID || !keyType.isScalarType()) {
+                throw new AnalysisException("Invalid key type in Map Only 
support scalar type");

Review Comment:
   for example, date and int are scala types but they are not compatible with 
each other.
   But the error msg is "Invalid key type in Map Only support scalar type".



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