Skip to content

Commit

Permalink
[SPARK-47911][SQL][FOLLOWUP] Rename UTF8 to UTF-8 in spark.sql.binary…
Browse files Browse the repository at this point in the history
…OutputStyle

### What changes were proposed in this pull request?

Make a follow-up for SPARK-47911 to rename UTF8 to UTF-8 of `spark.sql.binaryOutputStyle`, so that we could have a consistent name with `org.apache.spark.sql.catalyst.util.CharsetProvider.VALID_CHARSETS` and `java.nio.charset.StandardCharsets.UTF_8`

### Why are the changes needed?

reduce cognitive cost for users

### Does this PR introduce _any_ user-facing change?
no, unreleased feature

### How was this patch tested?
existing tests

### Was this patch authored or co-authored using generative AI tooling?
no

Closes apache#47322 from yaooqinn/SPARK-47911-FF.

Authored-by: Kent Yao <yao@apache.org>
Signed-off-by: Dongjoon Hyun <dhyun@apple.com>
  • Loading branch information
yaooqinn authored and dongjoon-hyun committed Jul 12, 2024
1 parent 8e4bbdf commit 115c6e4
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1522,12 +1522,12 @@ object SQLConf {
* Output as UTF-8 string.
* [83, 112, 97, 114, 107] -> "Spark"
*/
UTF8,
UTF8: Value = Value("UTF-8")
/**
* Output as comma separated byte array string.
* [83, 112, 97, 114, 107] -> [83, 112, 97, 114, 107]
*/
BASIC,
val BASIC,
/**
* Output as base64 encoded string.
* [83, 112, 97, 114, 107] -> U3Bhcmsg
Expand All @@ -1546,7 +1546,7 @@ object SQLConf {
}

val BINARY_OUTPUT_STYLE = buildConf("spark.sql.binaryOutputStyle")
.doc("The output style used display binary data. Valid values are 'UTF8', " +
.doc("The output style used display binary data. Valid values are 'UTF-8', " +
"'BASIC', 'BASE64', 'HEX', and 'HEX_DISCRETE'.")
.version("4.0.0")
.stringConf
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ object HiveResult extends SQLConfHelper {
def getBinaryFormatter: BinaryFormatter = {
if (conf.getConf(SQLConf.BINARY_OUTPUT_STYLE).isEmpty) {
// Keep the legacy behavior for compatibility.
conf.setConf(SQLConf.BINARY_OUTPUT_STYLE, Some("UTF8"))
conf.setConf(SQLConf.BINARY_OUTPUT_STYLE, Some("UTF-8"))
}
ToStringBase.getBinaryFormatter(_).toString
}
Expand Down
2 changes: 1 addition & 1 deletion sql/core/src/test/resources/sql-tests/inputs/binary.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
--SET spark.sql.binaryOutputStyle=UTF8
--SET spark.sql.binaryOutputStyle=UTF-8

SELECT X'';
SELECT X'4561736F6E2059616F20323031382D31312D31373A31333A33333A3333';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1067,7 +1067,7 @@ class DataFrameSuite extends QueryTest
)
assert(df.getRows(10, 20) === expectedAnswer)
}
withSQLConf(SQLConf.BINARY_OUTPUT_STYLE.key -> "UTF8") {
withSQLConf(SQLConf.BINARY_OUTPUT_STYLE.key -> "UTF-8") {
val expectedAnswer = Seq(
Seq("_1", "_2"),
Seq("12", "ABC."),
Expand Down

0 comments on commit 115c6e4

Please sign in to comment.