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

    https://github.com/apache/spark/pull/20024#discussion_r159584656
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/Cast.scala
 ---
    @@ -597,7 +605,114 @@ case class Cast(child: Expression, dataType: 
DataType, timeZoneId: Option[String
         """
       }
     
    -  private[this] def castToStringCode(from: DataType, ctx: CodegenContext): 
CastFunction = {
    +  private[this] def writeElemToBufferCode(
    +      dataType: DataType,
    +      buffer: String,
    +      elemTerm: String,
    +      ctx: CodegenContext): String = dataType match {
    +    case BinaryType => s"$buffer.append(new String($elemTerm))"
    +    case StringType => s"$buffer.append(new String($elemTerm.getBytes()))"
    +    case DateType => s"""$buffer.append(
    +      
org.apache.spark.sql.catalyst.util.DateTimeUtils.dateToString($elemTerm))"""
    +    case TimestampType => s"""$buffer.append(
    +      
org.apache.spark.sql.catalyst.util.DateTimeUtils.timestampToString($elemTerm))"""
    +    case map: MapType => s"${codegenWriteMapToBuffer(map, buffer, 
ctx)}($elemTerm)"
    +    case ar: ArrayType => s"${codegenWriteArrayToBuffer(ar, buffer, 
ctx)}($elemTerm)"
    +    case st: StructType => s"${codegenWriteStructToBuffer(st, buffer, 
ctx)}($elemTerm)"
    --- End diff --
    
    ok, dropped.


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to