You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "nikolamand-db (via GitHub)" <gi...@apache.org> on 2024/03/25 09:04:36 UTC

[PR] [SPARK-47541][SQL] Collated strings in complex types supporting operations reverse, array_join, concat, map [spark]

nikolamand-db opened a new pull request, #45693:
URL: https://github.com/apache/spark/pull/45693

   <!--
   Thanks for sending a pull request!  Here are some tips for you:
     1. If this is your first time, please read our contributor guidelines: https://spark.apache.org/contributing.html
     2. Ensure you have added or run the appropriate tests for your PR: https://spark.apache.org/developer-tools.html
     3. If the PR is unfinished, add '[WIP]' in your PR title, e.g., '[WIP][SPARK-XXXX] Your PR title ...'.
     4. Be sure to keep the PR description updated to reflect all changes.
     5. Please write your PR title to summarize what this PR proposes.
     6. If possible, provide a concise example to reproduce the issue for a faster review.
     7. If you want to add a new configuration, please read the guideline first for naming configurations in
        'core/src/main/scala/org/apache/spark/internal/config/ConfigEntry.scala'.
     8. If you want to add or modify an error type or message, please read the guideline first in
        'common/utils/src/main/resources/error/README.md'.
   -->
   
   ### What changes were proposed in this pull request?
   <!--
   Please clarify what changes you are proposing. The purpose of this section is to outline the changes and how this PR fixes the issue. 
   If possible, please consider writing useful notes for better and faster reviews in your PR. See the examples below.
     1. If you refactor some codes with changing classes, showing the class hierarchy will help reviewers.
     2. If you fix some SQL features, you can provide some references of other DBMSes.
     3. If there is design documentation, please add the link.
     4. If there is a discussion in the mailing list, please add the link.
   -->
   
   Add proper support for complex types containing collated strings in operations reverse, array_join, concat, map (create). Examples:
   ```
   select reverse('abc' collate utf8_binary_lcase);
   select reverse(array('a' collate utf8_binary_lcase, 'b' collate utf8_binary_lcase));
   select array_join(array('a' collate utf8_binary_lcase, 'b' collate utf8_binary_lcase), ', ' collate utf8_binary_lcase);
   select concat('a' collate utf8_binary_lcase, 'b' collate utf8_binary_lcase);
   select map('a' collate utf8_binary_lcase, 1, 'A' collate utf8_binary_lcase, 2);
   ```
   ### Why are the changes needed?
   <!--
   Please clarify why the changes are needed. For instance,
     1. If you propose a new API, clarify the use case for a new API.
     2. If you fix a bug, you can clarify why it is a bug.
   -->
   
   To enable listed complex types operations support for collated strings.
   
   ### Does this PR introduce _any_ user-facing change?
   <!--
   Note that it means *any* user-facing change including all aspects such as the documentation fix.
   If yes, please clarify the previous behavior and the change this PR proposes - provide the console output, description and/or an example to show the behavior difference if possible.
   If possible, please also clarify if this is a user-facing change compared to the released Spark versions or within the unreleased branches such as master.
   If no, write 'No'.
   -->
   
   Yes, results of listed complex types operations will return expected results to users.
   
   ### How was this patch tested?
   <!--
   If tests were added, say they were added here. Please make sure to add some test cases that check the changes thoroughly including negative and positive cases if possible.
   If it was tested in a way different from regular unit tests, please clarify how you tested step by step, ideally copy and paste-able, so that other reviewers can test and check, and descendants can verify in the future.
   If tests were not added, please describe why they were not added and/or why it was difficult to add.
   If benchmark tests were added, please run the benchmarks in GitHub Actions for the consistent environment, and the instructions could accord to: https://spark.apache.org/developer-tools.html#github-workflow-benchmarks.
   -->
   
   Added checks to collations suite.
   
   ### Was this patch authored or co-authored using generative AI tooling?
   <!--
   If generative AI tooling has been used in the process of authoring this patch, please include the
   phrase: 'Generated-by: ' followed by the name of the tool and its version.
   If no, write 'No'.
   Please refer to the [ASF Generative Tooling Guidance](https://www.apache.org/legal/generative-tooling.html) for details.
   -->
   
   No.


-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-47541][SQL] Collated strings in complex types supporting operations reverse, array_join, concat, map [spark]

Posted by "mihailom-db (via GitHub)" <gi...@apache.org>.
mihailom-db commented on code in PR #45693:
URL: https://github.com/apache/spark/pull/45693#discussion_r1537297293


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/collectionOperations.scala:
##########
@@ -1994,17 +1995,26 @@ 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 with ExpectsInputTypes {
 
   def this(array: Expression, delimiter: Expression) = this(array, delimiter, None)
 
   def this(array: Expression, delimiter: Expression, nullReplacement: Expression) =
     this(array, delimiter, Some(nullReplacement))
 
+  private val commonType: DataType = {
+    val elementType = array.dataType.asInstanceOf[ArrayType].elementType
+    val s = nullReplacement match {
+      case Some(replacement) => Seq(elementType, delimiter.dataType, replacement.dataType)
+      case _ => Seq(elementType, delimiter.dataType)
+    }
+    TypeCoercion.findWiderCommonType(s).getOrElse(StringType)
+  }
+
   override def inputTypes: Seq[AbstractDataType] = if (nullReplacement.isDefined) {
-    Seq(ArrayType(StringType), StringType, StringType)
+    Seq(ArrayType(commonType), commonType, commonType)
   } else {
-    Seq(ArrayType(StringType), StringType)
+    Seq(ArrayType(commonType), commonType)
   }

Review Comment:
   One more thing is. This what you do with findWiderCommonType is not correct. If delimiter has explicit collation, we would like to have that collation. In your case you would collect two different collations, where arrayType.elementType would go first and findWiderCommonType practically does not do anything with delimiter's type, but would keep the first element type.



-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-47541][SQL] Collated strings in complex types supporting operations reverse, array_join, concat, map [spark]

Posted by "mihailom-db (via GitHub)" <gi...@apache.org>.
mihailom-db commented on code in PR #45693:
URL: https://github.com/apache/spark/pull/45693#discussion_r1537277643


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/collectionOperations.scala:
##########
@@ -2149,7 +2159,7 @@ case class ArrayJoin(
     }
   }
 
-  override def dataType: DataType = StringType
+  override def dataType: DataType = commonType

Review Comment:
   Why not use some type of pass through where we would say dataType = array.asInstanceOf[ArrayType].elementType? Implicit casting should solve the problem of collations. 



-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-47541][SQL] Collated strings in complex types supporting operations reverse, array_join, concat, map [spark]

Posted by "mihailom-db (via GitHub)" <gi...@apache.org>.
mihailom-db commented on code in PR #45693:
URL: https://github.com/apache/spark/pull/45693#discussion_r1537271446


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/collectionOperations.scala:
##########
@@ -1994,17 +1995,26 @@ 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 with ExpectsInputTypes {
 
   def this(array: Expression, delimiter: Expression) = this(array, delimiter, None)
 
   def this(array: Expression, delimiter: Expression, nullReplacement: Expression) =
     this(array, delimiter, Some(nullReplacement))
 
+  private val commonType: DataType = {
+    val elementType = array.dataType.asInstanceOf[ArrayType].elementType
+    val s = nullReplacement match {
+      case Some(replacement) => Seq(elementType, delimiter.dataType, replacement.dataType)
+      case _ => Seq(elementType, delimiter.dataType)
+    }
+    TypeCoercion.findWiderCommonType(s).getOrElse(StringType)
+  }
+
   override def inputTypes: Seq[AbstractDataType] = if (nullReplacement.isDefined) {
-    Seq(ArrayType(StringType), StringType, StringType)
+    Seq(ArrayType(commonType), commonType, commonType)
   } else {
-    Seq(ArrayType(StringType), StringType)
+    Seq(ArrayType(commonType), commonType)
   }

Review Comment:
   This seems a bit too much hustle to get expected input types. I would say these have to not depend on the parameters. Why not use StringTypeAnyCollation?



-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-47541][SQL] Collated strings in complex types supporting operations reverse, array_join, concat, map [spark]

Posted by "dbatomic (via GitHub)" <gi...@apache.org>.
dbatomic commented on code in PR #45693:
URL: https://github.com/apache/spark/pull/45693#discussion_r1539021429


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/util/ArrayBasedMapBuilder.scala:
##########
@@ -36,7 +36,9 @@ class ArrayBasedMapBuilder(keyType: DataType, valueType: DataType) extends Seria
   private lazy val keyToIndex = keyType match {
     // Binary type data is `byte[]`, which can't use `==` to check equality.
     case _: AtomicType | _: CalendarIntervalType | _: NullType
-      if !keyType.isInstanceOf[BinaryType] => new java.util.HashMap[Any, Int]()
+      if !keyType.isInstanceOf[BinaryType] && (!keyType.isInstanceOf[StringType] ||

Review Comment:
   Let's wait for Collation Refactory PR for this. This should be stringType.isBinaryComparable?
   
   Also, can you push `StringType` in a separate `case`. Relying on order evaluation of || is not a good thing (I don't know if scala standard enforces this). E.g. you can end up with `keyType.asInstanceOf[StringType].isBinaryCollation` evaluating first which will throw if this is not a `StringType`.
   



-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-47541][SQL] Collated strings in complex types supporting operations reverse, array_join, concat, map [spark]

Posted by "cloud-fan (via GitHub)" <gi...@apache.org>.
cloud-fan closed pull request #45693: [SPARK-47541][SQL] Collated strings in complex types supporting operations reverse, array_join, concat, map
URL: https://github.com/apache/spark/pull/45693


-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-47541][SQL] Collated strings in complex types supporting operations reverse, array_join, concat, map [spark]

Posted by "dongjoon-hyun (via GitHub)" <gi...@apache.org>.
dongjoon-hyun commented on PR #45693:
URL: https://github.com/apache/spark/pull/45693#issuecomment-2050117231

   Since there are many `Collated`-feature patch, I made a following PR to catch this kind of failure more eagerly.
   - https://github.com/apache/spark/pull/46010
   
   Anyway, thank you all for working on this feature.


-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-47541][SQL] Collated strings in complex types supporting operations reverse, array_join, concat, map [spark]

Posted by "mihailom-db (via GitHub)" <gi...@apache.org>.
mihailom-db commented on code in PR #45693:
URL: https://github.com/apache/spark/pull/45693#discussion_r1537435955


##########
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:
   This looks better, but I am still concerned that we are setting inputTypes according to inputs that we get. If I understand the logic correctly, it should be independent. I would rather leave this as ArrayType only and then override checkInputTypes to do this check you performed.



-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-47541][SQL] Collated strings in complex types supporting operations reverse, array_join, concat, map [spark]

Posted by "mihailom-db (via GitHub)" <gi...@apache.org>.
mihailom-db commented on PR #45693:
URL: https://github.com/apache/spark/pull/45693#issuecomment-2050384840

   I have a fix for this, will create a followup soon.


-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-47541][SQL] Collated strings in complex types supporting operations reverse, array_join, concat, map [spark]

Posted by "nikolamand-db (via GitHub)" <gi...@apache.org>.
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-47541][SQL] Collated strings in complex types supporting operations reverse, array_join, concat, map [spark]

Posted by "mihailom-db (via GitHub)" <gi...@apache.org>.
mihailom-db commented on code in PR #45693:
URL: https://github.com/apache/spark/pull/45693#discussion_r1537264451


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/collectionOperations.scala:
##########
@@ -1994,17 +1995,26 @@ 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 with ExpectsInputTypes {

Review Comment:
   You extend both Parent class and its Child. Remove ExpectsInputTypes.



-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-47541][SQL] Collated strings in complex types supporting operations reverse, array_join, concat, map [spark]

Posted by "mihailom-db (via GitHub)" <gi...@apache.org>.
mihailom-db commented on code in PR #45693:
URL: https://github.com/apache/spark/pull/45693#discussion_r1548527496


##########
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:
   ArrayJoin should be fine with only ArrayType. This is because TypeCoercion rules in FunctionArgumentConversion cast this argument to ArrayType(StringType) and catalyst rules will loop over this and cast it to proper collation if necessary. 



-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-47541][SQL] Collated strings in complex types supporting operations reverse, array_join, concat, map [spark]

Posted by "cloud-fan (via GitHub)" <gi...@apache.org>.
cloud-fan commented on code in PR #45693:
URL: https://github.com/apache/spark/pull/45693#discussion_r1551342610


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/collectionOperations.scala:
##########
@@ -2002,9 +2003,9 @@ case class ArrayJoin(
     this(array, delimiter, Some(nullReplacement))
 
   override def inputTypes: Seq[AbstractDataType] = if (nullReplacement.isDefined) {
-    Seq(ArrayType(StringType), StringType, StringType)
+    Seq(ArrayType, StringTypeAnyCollation, StringTypeAnyCollation)

Review Comment:
   what if the input is array of int? Before it will fail with type check, but now it seems different.



-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-47541][SQL] Collated strings in complex types supporting operations reverse, array_join, concat, map [spark]

Posted by "cloud-fan (via GitHub)" <gi...@apache.org>.
cloud-fan commented on code in PR #45693:
URL: https://github.com/apache/spark/pull/45693#discussion_r1551344347


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/collectionOperations.scala:
##########
@@ -2002,9 +2003,9 @@ case class ArrayJoin(
     this(array, delimiter, Some(nullReplacement))
 
   override def inputTypes: Seq[AbstractDataType] = if (nullReplacement.isDefined) {
-    Seq(ArrayType(StringType), StringType, StringType)
+    Seq(ArrayType, StringTypeAnyCollation, StringTypeAnyCollation)

Review Comment:
   We probably need to override `checkInputDataTypes` to check the array element.



-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-47541][SQL] Collated strings in complex types supporting operations reverse, array_join, concat, map [spark]

Posted by "cloud-fan (via GitHub)" <gi...@apache.org>.
cloud-fan commented on PR #45693:
URL: https://github.com/apache/spark/pull/45693#issuecomment-2041779179

   thanks, merging to master!


-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-47541][SQL] Collated strings in complex types supporting operations reverse, array_join, concat, map [spark]

Posted by "nikolamand-db (via GitHub)" <gi...@apache.org>.
nikolamand-db commented on code in PR #45693:
URL: https://github.com/apache/spark/pull/45693#discussion_r1551651242


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/collectionOperations.scala:
##########
@@ -2002,9 +2003,9 @@ case class ArrayJoin(
     this(array, delimiter, Some(nullReplacement))
 
   override def inputTypes: Seq[AbstractDataType] = if (nullReplacement.isDefined) {
-    Seq(ArrayType(StringType), StringType, StringType)
+    Seq(ArrayType, StringTypeAnyCollation, StringTypeAnyCollation)

Review Comment:
   So if I'm not mistaken this behavior was allowed before and it still works as expected.



-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-47541][SQL] Collated strings in complex types supporting operations reverse, array_join, concat, map [spark]

Posted by "nikolamand-db (via GitHub)" <gi...@apache.org>.
nikolamand-db commented on code in PR #45693:
URL: https://github.com/apache/spark/pull/45693#discussion_r1551648804


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/collectionOperations.scala:
##########
@@ -2002,9 +2003,9 @@ case class ArrayJoin(
     this(array, delimiter, Some(nullReplacement))
 
   override def inputTypes: Seq[AbstractDataType] = if (nullReplacement.isDefined) {
-    Seq(ArrayType(StringType), StringType, StringType)
+    Seq(ArrayType, StringTypeAnyCollation, StringTypeAnyCollation)

Review Comment:
   @cloud-fan There's a special case in `FunctionArgumentConversion` which implicitly casts array parameter to array of strings https://github.com/apache/spark/pull/21620.



-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org