Uh oh!
There was an error while loading. Please reload this page.
[SPARK-29860][SQL] Fix dataType mismatch issue for InSubquery. - #26485
[SPARK-29860][SQL] Fix dataType mismatch issue for InSubquery.#26485turboFei wants to merge 1 commit into
Conversation
maropu
commented
Nov 13, 2019
ok to test |
Uh oh!
There was an error while loading. Please reload this page.
SparkQA
commented
Nov 13, 2019
Test build #113659 has finished for PR 26485 at commit
|
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
SparkQA
commented
Nov 13, 2019
Test build #113665 has finished for PR 26485 at commit
|
amanomer
commented
Nov 13, 2019
SparkQA
commented
Nov 13, 2019
Test build #113678 has finished for PR 26485 at commit
|
turboFei
commented
Nov 13, 2019
cc @wangyum |
SparkQA
commented
Nov 13, 2019
Test build #113689 has finished for PR 26485 at commit
|
SparkQA
commented
Nov 13, 2019
Test build #113691 has finished for PR 26485 at commit
|
SparkQA
commented
Nov 13, 2019
Test build #113699 has finished for PR 26485 at commit
|
| Some(widerType) | ||
| } else { | ||
| None | ||
| } |
There was a problem hiding this comment.
This code looks suspicious... I personally think this issue should be fixed only in InConversion instead of findTightestCommonType. That's because the change of findTightestCommonType can affect type coercion in the other operations... cc: @mgaido91@cloud-fan
There was a problem hiding this comment.
I think for two decimalType, such as Decimal(3,0) and Decimal(3,2), their tightest common type should be Decimal(5,2), which is consistent with the method name findTightestCommonType.
There was a problem hiding this comment.
is this related to the specific bug? If not let's open another PR to do it.
There was a problem hiding this comment.
It's more reasonable to fix InConversion. I think it's wrong that In and InSubquery have different type coercion logic.
There was a problem hiding this comment.
Actually InConversion and BinaryComparison also have different type coercion logic: #22038
There was a problem hiding this comment.
I find a similar implementation:
There was a problem hiding this comment.
I think it's wrong that In and InSubquery have different type coercion logic.
I agree on this. Please see #19635, where I tried to fix this....
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
maropu
commented
Nov 14, 2019
I think the PR description above should be self-descriptive, so could you please make that more clearer? What's a root cause of this issue, how to fix, brabrabra... |
turboFei
commented
Nov 14, 2019
Thanks, updated. |
SparkQA
commented
Nov 14, 2019
Test build #113745 has finished for PR 26485 at commit
|
SparkQA
commented
Nov 14, 2019
Test build #113782 has finished for PR 26485 at commit
|
SparkQA
commented
Nov 14, 2019
Test build #113788 has finished for PR 26485 at commit
|
SparkQA
commented
Nov 14, 2019
Test build #113780 has finished for PR 26485 at commit
|
SparkQA
commented
Nov 14, 2019
Test build #113791 has finished for PR 26485 at commit
|
Uh oh!
There was an error while loading. Please reload this page.
SparkQA
commented
Nov 14, 2019
Test build #113794 has finished for PR 26485 at commit
|
SparkQA
commented
Nov 15, 2019
Test build #113879 has finished for PR 26485 at commit
|
turboFei
commented
Nov 15, 2019
retest this please. |
maropu
commented
Nov 15, 2019
retest this please |
SparkQA
commented
Nov 16, 2019
Test build #113899 has finished for PR 26485 at commit
|
HyukjinKwon
commented
Dec 4, 2019
retest this please |
HyukjinKwon
commented
Dec 4, 2019
cc @liancheng as well |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
SparkQA
commented
Dec 4, 2019
Test build #114820 has finished for PR 26485 at commit
|
| -- !query 9 output | ||
| org.apache.spark.sql.AnalysisException | ||
| cannot resolve '(named_struct('t4a', t4.`t4a`, 't4b', t4.`t4b`, 't4c', t4.`t4c`) IN (listquery()))' due to data type mismatch: | ||
| cannot resolve '(named_struct('t4a', t4.`t4a`, 't4b', t4.`t4b`, 't4c', t4.`t4c`) IN (listquery()))' due to data type mismatch: |
There was a problem hiding this comment.
In fact, I do not know why a space is involved, I have tried to remove it, but failed. It should does not matter.
SparkQA
commented
Dec 4, 2019
Test build #114835 has finished for PR 26485 at commit
|
cloud-fan
commented
Dec 4, 2019
LGTM. Can we check the behavior in other databases like pgsql? It's better to know if Spark follows SQL standard or not. |
turboFei
commented
Dec 4, 2019
Will check the behavior later. |
SparkQA
commented
Dec 4, 2019
Test build #114847 has finished for PR 26485 at commit
|
turboFei
commented
Dec 4, 2019
cloud-fan
commented
Dec 4, 2019
How about the other way around (string in decimal)? Anyway this is already the behavior of |
turboFei
commented
Dec 4, 2019
The result is similar: |
SparkQA
commented
Dec 4, 2019
Test build #114862 has finished for PR 26485 at commit
|
cloud-fan
commented
Dec 5, 2019
thanks, merging to master! |
### What changes were proposed in this pull request?
There is an issue for InSubquery expression.
For example, there are two tables `ta` and `tb` created by the below statements.
```
sql("create table ta(id Decimal(18,0)) using parquet")
sql("create table tb(id Decimal(19,0)) using parquet")
```
This statement below would thrown dataType mismatch exception.
```
sql("select * from ta where id in (select id from tb)").show()
```
However, this similar statement could execute successfully.
```
sql("select * from ta where id in ((select id from tb))").show()
```
The root cause is that, for `InSubquery` expression, it does not find a common type for two decimalType like `In` expression.
Besides that, for `InSubquery` expression, it also does not find a common type for DecimalType and double/float/bigInt.
In this PR, I fix this issue by finding widerType for `InSubquery` expression when DecimalType is involved.
### Why are the changes needed?
Some InSubquery would throw dataType mismatch exception.
### Does this PR introduce any user-facing change?
No.
### How was this patch tested?
Unit test.
Closesapache#26485 from turboFei/SPARK-29860-in-subquery.
Authored-by: turbofei <fwang12@ebay.com>
Signed-off-by: Wenchen Fan <wenchen@databricks.com>
What changes were proposed in this pull request?
There is an issue for InSubquery expression.
For example, there are two tables
taandtbcreated by the below statements.This statement below would thrown dataType mismatch exception.
However, this similar statement could execute successfully.
The root cause is that, for
InSubqueryexpression, it does not find a common type for two decimalType likeInexpression.Besides that, for
InSubqueryexpression, it also does not find a common type for DecimalType and double/float/bigInt.In this PR, I fix this issue by finding widerType for
InSubqueryexpression when DecimalType is involved.Why are the changes needed?
Some InSubquery would throw dataType mismatch exception.
Does this PR introduce any user-facing change?
No.
How was this patch tested?
Unit test.