Github user hvanhovell commented on a diff in the pull request:
https://github.com/apache/spark/pull/16954#discussion_r105717078
--- Diff:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/predicates.scala
---
@@ -123,19 +123,36 @@ case class Not(child: Expression)
*/
@ExpressionDescription(
usage = "expr1 _FUNC_(expr2, expr3, ...) - Returns true if `expr` equals
to any valN.")
-case class In(value: Expression, list: Seq[Expression]) extends Predicate
- with ImplicitCastInputTypes {
+case class In(value: Expression, list: Seq[Expression]) extends Predicate {
require(list != null, "list should not be null")
-
- override def inputTypes: Seq[AbstractDataType] = value.dataType +:
list.map(_.dataType)
-
override def checkInputDataTypes(): TypeCheckResult = {
- if (list.exists(l => l.dataType != value.dataType)) {
- TypeCheckResult.TypeCheckFailure(
- "Arguments must be same type")
- } else {
- TypeCheckResult.TypeCheckSuccess
+ list match {
+ case ListQuery(sub, _, _) :: Nil =>
+ val valExprs = value match {
+ case cns: CreateNamedStruct => cns.valExprs
+ case expr => Seq(expr)
+ }
+ val isTypeMismatched = valExprs.zip(sub.output).exists {
+ case (l, r) => l.dataType != r.dataType
+ }
+ if (isTypeMismatched) {
+ TypeCheckResult.TypeCheckFailure(
+ s"""
+ |The data type of one or more elements in the LHS of an IN
subquery
+ |[${valExprs.map(_.dataType).mkString(", ")}]
--- End diff --
Use catalog strings please.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]