You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "mihailom-db (via GitHub)" <gi...@apache.org> on 2024/04/05 07:11:35 UTC
[PR] Add support for AbstractArrayType(StringTypeCollated) [spark]
mihailom-db opened a new pull request, #45891:
URL: https://github.com/apache/spark/pull/45891
### What changes were proposed in this pull request?
Addition of abstract arraytype which accepts StringTypeCollated as elementType.
### Why are the changes needed?
This is needed in order to enable functions to use collated arrays.
### Does this PR introduce _any_ user-facing change?
Yes, collation functions will work.
### How was this patch tested?
Test for array_join will be added.
### Was this patch authored or co-authored using generative AI tooling?
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-47736][SQL] Add support for AbstractArrayType [spark]
Posted by "mihailom-db (via GitHub)" <gi...@apache.org>.
mihailom-db commented on code in PR #45891:
URL: https://github.com/apache/spark/pull/45891#discussion_r1556979888
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/StringTypeCollated.scala:
##########
@@ -52,3 +52,20 @@ case object StringTypeAnyCollation extends StringTypeCollated {
override private[sql] def simpleString: String = "string_any_collation"
override private[sql] def acceptsType(other: DataType): Boolean = other.isInstanceOf[StringType]
}
+
+/**
+ * Use ArrayType(StringTypeCollated) for expressions supporting different type of
+ * collations in ArrayTypes
+ */
+case class AbstractArrayType(elementType: StringTypeCollated) extends AbstractDataType {
Review Comment:
Done, I also realised, should I move the StringTypeCollated to the right package? It is now in catalyst.expressions instead of types as all other types.
--
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-47736][SQL] Add support for AbstractArrayType [spark]
Posted by "mihailom-db (via GitHub)" <gi...@apache.org>.
mihailom-db commented on PR #45891:
URL: https://github.com/apache/spark/pull/45891#issuecomment-2045750423
@cloud-fan Did some refactoring with some renaming, so I re-requested approve
--
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-47736][SQL] Add support for AbstractArrayType [spark]
Posted by "cloud-fan (via GitHub)" <gi...@apache.org>.
cloud-fan commented on code in PR #45891:
URL: https://github.com/apache/spark/pull/45891#discussion_r1557312729
##########
sql/api/src/main/scala/org/apache/spark/sql/types/ArrayType.scala:
##########
@@ -43,6 +43,23 @@ object ArrayType extends AbstractDataType {
override private[spark] def simpleString: String = "array"
}
+/**
+ * Use AbstractArrayType(AbstractDataType) for defining expected types for expression parameters.
+ */
+@Stable
Review Comment:
This is used by expressions to define expected types, so shouldn't be exposed to end-users. It's more like a developer API.
Can we have a new package `org.apache.spark.sql.internal.types` to put this class (with a new file) and also the string collation related classes?
--
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-47736][SQL] Add support for AbstractArrayType [spark]
Posted by "cloud-fan (via GitHub)" <gi...@apache.org>.
cloud-fan commented on PR #45891:
URL: https://github.com/apache/spark/pull/45891#issuecomment-2049111906
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-47736][SQL] Add support for AbstractArrayType [spark]
Posted by "mihailom-db (via GitHub)" <gi...@apache.org>.
mihailom-db commented on code in PR #45891:
URL: https://github.com/apache/spark/pull/45891#discussion_r1560747241
##########
sql/api/src/main/scala/org/apache/spark/sql/internal/types/AbstractStringType.scala:
##########
@@ -15,30 +15,30 @@
* limitations under the License.
*/
-package org.apache.spark.sql.catalyst.expressions
+package org.apache.spark.sql.internal.types
import org.apache.spark.sql.types.{AbstractDataType, DataType, StringType}
/**
* StringTypeCollated is an abstract class for StringType with collation support.
Review Comment:
Noted, will include the change with some of the next PRs.
--
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-47736][SQL] Add support for AbstractArrayType [spark]
Posted by "stefankandic (via GitHub)" <gi...@apache.org>.
stefankandic commented on code in PR #45891:
URL: https://github.com/apache/spark/pull/45891#discussion_r1560698270
##########
sql/api/src/main/scala/org/apache/spark/sql/internal/types/AbstractStringType.scala:
##########
@@ -15,30 +15,30 @@
* limitations under the License.
*/
-package org.apache.spark.sql.catalyst.expressions
+package org.apache.spark.sql.internal.types
import org.apache.spark.sql.types.{AbstractDataType, DataType, StringType}
/**
* StringTypeCollated is an abstract class for StringType with collation support.
Review Comment:
missed a docstring update here
--
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-47736][SQL] Add support for AbstractArrayType [spark]
Posted by "cloud-fan (via GitHub)" <gi...@apache.org>.
cloud-fan commented on code in PR #45891:
URL: https://github.com/apache/spark/pull/45891#discussion_r1557313843
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/TypeCoercion.scala:
##########
@@ -1017,6 +1017,9 @@ object TypeCoercion extends TypeCoercionBase {
case (ArrayType(fromType, fn), ArrayType(toType: DataType, true)) =>
implicitCast(fromType, toType).map(ArrayType(_, true)).orNull
+ case (ArrayType(fromType, fn), AbstractArrayType(toType: StringTypeCollated)) =>
Review Comment:
```suggestion
case (ArrayType(fromType, fn), AbstractArrayType(toType)) =>
```
--
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] Add support for AbstractArrayType(StringTypeCollated) [spark]
Posted by "cloud-fan (via GitHub)" <gi...@apache.org>.
cloud-fan commented on code in PR #45891:
URL: https://github.com/apache/spark/pull/45891#discussion_r1556851091
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/StringTypeCollated.scala:
##########
@@ -52,3 +52,20 @@ case object StringTypeAnyCollation extends StringTypeCollated {
override private[sql] def simpleString: String = "string_any_collation"
override private[sql] def acceptsType(other: DataType): Boolean = other.isInstanceOf[StringType]
}
+
+/**
+ * Use ArrayType(StringTypeCollated) for expressions supporting different type of
+ * collations in ArrayTypes
+ */
+case class AbstractArrayType(elementType: StringTypeCollated) extends AbstractDataType {
Review Comment:
can we make it general to take `AbstractDataType`? I don't think we should limit it to string 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-47736][SQL] Add support for AbstractArrayType [spark]
Posted by "cloud-fan (via GitHub)" <gi...@apache.org>.
cloud-fan commented on code in PR #45891:
URL: https://github.com/apache/spark/pull/45891#discussion_r1558907777
##########
sql/api/src/main/scala/org/apache/spark/sql/internal/types/AbstractArrayType.scala:
##########
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.spark.sql.internal.types
+
+import org.apache.spark.annotation.Stable
+import org.apache.spark.sql.types.{AbstractDataType, ArrayType, DataType}
+
+
+/**
+ * Use AbstractArrayType(AbstractDataType) for defining expected types for expression parameters.
+ */
+@Stable
Review Comment:
```suggestion
```
--
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-47736][SQL] Add support for AbstractArrayType [spark]
Posted by "cloud-fan (via GitHub)" <gi...@apache.org>.
cloud-fan commented on code in PR #45891:
URL: https://github.com/apache/spark/pull/45891#discussion_r1558908333
##########
sql/api/src/main/scala/org/apache/spark/sql/types/ArrayType.scala:
##########
@@ -43,6 +43,23 @@ object ArrayType extends AbstractDataType {
override private[spark] def simpleString: String = "array"
}
+/**
+ * Use AbstractArrayType(AbstractDataType) for defining expected types for expression parameters.
+ */
+@Stable
+case class AbstractArrayType(elementType: AbstractDataType) extends AbstractDataType {
Review Comment:
we can remove this now
--
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-47736][SQL] Add support for AbstractArrayType [spark]
Posted by "cloud-fan (via GitHub)" <gi...@apache.org>.
cloud-fan commented on code in PR #45891:
URL: https://github.com/apache/spark/pull/45891#discussion_r1557314805
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/TypeCoercion.scala:
##########
@@ -1017,6 +1017,9 @@ object TypeCoercion extends TypeCoercionBase {
case (ArrayType(fromType, fn), ArrayType(toType: DataType, true)) =>
implicitCast(fromType, toType).map(ArrayType(_, true)).orNull
+ case (ArrayType(fromType, fn), AbstractArrayType(toType: StringTypeCollated)) =>
Review Comment:
No expression uses `AbstractArrayType` with non string type now, but it's pretty easy to make it future-proof so let's do it.
--
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] Add support for AbstractArrayType(StringTypeCollated) [spark]
Posted by "mihailom-db (via GitHub)" <gi...@apache.org>.
mihailom-db commented on PR #45891:
URL: https://github.com/apache/spark/pull/45891#issuecomment-2042405846
@cloud-fan Do you think adding AbstractArrayType could be a good idea as a general and not only for StringTypeCollated? Otherwise this PR should be ready for review.
--
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-47736][SQL] Add support for AbstractArrayType [spark]
Posted by "cloud-fan (via GitHub)" <gi...@apache.org>.
cloud-fan closed pull request #45891: [SPARK-47736][SQL] Add support for AbstractArrayType
URL: https://github.com/apache/spark/pull/45891
--
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