You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@doris.apache.org by GitBox <gi...@apache.org> on 2019/07/03 01:41:33 UTC
[GitHub] [incubator-doris] imay commented on a change in pull request #1422:
Cast the type of constant value in binary predicate to column type.
imay commented on a change in pull request #1422: Cast the type of constant value in binary predicate to column type.
URL: https://github.com/apache/incubator-doris/pull/1422#discussion_r299746936
##########
File path: fe/src/main/java/org/apache/doris/analysis/BinaryPredicate.java
##########
@@ -299,6 +302,29 @@ private Type getCmpType() {
return Type.LARGEINT;
}
+ /*
+ * If one child is SlotRef and the other is a constant expr,
+ * set the compatible type to SlotRef's column type.
+ * eg:
+ * k1(int):
+ * ... WHERE k1 = "123" --> k1 = cast("123" as int);
+ *
+ * k2(varchar):
+ * ... WHERE 123 = k2 --> cast(123 as varchar) = k2
+ *
+ * This optimization is for the case that some user may using a int column to save date, eg: 20190703,
+ * but query with predicate: col = "20190703".
+ *
+ * If not casting "20190703" to int, query optimizer can not do partition prune correctly.
+ *
+ */
+ if (child0 instanceof SlotRef && child1.isConstant()) {
+ return child0.getType();
+ } else if (child1 instanceof SlotRef && child0.isConstant()) {
+ return child1.getType();
+ }
+
+ // double can be cast to any types
Review comment:
any type can be casted to double?
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@doris.apache.org
For additional commands, e-mail: dev-help@doris.apache.org