Github user chenghao-intel commented on a diff in the pull request:

    https://github.com/apache/spark/pull/7202#discussion_r33839886
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/types/AbstractDataType.scala 
---
    @@ -28,7 +28,45 @@ import org.apache.spark.util.Utils
      * A non-concrete data type, reserved for internal uses.
      */
     private[sql] abstract class AbstractDataType {
    +  /**
    +   * The default concrete type to use if we want to cast a null literal 
into this type.
    +   */
       private[sql] def defaultConcreteType: DataType
    +
    +  /**
    +   * Returns true if this data type is a parent of the `childCandidate`.
    +   */
    +  private[sql] def isParentOf(childCandidate: DataType): Boolean
    +}
    +
    +
    +/**
    + * A collection of types that can be used to specify type constraints. The 
sequence also specifies
    + * precedence: an earlier type takes precedence over a latter type.
    + *
    + * {{{
    + *   TypeCollection(StringType, BinaryType)
    + * }}}
    + *
    + * This means that we prefer StringType over BinaryType if it is possible 
to cast to StringType.
    + */
    +private[sql] class TypeCollection(private val types: Seq[DataType]) 
extends AbstractDataType {
    +  require(types.nonEmpty, s"TypeCollection ($types) cannot be empty")
    +
    +  private[sql] override def defaultConcreteType: DataType = types.head
    --- End diff --
    
    This is probably not always true for the `Expression`, the 
`defaultConcreteType` depends on what the data type of child expression in lots 
of case.
    e.g. `Length` expects both `StringType` and `BinaryType`, `Hex` etc.
    
    And we probably need to review those expressions override the function of 
`checkInputDataTypes()`.


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