xy720 commented on code in PR #16948: URL: https://github.com/apache/doris/pull/16948#discussion_r1112488331
########## fe/fe-core/src/main/java/org/apache/doris/analysis/MapLiteral.java: ########## @@ -47,30 +47,35 @@ 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"); - } + // check types here + // 1. limit key type with map-key support + // 2. check type can be assigment for cast + for (int idx = 0; idx < exprs.length && idx + 1 < exprs.length; idx += 2) { + if (type.supportSubType(exprs[idx].getType())) { Review Comment: type is not initialized. Why not use a new static method? -- 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