nikolamand-db commented on code in PR #45693:
URL: https://github.com/apache/spark/pull/45693#discussion_r1537456608
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/collectionOperations.scala:
##########
@@ -1994,17 +1995,23 @@ case class Slice(x: Expression, start: Expression,
length: Expression)
case class ArrayJoin(
array: Expression,
delimiter: Expression,
- nullReplacement: Option[Expression]) extends Expression with
ExpectsInputTypes {
+ nullReplacement: Option[Expression]) extends ImplicitCastInputTypes {
def this(array: Expression, delimiter: Expression) = this(array, delimiter,
None)
def this(array: Expression, delimiter: Expression, nullReplacement:
Expression) =
this(array, delimiter, Some(nullReplacement))
- override def inputTypes: Seq[AbstractDataType] = if
(nullReplacement.isDefined) {
- Seq(ArrayType(StringType), StringType, StringType)
- } else {
- Seq(ArrayType(StringType), StringType)
+ override def inputTypes: Seq[AbstractDataType] = {
+ val arrayType = array.dataType.asInstanceOf[ArrayType].elementType match {
+ case _: StringType => array.dataType
+ case _ => ArrayType(StringType)
+ }
+ if (nullReplacement.isDefined) {
+ Seq(arrayType, StringTypeAnyCollation, StringTypeAnyCollation)
+ } else {
+ Seq(arrayType, StringTypeAnyCollation)
+ }
Review Comment:
@mihailom-db There are already examples of such checks performed in
`inputTypes`, here are few:
https://github.com/apache/spark/blob/49b7dbce68a4620f552a595e180831c9d678e25d/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/collectionOperations.scala#L59-L68
https://github.com/apache/spark/blob/49b7dbce68a4620f552a595e180831c9d678e25d/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/collectionOperations.scala#L2341-L2350
I see a potential issue in implicit
[conversions](https://github.com/apache/spark/blob/8762e256d164c6b89102e9bf71478643a7cc0d2c/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/TypeCoercion.scala#L1016-L1023)
if I replace it with `ArrayType` without StringType information. Is there some
kind of explicit conversion which will override 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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]