[GitHub] spark pull request #17614: [SPARK-20302][SQL] Short circuit cast when from a...
Github user asfgit closed the pull request at: https://github.com/apache/spark/pull/17614 --- 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
[GitHub] spark pull request #17614: [SPARK-20302][SQL] Short circuit cast when from a...
Github user rxin commented on a diff in the pull request: https://github.com/apache/spark/pull/17614#discussion_r111064001 --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/types/DataType.scala --- @@ -288,4 +288,30 @@ object DataType { case (fromDataType, toDataType) => fromDataType == toDataType } } + + /** + * Returns true if the two data types share the same "shape", i.e. the types (including + * nullability) are the same, but the field names don't need to be the same. + */ + def equalsStructurally(from: DataType, to: DataType): Boolean = { +(from, to) match { + case (left: ArrayType, right: ArrayType) => +equalsStructurally(left.elementType, right.elementType) && + left.containsNull == right.containsNull --- End diff -- That's not symmetric. equalsStructurally should be symmetric, unless we rename this something else (e.g. structurallyCastable) --- 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
[GitHub] spark pull request #17614: [SPARK-20302][SQL] Short circuit cast when from a...
Github user cloud-fan commented on a diff in the pull request: https://github.com/apache/spark/pull/17614#discussion_r111063773 --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/types/DataType.scala --- @@ -288,4 +288,30 @@ object DataType { case (fromDataType, toDataType) => fromDataType == toDataType } } + + /** + * Returns true if the two data types share the same "shape", i.e. the types (including + * nullability) are the same, but the field names don't need to be the same. + */ + def equalsStructurally(from: DataType, to: DataType): Boolean = { +(from, to) match { + case (left: ArrayType, right: ArrayType) => +equalsStructurally(left.elementType, right.elementType) && + left.containsNull == right.containsNull --- End diff -- shall we be more flexible here? i.e. `!left.containsNull || right.containsNull` --- 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