Fokko commented on a change in pull request #26644: [SPARK-30004][SQL] Allow merge UserDefinedType into a native DataType URL: https://github.com/apache/spark/pull/26644#discussion_r350674098
########## File path: sql/catalyst/src/main/scala/org/apache/spark/sql/types/StructType.scala ########## @@ -453,7 +453,23 @@ case class StructType(fields: Array[StructField]) extends DataType with Seq[Stru * 3. If B doesn't exist in `this`, it's also included in the result schema. * 4. Otherwise, `this` and `that` are considered as conflicting schemas and an exception would be * thrown. + * + * Function to merge the two DataTypes that is compatible with the left + * and right side. The order is: + * + * 1. Merge Arrays, where the type of the Arrays should be compatible + * 2. Merge Maps, where the type of the Maps should be compatible + * 3. Merge Structs, where the struct recursively checked for compatibility + * 4. Merge DecimalType, where the scale and precision should be equal + * 5. Merge UserDefinedType, where the underlying class is equal + * 6. Merge UserDefinedType into DataType, where the underlying DataType is equal + * 7. Merge DataType, where we check if the DataTypes are compatible + * 8. Unable to determine compatibility or incompatible, throw exception + * + * @throws org.apache.spark.SparkException In case the DataTypes are incompatible + * @return The compatible DataType that support both left and right */ + @throws(classOf[SparkException]) Review comment: If the schema isn't compatible, it will throw a SparkException. I like these functions to be annotated. If you don't like it, I'm happy to remove 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org