Skip to content

Commit

Permalink
[FLINK-15478][table-planner-blink] Fix FROM_BASE64 code generation ex…
Browse files Browse the repository at this point in the history
…ception because of the wrong result type (apache#10766)
  • Loading branch information
libenchao authored and wuchong committed Jan 7, 2020
1 parent 1121949 commit f0fe365
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,7 @@ object StringCallGen {
ctx: CodeGeneratorContext,
operands: Seq[GeneratedExpression]): GeneratedExpression = {
val className = classOf[SqlFunctionUtils].getCanonicalName
generateCallIfArgsNotNull(ctx, new VarBinaryType(VarBinaryType.MAX_LENGTH), operands) {
generateCallIfArgsNotNull(ctx, new VarCharType(VarCharType.MAX_LENGTH), operands) {
terms => s"$className.fromBase64(${terms.head})"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -893,6 +893,10 @@ class ScalarFunctionsTest extends ScalarTypesTestBase {
"FROM_BASE64('aGVsbG8gd29ybGQ=')",
"hello world")

testSqlApi(
"CONCAT(FROM_BASE64('5L2g5aW9'), ' flink')",
"你好 flink")

//null test
testSqlApi(
"FROM_BASE64(f33)",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1063,8 +1063,8 @@ public static String toBase64(byte[] bytes){
return Base64.getEncoder().encodeToString(bytes);
}

public static byte[] fromBase64(BinaryString bs){
return Base64.getDecoder().decode(bs.getBytes());
public static BinaryString fromBase64(BinaryString bs) {
return BinaryString.fromBytes(Base64.getDecoder().decode(bs.getBytes()));
}

public static String uuid(){
Expand Down

0 comments on commit f0fe365

Please sign in to comment.