def buildSerializer()

in spark/common/src/main/scala/org/apache/spark/sql/sedona_sql/expressions/InferredExpression.scala [234:295]


  def buildSerializer(t: Type): Any => Any = {
    if (t =:= typeOf[Geometry]) { output =>
      if (output != null) {
        output.asInstanceOf[Geometry].toGenericArrayData
      } else {
        null
      }
    } else if (t =:= typeOf[Geography]) { output =>
      if (output != null) {
        output.asInstanceOf[Geography].toGenericArrayData
      } else {
        null
      }
    } else if (InferredRasterExpression.isRasterType(t)) {
      InferredRasterExpression.rasterSerializer
    } else if (t =:= typeOf[String]) { output =>
      if (output != null) {
        UTF8String.fromString(output.asInstanceOf[String])
      } else {
        null
      }
    } else if (t =:= typeOf[Array[java.lang.Long]] || t =:= typeOf[Array[Long]] ||
      t =:= typeOf[Array[Double]]) { output =>
      if (output != null) {
        ArrayData.toArrayData(output)
      } else {
        null
      }
    } else if (t =:= typeOf[java.util.List[java.lang.Double]]) { output =>
      if (output != null) {
        ArrayData.toArrayData(
          output.asInstanceOf[java.util.List[java.lang.Double]].map(elem => elem))
      } else {
        null
      }
    } else if (t =:= typeOf[Array[Geometry]] || t =:= typeOf[java.util.List[Geometry]]) {
      output =>
        if (output != null) {
          ArrayData.toArrayData(output.asInstanceOf[Array[Geometry]].map(_.toGenericArrayData))
        } else {
          null
        }
    } else if (t =:= typeOf[Array[Geography]] || t =:= typeOf[java.util.List[Geography]]) {
      output =>
        if (output != null) {
          ArrayData.toArrayData(output.asInstanceOf[Array[Geography]].map(_.toGenericArrayData))
        } else {
          null
        }

    } else if (InferredRasterExpression.isRasterArrayType(t)) {
      InferredRasterExpression.rasterArraySerializer
    } else if (t =:= typeOf[Option[Boolean]]) { output =>
      if (output != null) {
        output.asInstanceOf[Option[Boolean]].orNull
      } else {
        null
      }
    } else { output =>
      output
    }
  }