Github user marmbrus commented on a diff in the pull request:
https://github.com/apache/spark/pull/2246#discussion_r17092279
--- Diff: sql/core/src/main/scala/org/apache/spark/sql/json/JsonRDD.scala
---
@@ -125,12 +125,16 @@ private[sql] object JsonRDD extends Logging {
* Returns the most general data type for two given data types.
*/
private[json] def compatibleType(t1: DataType, t2: DataType): DataType =
{
- // Try and find a promotion rule that contains both types in question.
- val applicableConversion = HiveTypeCoercion.allPromotions.find(p =>
p.contains(t1) && p
- .contains(t2))
+ val returnType = if (t1 == t2) {
+ Some(t1)
+ } else {
+ // Try and find a promotion rule that contains both types in
question.
+ val applicableConversion = HiveTypeCoercion.allPromotions.find(p =>
p.contains(t1) && p
+ .contains(t2))
- // If found return the widest common type, otherwise None
- val returnType = applicableConversion.map(_.filter(t => t == t1 || t
== t2).last)
+ // If found return the widest common type, otherwise None
+ applicableConversion.map(_.filter(t => t == t1 || t == t2).last)
--- End diff --
Well, yes after this the code is different, but up here this looks
identical. Could this just be `val returnType = findTightestCommonType(t1,
t2)`? (Sorry if I'm missing something obvious)
---
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 [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]