morrySnow commented on code in PR #57532:
URL: https://github.com/apache/doris/pull/57532#discussion_r2485552790
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/ExpressionAnalyzer.java:
##########
@@ -256,6 +265,37 @@ public Expression visitUnboundAlias(UnboundAlias
unboundAlias, ExpressionRewrite
}
}
+ @Override
+ public Expression visitDereferenceExpression(DereferenceExpression
dereferenceExpression,
+ ExpressionRewriteContext context) {
+ Expression expression = dereferenceExpression.child(0).accept(this,
context);
+ DataType dataType = expression.getDataType();
+ if (dataType.isStructType()) {
+ StructType structType = (StructType) dataType;
+ StructField field =
structType.getField(dereferenceExpression.fieldName);
+ if (field != null) {
+ return new StructElement(expression,
dereferenceExpression.child(1));
+ }
+ } else if (dataType.isArrayType()) {
+ if (dereferenceExpression.fieldName.equalsIgnoreCase("size")) {
+ return new Cardinality(expression);
+ }
Review Comment:
so, maybe wo should remove array.size too. because this make dereference has
two different behavior on different types
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/ExpressionAnalyzer.java:
##########
@@ -256,6 +265,37 @@ public Expression visitUnboundAlias(UnboundAlias
unboundAlias, ExpressionRewrite
}
}
+ @Override
+ public Expression visitDereferenceExpression(DereferenceExpression
dereferenceExpression,
+ ExpressionRewriteContext context) {
+ Expression expression = dereferenceExpression.child(0).accept(this,
context);
Review Comment:
better to add ut for it
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/ExpressionAnalyzer.java:
##########
@@ -256,6 +265,37 @@ public Expression visitUnboundAlias(UnboundAlias
unboundAlias, ExpressionRewrite
}
}
+ @Override
+ public Expression visitDereferenceExpression(DereferenceExpression
dereferenceExpression,
+ ExpressionRewriteContext context) {
+ Expression expression = dereferenceExpression.child(0).accept(this,
context);
+ DataType dataType = expression.getDataType();
+ if (dataType.isStructType()) {
+ StructType structType = (StructType) dataType;
+ StructField field =
structType.getField(dereferenceExpression.fieldName);
+ if (field != null) {
+ return new StructElement(expression,
dereferenceExpression.child(1));
+ }
+ } else if (dataType.isArrayType()) {
+ if (dereferenceExpression.fieldName.equalsIgnoreCase("size")) {
+ return new Cardinality(expression);
+ }
+ } else if (dataType.isMapType()) {
+ if (dereferenceExpression.fieldName.equalsIgnoreCase("size")) {
+ return new MapSize(expression);
+ } else if
(dereferenceExpression.fieldName.equalsIgnoreCase("keys")) {
Review Comment:
map.keys should return map['keys'], not map's key set
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]