Uploaded image for project: 'Spark'
  1. Spark
  2. SPARK-19311

UDFs disregard UDT type hierarchy

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 2.1.0
    • 2.1.1, 2.2.0
    • SQL
    • None

    Description

      When you define UDTs based on hierarchical traits UDFs disregard the type hierarchy:

      E.g. I have 2 UDTs based on 2 hierarchical traits. I then define 2 UDFs: The first one returns the derived type, the second takes the base type. This results in an error, although i believe it should be feasible:

      (...)cannot resolve 'UDF(UDF(22))' due to data type mismatch: argument 1 requires exampleBaseType type, however, 'UDF(22)' is of exampleFirstSubType type.

      The reason is that DataType defines

      override private[sql] def acceptsType(dataType: DataType) =
      this.getClass == dataType.getClass

      However I believe it should be:

      override private[sql] def acceptsType(dataType: DataType) = dataType match {
      case other: UserDefinedType[_] =>
      this.getClass == other.getClass || this.userClass.isAssignableFrom(other.userClass)
      case _ => false
      }

      Attachments

        Activity

          People

            gmoehler Gregor Moehler
            gmoehler Gregor Moehler
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - 1h
                1h
                Remaining:
                Remaining Estimate - 1h
                1h
                Logged:
                Time Spent - Not Specified
                Not Specified