Skip to content

Commit

Permalink
[CH] Support function base64/unbase64 (#6077)
Browse files Browse the repository at this point in the history
[CH] Support function base64/unbase64

Co-authored-by: liuneng1994 <[email protected]>
  • Loading branch information
liuneng1994 and liuneng1994 authored Jun 17, 2024
1 parent fc04a63 commit 150ccb9
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,44 @@ class GlutenClickhouseStringFunctionsSuite extends GlutenClickHouseWholeStageTra
}
}

test("base64") {
val tableName = "base64_table"
withTable(tableName) {
sql(s"create table $tableName(data String) using parquet")
sql(s"""
|insert into $tableName values
| ("hello")
""".stripMargin)

val sql_str =
s"""
|select
| base64(data)
| from $tableName
""".stripMargin

runQueryAndCompare(sql_str) { _ => }
}
}

test("unbase64") {
val tableName = "unbase64_table"
withTable(tableName) {
sql(s"create table $tableName(data String) using parquet")
sql(s"""
|insert into $tableName values
| ("U3BhcmsgU1FM")
""".stripMargin)

val sql_str =
s"""
|select
| unbase64(data)
| from $tableName
""".stripMargin

runQueryAndCompare(sql_str) { _ => }
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ object ExpressionMappings {
Sig[Encode](ENCODE),
Sig[Uuid](UUID),
Sig[BitLength](BIT_LENGTH),
Sig[UnBase64](UNBASE64),
Sig[Base64](BASE64),

// URL functions
Sig[ParseUrl](PARSE_URL),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ object ExpressionNames {
final val ENCODE = "encode"
final val UUID = "uuid"
final val BIT_LENGTH = "bit_length"
final val UNBASE64 = "unbase64"
final val BASE64 = "base64"

// URL functions
final val PARSE_URL = "parse_url"
Expand Down

0 comments on commit 150ccb9

Please sign in to comment.