Skip to content

Commit cfe2526

Browse files
wForgetyaooqinn
authored andcommitted
[SPARK-47307][SQL][FOLLOWUP] Promote spark.sql.legacy.chunkBase64String.enabled from a legacy/internal config to a regular/public one
### What changes were proposed in this pull request? + Promote spark.sql.legacy.chunkBase64String.enabled from a legacy/internal config to a regular/public one. + Add test cases for unbase64 ### Why are the changes needed? Keep the same behavior as before. More details: apache#47303 (comment) ### Does this PR introduce _any_ user-facing change? yes, revert behavior change introduced in apache#47303 ### How was this patch tested? existing unit test ### Was this patch authored or co-authored using generative AI tooling? No Closes apache#47410 from wForget/SPARK-47307_followup. Lead-authored-by: wforget <[email protected]> Co-authored-by: Kent Yao <[email protected]> Signed-off-by: Kent Yao <[email protected]>
1 parent 16b32ed commit cfe2526

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
Project [static_invoke(Base64.encode(cast(g#0 as binary), false)) AS base64(CAST(g AS BINARY))#0]
1+
Project [static_invoke(Base64.encode(cast(g#0 as binary), true)) AS base64(CAST(g AS BINARY))#0]
22
+- LocalRelation <empty>, [id#0L, a#0, b#0, d#0, e#0, f#0, g#0]

sql/catalyst/src/main/scala/org/apache/spark/sql/internal/SQLConf.scala

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3525,14 +3525,13 @@ object SQLConf {
35253525
.booleanConf
35263526
.createWithDefault(false)
35273527

3528-
val CHUNK_BASE64_STRING_ENABLED = buildConf("spark.sql.legacy.chunkBase64String.enabled")
3529-
.internal()
3528+
val CHUNK_BASE64_STRING_ENABLED = buildConf("spark.sql.chunkBase64String.enabled")
35303529
.doc("Whether to truncate string generated by the `Base64` function. When true, base64" +
35313530
" strings generated by the base64 function are chunked into lines of at most 76" +
35323531
" characters. When false, the base64 strings are not chunked.")
35333532
.version("3.5.2")
35343533
.booleanConf
3535-
.createWithDefault(false)
3534+
.createWithDefault(true)
35363535

35373536
val ENABLE_DEFAULT_COLUMNS =
35383537
buildConf("spark.sql.defaultColumn.enabled")

sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/StringExpressionsSuite.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,10 @@ class StringExpressionsSuite extends SparkFunSuite with ExpressionEvalHelper {
520520
withSQLConf(SQLConf.CHUNK_BASE64_STRING_ENABLED.key -> "true") {
521521
checkEvaluation(Base64(Literal(longString.getBytes)), chunkEncoded)
522522
}
523+
524+
// check if unbase64 works well for chunked and non-chunked encoded strings
525+
checkEvaluation(StringDecode(UnBase64(Literal(encoded)), Literal("utf-8")), longString)
526+
checkEvaluation(StringDecode(UnBase64(Literal(chunkEncoded)), Literal("utf-8")), longString)
523527
}
524528

525529
test("initcap unit test") {

0 commit comments

Comments
 (0)