-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-47307][SQL] Add a config to optionally chunk base64 strings #47303
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 18 commits
09d1499
1305879
54ea063
6f1ace9
dfca282
7226206
f685701
cc790c0
47922c8
0c8593f
0b947c8
64a7400
e1cd658
fc48cc3
d4504c4
7423512
9a4d785
127e5b8
b179d49
0848e01
55c1a1f
36ed6aa
fcb432d
101409f
5aedf3a
be2a46a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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)); | ||
|
||
| """ | ||
| } else { | ||
| s"""${ev.value} = UTF8String.fromBytes( | ||
| ${classOf[JBase64].getName}.getMimeEncoder(-1, new byte[0]).encode($child)); | ||
| """ | ||
| } | ||
| }) | ||
| } | ||
|
|
||
| override protected def withNewChildInternal(newChild: Expression): Base64 = copy(child = newChild) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.