Github user dilipbiswal commented on a diff in the pull request:
https://github.com/apache/spark/pull/21403#discussion_r206322597
--- Diff:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala
---
@@ -1422,11 +1422,26 @@ class Analyzer(
resolveSubQuery(s, plans)(ScalarSubquery(_, _, exprId))
case e @ Exists(sub, _, exprId) if !sub.resolved =>
resolveSubQuery(e, plans)(Exists(_, _, exprId))
- case In(value, Seq(l @ ListQuery(sub, _, exprId, _))) if
value.resolved && !l.resolved =>
+ case In(values, Seq(l @ ListQuery(_, _, exprId, _)))
+ if values.forall(_.resolved) && !l.resolved =>
val expr = resolveSubQuery(l, plans)((plan, exprs) => {
ListQuery(plan, exprs, exprId, plan.output)
})
- In(value, Seq(expr))
+ val subqueryOutput = expr.plan.output
+ val resolvedIn = In(values, Seq(expr))
+ if (values.length != subqueryOutput.length) {
+ throw new AnalysisException(
--- End diff --
@mgaido91 I tried the following -
```
create table in(c1 int);
insert into in values(1);
spark-sql> select * from in where c1 in (1);
1
spark-sql> select * from in where c1 in (cast(1 as float));
1
spark-sql> select * from in where (c1,c1) in ((cast(1 as float), 1));
Error in query: cannot resolve '(named_struct('c1', in.`c1`, 'c1', in.`c1`)
IN (named_struct('col1', CAST(1 AS FLOAT), 'col2', 1)))' due to data type
mismatch: Arguments must be same type but were: struct<c1:int,c1:int> !=
struct<col1:float,col2:int>; line 1 pos 31;
```
Just a question, should we have been able to do a type promotion here ?
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]