You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by GitBox <gi...@apache.org> on 2020/08/25 06:52:50 UTC
[GitHub] [incubator-doris] Astralidea opened a new pull request #4445: support StringLiteral try to cast BigInt
Astralidea opened a new pull request #4445:
URL: https://github.com/apache/incubator-doris/pull/4445
## Proposed changes
Describe the big picture of your changes here to communicate to the maintainers why we should accept this pull request. If it fixes a bug or resolves a feature request, be sure to link to that issue.
Fix #4444
## Types of changes
What types of changes does your code introduce to Doris?
_Put an `x` in the boxes that apply_
- [x] Bugfix (non-breaking change which fixes an issue)
- [] New feature (non-breaking change which adds functionality)
- [] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [] Documentation Update (if none of the other choices apply)
- [] Code refactor (Modify the code structure, format the code, etc...)
## Checklist
_Put an `x` in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code._
- [x] I have create an issue on (Fix #ISSUE), and have described the bug/feature there in detail
- [x] Compiling and unit tests pass locally with my changes
- [] I have added tests that prove my fix is effective or that my feature works
- [] If this change need a document change, I have updated the document
- [] Any dependent changes have been merged
## Further comments
If this is a relatively large or complex change, kick off the discussion at dev@doris.apache.org by explaining why you chose the solution you did and what alternatives you considered, etc...
按照我的理解改了一下,可以看看会不会影响其它没有考虑到的情况。
或者说有没有破坏Mysql的一些规则?
----------------------------------------------------------------
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
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
[GitHub] [incubator-doris] kangkaisen commented on a change in pull request #4445: support StringLiteral try to cast BigInt
Posted by GitBox <gi...@apache.org>.
kangkaisen commented on a change in pull request #4445:
URL: https://github.com/apache/incubator-doris/pull/4445#discussion_r476385845
##########
File path: fe/fe-core/src/main/java/org/apache/doris/analysis/BinaryPredicate.java
##########
@@ -307,6 +307,16 @@ private Type getCmpType() {
return Type.LARGEINT;
}
+ // Try parse varchar to bigint
+ if (t1 == PrimitiveType.BIGINT && t2 == PrimitiveType.VARCHAR) {
Review comment:
Yes. you are right. Don't need change this.
----------------------------------------------------------------
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
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
[GitHub] [incubator-doris] kangkaisen commented on a change in pull request #4445: support StringLiteral try to cast BigInt
Posted by GitBox <gi...@apache.org>.
kangkaisen commented on a change in pull request #4445:
URL: https://github.com/apache/incubator-doris/pull/4445#discussion_r476361883
##########
File path: fe/fe-core/src/main/java/org/apache/doris/analysis/BinaryPredicate.java
##########
@@ -307,6 +307,16 @@ private Type getCmpType() {
return Type.LARGEINT;
}
+ // Try parse varchar to bigint
+ if (t1 == PrimitiveType.BIGINT && t2 == PrimitiveType.VARCHAR) {
Review comment:
Because we have `NormalizeBinaryPredicatesRule`. You could only consider slot in left and string Literal in right
----------------------------------------------------------------
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
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
[GitHub] [incubator-doris] kangkaisen commented on pull request #4445: support StringLiteral try to cast BigInt
Posted by GitBox <gi...@apache.org>.
kangkaisen commented on pull request #4445:
URL: https://github.com/apache/incubator-doris/pull/4445#issuecomment-679954520
> 按照我的理解改了一下,可以看看会不会影响其它没有考虑到的情况。
或者说有没有破坏Mysql的一些规则?
when int column compares with string, Mysql will convert string to int, so your PR is OK.
----------------------------------------------------------------
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
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
[GitHub] [incubator-doris] kangkaisen commented on a change in pull request #4445: support StringLiteral try to cast BigInt
Posted by GitBox <gi...@apache.org>.
kangkaisen commented on a change in pull request #4445:
URL: https://github.com/apache/incubator-doris/pull/4445#discussion_r476394115
##########
File path: fe/fe-core/src/main/java/org/apache/doris/catalog/Type.java
##########
@@ -386,6 +386,17 @@ public static Type getAssignmentCompatibleType(Type t1, Type t2, boolean strict)
return ScalarType.INVALID;
}
+ /**
+ * Returns Type.BIGINT if this type could parse to long, otherwise Type.DOUBLE.
+ */
+ public static Long tryParseToLong(Expr expectStringExpr){
+ if(expectStringExpr instanceof StringLiteral) {
Review comment:
```suggestion
if (expectStringExpr instanceof StringLiteral) {
```
##########
File path: fe/fe-core/src/main/java/org/apache/doris/catalog/Type.java
##########
@@ -386,6 +386,17 @@ public static Type getAssignmentCompatibleType(Type t1, Type t2, boolean strict)
return ScalarType.INVALID;
}
+ /**
+ * Returns Type.BIGINT if this type could parse to long, otherwise Type.DOUBLE.
Review comment:
update comment
----------------------------------------------------------------
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
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
[GitHub] [incubator-doris] Astralidea commented on a change in pull request #4445: support StringLiteral try to cast BigInt
Posted by GitBox <gi...@apache.org>.
Astralidea commented on a change in pull request #4445:
URL: https://github.com/apache/incubator-doris/pull/4445#discussion_r476372131
##########
File path: fe/fe-core/src/main/java/org/apache/doris/analysis/BinaryPredicate.java
##########
@@ -307,6 +307,16 @@ private Type getCmpType() {
return Type.LARGEINT;
}
+ // Try parse varchar to bigint
+ if (t1 == PrimitiveType.BIGINT && t2 == PrimitiveType.VARCHAR) {
Review comment:
> Because we have `NormalizeBinaryPredicatesRule`. You could only consider slot in left and string Literal in right
但是我试了一下,如果我注释掉代码后,如果SQL这么写,还是转成Double了,虽然很少有人这么写SQL。
explain select count()
from app_rt_flow_poi_intent_uv_price_v2
where '20200730'=datekey
我看了一下,在`analyzeAndGenerateQueryPlan`是先parsedStmt.analyze再parsedStmt.rewriteExprs这个cast是在analyze里完成的。这块是不是把rewrite提前面不太好提- -。
----------------------------------------------------------------
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
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
[GitHub] [incubator-doris] kangkaisen commented on a change in pull request #4445: support StringLiteral try to cast BigInt
Posted by GitBox <gi...@apache.org>.
kangkaisen commented on a change in pull request #4445:
URL: https://github.com/apache/incubator-doris/pull/4445#discussion_r476370712
##########
File path: fe/fe-core/src/main/java/org/apache/doris/catalog/Type.java
##########
@@ -386,6 +386,20 @@ public static Type getAssignmentCompatibleType(Type t1, Type t2, boolean strict)
return ScalarType.INVALID;
}
+ /**
+ * Returns Type.BIGINT if this type could parse to long, otherwise Type.DOUBLE.
+ */
+ public static Type tryParseToLong(Expr expectStringExpr){
Review comment:
The method name and logic are a little strange. this method does two things: try to parse a string and decide the type. I think we could better split it.
----------------------------------------------------------------
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
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
[GitHub] [incubator-doris] Astralidea commented on a change in pull request #4445: support StringLiteral try to cast BigInt
Posted by GitBox <gi...@apache.org>.
Astralidea commented on a change in pull request #4445:
URL: https://github.com/apache/incubator-doris/pull/4445#discussion_r476372131
##########
File path: fe/fe-core/src/main/java/org/apache/doris/analysis/BinaryPredicate.java
##########
@@ -307,6 +307,16 @@ private Type getCmpType() {
return Type.LARGEINT;
}
+ // Try parse varchar to bigint
+ if (t1 == PrimitiveType.BIGINT && t2 == PrimitiveType.VARCHAR) {
Review comment:
> Because we have `NormalizeBinaryPredicatesRule`. You could only consider slot in left and string Literal in right
但是我试了一下,如果我注释掉代码后,如果SQL这么写,还是转成Double了,虽然很少有人这么写SQL。
explain select count()
from app_rt_flow_poi_intent_uv_price_v2
where '20200730'=datekey
我看了一下,在`analyzeAndGenerateQueryPlan`是先parsedStmt.analyze再parsedStmt.rewriteExprs这个隐式转换是在analyze里完成的。这块是不是把rewrite提前面不太好提- -。
----------------------------------------------------------------
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
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
[GitHub] [incubator-doris] kangkaisen commented on pull request #4445: support StringLiteral try to cast BigInt
Posted by GitBox <gi...@apache.org>.
kangkaisen commented on pull request #4445:
URL: https://github.com/apache/incubator-doris/pull/4445#issuecomment-679983222
@Astralidea Hi, Please add a UT in `SelectStmtTest` to cover this PR. Thanks.
----------------------------------------------------------------
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
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
[GitHub] [incubator-doris] kangkaisen commented on a change in pull request #4445: support StringLiteral try to cast BigInt
Posted by GitBox <gi...@apache.org>.
kangkaisen commented on a change in pull request #4445:
URL: https://github.com/apache/incubator-doris/pull/4445#discussion_r476395080
##########
File path: fe/fe-core/src/main/java/org/apache/doris/analysis/BinaryPredicate.java
##########
@@ -307,6 +307,22 @@ private Type getCmpType() {
return Type.LARGEINT;
}
+ // Try parse varchar to bigint and decide type
Review comment:
would better add a comment to describe why do we want to convert string to bigint. add note this is compatible with Mysql
----------------------------------------------------------------
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
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
[GitHub] [incubator-doris] Astralidea commented on a change in pull request #4445: support StringLiteral try to cast BigInt
Posted by GitBox <gi...@apache.org>.
Astralidea commented on a change in pull request #4445:
URL: https://github.com/apache/incubator-doris/pull/4445#discussion_r476372131
##########
File path: fe/fe-core/src/main/java/org/apache/doris/analysis/BinaryPredicate.java
##########
@@ -307,6 +307,16 @@ private Type getCmpType() {
return Type.LARGEINT;
}
+ // Try parse varchar to bigint
+ if (t1 == PrimitiveType.BIGINT && t2 == PrimitiveType.VARCHAR) {
Review comment:
> Because we have `NormalizeBinaryPredicatesRule`. You could only consider slot in left and string Literal in right
但是我试了一下,如果我注释掉代码后,如果SQL这么写,还是转成Double了,虽然很少有人这么写SQL。
explain select count()
from app_rt_flow_poi_intent_uv_price_v2
where '20200730'=datekey
回头我看一下NormalizeBinaryPredicatesRule的原理。
----------------------------------------------------------------
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
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
[GitHub] [incubator-doris] kangkaisen commented on pull request #4445: support StringLiteral try to cast BigInt
Posted by GitBox <gi...@apache.org>.
kangkaisen commented on pull request #4445:
URL: https://github.com/apache/incubator-doris/pull/4445#issuecomment-679954667
> > 按照我的理解改了一下,可以看看会不会影响其它没有考虑到的情况。
> > 或者说有没有破坏Mysql的一些规则?
when int column compares with string, Mysql will convert string to int, so your PR is OK.
----------------------------------------------------------------
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
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
[GitHub] [incubator-doris] Astralidea commented on pull request #4445: support StringLiteral try to cast BigInt
Posted by GitBox <gi...@apache.org>.
Astralidea commented on pull request #4445:
URL: https://github.com/apache/incubator-doris/pull/4445#issuecomment-680045750
> @Astralidea Hi, Please add a UT in `SelectStmtTest` to cover this PR. Thanks.
OK,看看英文写得有没有啥问题,我英文不太好。
----------------------------------------------------------------
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
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
[GitHub] [incubator-doris] morningman merged pull request #4445: support StringLiteral try to cast BigInt
Posted by GitBox <gi...@apache.org>.
morningman merged pull request #4445:
URL: https://github.com/apache/incubator-doris/pull/4445
----------------------------------------------------------------
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
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
[GitHub] [incubator-doris] Astralidea commented on a change in pull request #4445: support StringLiteral try to cast BigInt
Posted by GitBox <gi...@apache.org>.
Astralidea commented on a change in pull request #4445:
URL: https://github.com/apache/incubator-doris/pull/4445#discussion_r476389361
##########
File path: fe/fe-core/src/main/java/org/apache/doris/catalog/Type.java
##########
@@ -386,6 +386,20 @@ public static Type getAssignmentCompatibleType(Type t1, Type t2, boolean strict)
return ScalarType.INVALID;
}
+ /**
+ * Returns Type.BIGINT if this type could parse to long, otherwise Type.DOUBLE.
+ */
+ public static Type tryParseToLong(Expr expectStringExpr){
Review comment:
> The method name and logic are a little strange. this method does two things: try to parse a string and decide the type. I think we could better split it.
感谢指出问题,我改了一下,看看行不行,是否还有问题。
----------------------------------------------------------------
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
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org