Github user EntilZha commented on a diff in the pull request: https://github.com/apache/spark/pull/7580#discussion_r35295129 --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/collectionOperations.scala --- @@ -35,3 +36,47 @@ case class Size(child: Expression) extends UnaryExpression with ExpectsInputType nullSafeCodeGen(ctx, ev, c => s"${ev.primitive} = ($c).size();") } } + +case class ArrayContains(left: Expression, right: Expression) extends BinaryExpression with ExpectsInputTypes { + override def dataType: DataType = BooleanType + + override def inputTypes: Seq[AbstractDataType] = Seq(ArrayType, AnyDataType) --- End diff -- Agreed, we should not do implicit casting. The above python code should work, but it is failing if I do an exact type match. Specifically, this code makes it fail: ```scala override def checkInputDataTypes(): TypeCheckResult = { if (!left.dataType.isInstanceOf[ArrayType]) { TypeCheckResult.TypeCheckFailure( s"type of first input must be an array, not ${left.dataType.simpleString}") } else { val elementType = left.dataType.asInstanceOf[ArrayType].elementType if (elementType.acceptsType(right.dataType) && right.dataType.acceptsType(elementType)) { TypeCheckResult.TypeCheckSuccess } else { TypeCheckResult.TypeCheckFailure( s"type of value must match array type " + s"${elementType.simpleString}, not " + s"${right.dataType.simpleString}") } } } ``` due to this exception being thrown: `cannot resolve 'array_contains(data,1)' due to data type mismatch: type of value must match array type bigint, not int;` That seems like the wrong thing to do. Additionally, I think it should work to do something like `array_contains([1.0, 2.0], 1)` and expect it to return true. This can be left to `scala` I think when it does a comparison. This would mean however that checking for exact type equality would break this. So either we could leave this and allow comparison of obviously incompatible types, or we could implement that the types of elements must match to some degree (for example, numerics with numerics, strings with strings etc).
--- 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 infrastruct...@apache.org or file a JIRA ticket with INFRA. --- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org