Quanlong Huang has posted comments on this change. ( http://gerrit.cloudera.org:8080/17933 )
Change subject: IMPALA-10836: Add 'CastExprSimplifyRule' rule to rewrite cast expr in some situations ...................................................................... Patch Set 2: (9 comments) http://gerrit.cloudera.org:8080/#/c/17933/2//COMMIT_MSG Commit Message: http://gerrit.cloudera.org:8080/#/c/17933/2//COMMIT_MSG@7 PS2, Line 7: CastExprSimplifyRule Can we rename it to 'SimplifyCastExprRule'? We already have some similar names like SimplifyConditionalsRule, SimplifyDistinctFromRule, SimplifyCastStringToTimestamp, etc. http://gerrit.cloudera.org:8080/#/c/17933/2//COMMIT_MSG@9 PS2, Line 9: add nit: adds http://gerrit.cloudera.org:8080/#/c/17933/2//COMMIT_MSG@11 PS2, Line 11: is same nit: is the same http://gerrit.cloudera.org:8080/#/c/17933/2//COMMIT_MSG@12 PS2, Line 12: is same nit: is the same http://gerrit.cloudera.org:8080/#/c/17933/2//COMMIT_MSG@14 PS2, Line 14: if matched rule nit: if any rules is matched http://gerrit.cloudera.org:8080/#/c/17933/2//COMMIT_MSG@15 PS2, Line 15: cast nit: casting http://gerrit.cloudera.org:8080/#/c/17933/2//COMMIT_MSG@16 PS2, Line 16: Especially when scan lots of data. nit: , especially when scanning lots of data. http://gerrit.cloudera.org:8080/#/c/17933/2/fe/src/main/java/org/apache/impala/rewrite/CastExprSimplifyRule.java File fe/src/main/java/org/apache/impala/rewrite/CastExprSimplifyRule.java: http://gerrit.cloudera.org:8080/#/c/17933/2/fe/src/main/java/org/apache/impala/rewrite/CastExprSimplifyRule.java@56 PS2, Line 56: if (castExpr.getChild(0) instanceof SlotRef) Can we remove this check? So the rule can apply to more scenarios, e.g. CAST(a + b AS INT) ==> INT where a,b are INT columns. http://gerrit.cloudera.org:8080/#/c/17933/2/fe/src/main/java/org/apache/impala/rewrite/CastExprSimplifyRule.java@56 PS2, Line 56: if (castExpr.getChild(0) instanceof SlotRef) { : Preconditions.checkState(castExpr.getChildren().size() == 1); : SlotRef slotRef = (SlotRef) castExpr.getChild(0); : return castExpr.getType().matchesType(slotRef.getType()) ? slotRef : castExpr; : } else if (castExpr.getChild(0) instanceof CastExpr) { : Preconditions.checkState(castExpr.getChildren().size() == 1); : CastExpr subCastExpr = (CastExpr) castExpr.getChild(0); : return castExpr.getType().matchesType(subCastExpr.getType())? : subCastExpr : castExpr; : } I think we can merge these two branches into one. We just check the first child type with the castExpr type, and return either the first child or the original castExpr. -- To view, visit http://gerrit.cloudera.org:8080/17933 To unsubscribe, visit http://gerrit.cloudera.org:8080/settings Gerrit-Project: Impala-ASF Gerrit-Branch: master Gerrit-MessageType: comment Gerrit-Change-Id: Id8fac7100060d4e139a8b24d4795c6f279c55954 Gerrit-Change-Number: 17933 Gerrit-PatchSet: 2 Gerrit-Owner: wangsheng <[email protected]> Gerrit-Reviewer: Impala Public Jenkins <[email protected]> Gerrit-Reviewer: Quanlong Huang <[email protected]> Gerrit-Reviewer: Xianqing He <[email protected]> Gerrit-Reviewer: Zoltan Borok-Nagy <[email protected]> Gerrit-Comment-Date: Thu, 21 Oct 2021 08:47:31 +0000 Gerrit-HasComments: Yes
