wForget commented on code in PR #47303: URL: https://github.com/apache/spark/pull/47303#discussion_r1675338494
########## sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/stringExpressions.scala: ########## @@ -2685,18 +2685,32 @@ case class Chr(child: Expression) case class Base64(child: Expression) extends UnaryExpression with ImplicitCastInputTypes with NullIntolerant { + lazy val chunkBase64: Boolean = SQLConf.get.chunkBase64StringEnabled + lazy val encoder: JBase64.Encoder = if (chunkBase64) { + JBase64.getMimeEncoder + } else { + JBase64.getMimeEncoder(-1, Array()) + } + override def dataType: DataType = SQLConf.get.defaultStringType override def inputTypes: Seq[DataType] = Seq(BinaryType) protected override def nullSafeEval(bytes: Any): Any = { - UTF8String.fromBytes(JBase64.getMimeEncoder.encode(bytes.asInstanceOf[Array[Byte]])) + UTF8String.fromBytes(encoder.encode(bytes.asInstanceOf[Array[Byte]])) } override def doGenCode(ctx: CodegenContext, ev: ExprCode): ExprCode = { nullSafeCodeGen(ctx, ev, (child) => { - s"""${ev.value} = UTF8String.fromBytes( - ${classOf[JBase64].getName}.getMimeEncoder().encode($child)); - """}) + if (chunkBase64) { + s"""${ev.value} = UTF8String.fromBytes( + ${classOf[JBase64].getName}.getMimeEncoder().encode($child)); Review Comment: > maybe we can follow the work I have done for `Encode` to make it RuntimeReplaceable with StaticInvoke Thanks, I will try it -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org