@@ -216,16 +216,11 @@ abstract class CodeGenerator[InType <: AnyRef, OutType <: AnyRef] extends Loggin
216216 val $primitiveTerm: ${termForType(dataType)} = $value
217217 """ .children
218218
219- // case expressions.Literal(value: UTF8String, dataType) =>
220- // q"""
221- // val $nullTerm = ${value == null}
222- // val $primitiveTerm: ${termForType(dataType)} = $value
223- // """.children
224-
225- case expressions.Literal (value : String , dataType) =>
219+ case expressions.Literal (value : UTF8String , dataType) =>
226220 q """
227221 val $nullTerm = ${value == null }
228- val $primitiveTerm: ${termForType(dataType)} = $value
222+ val $primitiveTerm: ${termForType(dataType)} =
223+ org.apache.spark.sql.types.UTF8String( ${value.toString})
229224 """ .children
230225
231226 case expressions.Literal (value : Int , dataType) =>
@@ -249,11 +244,11 @@ abstract class CodeGenerator[InType <: AnyRef, OutType <: AnyRef] extends Loggin
249244 if( $nullTerm)
250245 ${defaultPrimitive(StringType )}
251246 else
252- UTF8String( ${eval.primitiveTerm}.asInstanceOf[Array[Byte]])
247+ org.apache.spark.sql.types. UTF8String( ${eval.primitiveTerm}.asInstanceOf[Array[Byte]])
253248 """ .children
254249
255250 case Cast (child @ DateType (), StringType ) =>
256- child.castOrNull(c => q " org.apache.spark.sql.types.DateUtils.toString( $c) " , StringType )
251+ child.castOrNull(c => q " org.apache.spark.sql.types.UTF8String(org.apache.spark.sql.types. DateUtils.toString( $c) )" , StringType )
257252
258253 case Cast (child @ NumericType (), IntegerType ) =>
259254 child.castOrNull(c => q " $c.toInt " , IntegerType )
@@ -278,7 +273,7 @@ abstract class CodeGenerator[InType <: AnyRef, OutType <: AnyRef] extends Loggin
278273 if( $nullTerm)
279274 ${defaultPrimitive(StringType )}
280275 else
281- ${eval.primitiveTerm}.toString
276+ org.apache.spark.sql.types.UTF8String( ${eval.primitiveTerm}.toString)
282277 """ .children
283278
284279 case EqualTo (e1, e2) =>
@@ -579,7 +574,7 @@ abstract class CodeGenerator[InType <: AnyRef, OutType <: AnyRef] extends Loggin
579574 val localLogger = log
580575 val localLoggerTree = reify { localLogger }
581576 q """
582- $localLoggerTree.debug( ${e.toString} + ": " + (if( $nullTerm) "null" else $primitiveTerm))
577+ $localLoggerTree.debug( ${e.toString} + ": " + (if( $nullTerm) "null" else $primitiveTerm.toString ))
583578 """ :: Nil
584579 } else {
585580 Nil
@@ -590,7 +585,7 @@ abstract class CodeGenerator[InType <: AnyRef, OutType <: AnyRef] extends Loggin
590585
591586 protected def getColumn (inputRow : TermName , dataType : DataType , ordinal : Int ) = {
592587 dataType match {
593- case StringType => q " $inputRow.apply ( $ordinal).asInstanceOf[UTF8String] "
588+ case StringType => q " $inputRow( $ordinal).asInstanceOf[org.apache.spark.sql.types. UTF8String] "
594589 case dt @ NativeType () => q " $inputRow. ${accessorForType(dt)}( $ordinal) "
595590 case _ => q " $inputRow.apply( $ordinal).asInstanceOf[ ${termForType(dataType)}] "
596591 }
@@ -602,7 +597,7 @@ abstract class CodeGenerator[InType <: AnyRef, OutType <: AnyRef] extends Loggin
602597 ordinal : Int ,
603598 value : TermName ) = {
604599 dataType match {
605- case StringType => q " $destinationRow.setString ( $ordinal, $value) "
600+ case StringType => q " $destinationRow.update ( $ordinal, $value) "
606601 case dt @ NativeType () => q " $destinationRow. ${mutatorForType(dt)}( $ordinal, $value) "
607602 case _ => q " $destinationRow.update( $ordinal, $value) "
608603 }
@@ -626,13 +621,13 @@ abstract class CodeGenerator[InType <: AnyRef, OutType <: AnyRef] extends Loggin
626621 case DoubleType => " Double"
627622 case FloatType => " Float"
628623 case BooleanType => " Boolean"
629- case StringType => " String "
624+ case StringType => " org.apache.spark.sql.types.UTF8String "
630625 }
631626
632627 protected def defaultPrimitive (dt : DataType ) = dt match {
633628 case BooleanType => ru.Literal (Constant (false ))
634629 case FloatType => ru.Literal (Constant (- 1.0 .toFloat))
635- case StringType => ru. Literal ( Constant ( " <uninit>" ))
630+ case StringType => q """ org.apache.spark.sql.types.UTF8String( "<uninit>")"""
636631 case ShortType => ru.Literal (Constant (- 1 .toShort))
637632 case LongType => ru.Literal (Constant (- 1L ))
638633 case ByteType => ru.Literal (Constant (- 1 .toByte))
0 commit comments