IMPALA-2107: Add Base64 encoder/decoder

Change-Id: I911451c5d68e8ae9d352abfcf4d5ff36484f0bf3
Reviewed-on: http://gerrit.cloudera.org:8080/2633
Reviewed-by: Dan Hecht <dhecht@cloudera.com>
Tested-by: Internal Jenkins
This commit is contained in:
Jim Apple
2016-03-25 14:45:03 -07:00
committed by Tim Armstrong
parent f5e8047886
commit 1c16dd0cf8
5 changed files with 158 additions and 0 deletions

View File

@@ -2415,3 +2415,42 @@ NULL
---- TYPES
timestamp
====
---- QUERY
# base64 encoding/decoding
select count(*) from functional.alltypes
where length(string_col) > 0 &&
length(base64encode(string_col)) <= length(string_col)
---- RESULTS
0
---- TYPES
BIGINT
====
---- QUERY
# base64 encoding/decoding
select count (*) from functional.alltypes
where base64decode(base64encode(string_col)) IS DISTINCT FROM string_col
---- RESULTS
0
---- TYPES
BIGINT
====
---- QUERY
# base64 decoding a string of invalid length (must be divisible by 4)
select base64decode('foo')
---- RESULTS
'NULL'
---- TYPES
STRING
---- ERRORS
UDF WARNING: Invalid base64 string; input length is 3, which is not a multiple of 4.
====
---- QUERY
# base64 decoding a string with invalid characters
select base64decode('abc%')
---- RESULTS
'NULL'
---- TYPES
STRING
---- ERRORS
UDF WARNING: Could not base64 decode input in space 4; actual output length 0
====