Github user marmbrus commented on a diff in the pull request:

    https://github.com/apache/spark/pull/3110#discussion_r20123850
  
    --- Diff: 
sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveMetastoreCatalog.scala ---
    @@ -313,6 +319,48 @@ private[hive] class HiveMetastoreCatalog(hive: 
HiveContext) extends Catalog with
     }
     
     /**
    + * A logical plan representing insertion into Hive table.
    + * This plan ignores nullability of ArrayType, MapType, StructType unlike 
InsertIntoTable
    + * because Hive table doesn't have nullability for ARRAY, MAP, STRUCT 
types.
    + */
    +private[hive] case class InsertIntoHiveTable(
    +    table: LogicalPlan,
    +    partition: Map[String, Option[String]],
    +    child: LogicalPlan,
    +    overwrite: Boolean)
    +  extends LogicalPlan {
    +
    +  override def children = child :: Nil
    +  override def output = child.output
    +
    +  override lazy val resolved = childrenResolved && 
child.output.zip(table.output).forall {
    +    case (childAttr, tableAttr) =>
    +      InsertIntoHiveType.equalsIgnoreNullability(childAttr.dataType, 
tableAttr.dataType)
    +  }
    +}
    +
    +private[hive] object InsertIntoHiveType {
    +
    +  /**
    +   * Compares two types, ignoring nullability of ArrayType, MapType, 
StructType.
    +   */
    +  def equalsIgnoreNullability(dataTypePair: (DataType, DataType)): Boolean 
= {
    --- End diff --
    
    I like this approach of having a separate equals function (In my experience 
overriding the standard `equals` to do loose equality is a recipe for 
disaster).  What do you think about moving this function into `DataType` 
though?  seems like it could be generally useful.


---
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]

Reply via email to