@@ -23,8 +23,9 @@ CREATE TABLE test(
23
23
hex_field TEXT
24
24
) as VALUES
25
25
(0, 'abc', encode('abc', 'base64'), encode('abc', 'hex')),
26
- (1, 'qweqwe', encode('qweqwe', 'base64'), encode('qweqwe', 'hex')),
27
- (2, NULL, NULL, NULL)
26
+ (1, 'qweqwe', encode('qweqwe', 'base64'), encode('qweqwe', 'hex')),
27
+ (2, NULL, NULL, NULL),
28
+ (3, X'8f50d3f60eae370ddbf85c86219c55108a350165', encode('8f50d3f60eae370ddbf85c86219c55108a350165', 'base64'), encode('8f50d3f60eae370ddbf85c86219c55108a350165', 'hex'))
28
29
;
29
30
30
31
# errors
@@ -43,34 +44,51 @@ select decode(hex_field, 'non_encoding') from test;
43
44
query error
44
45
select to_hex(hex_field) from test;
45
46
47
+ query error
48
+ select arrow_cast(decode(X'8f50d3f60eae370ddbf85c86219c55108a350165', 'base64'), 'Utf8');
49
+
46
50
# Arrays tests
47
51
query T
48
52
SELECT encode(bin_field, 'hex') FROM test ORDER BY num;
49
53
----
50
54
616263
51
55
717765717765
52
56
NULL
57
+ 8f50d3f60eae370ddbf85c86219c55108a350165
53
58
54
59
query T
55
60
SELECT arrow_cast(decode(base64_field, 'base64'), 'Utf8') FROM test ORDER BY num;
56
61
----
57
62
abc
58
63
qweqwe
59
64
NULL
65
+ 8f50d3f60eae370ddbf85c86219c55108a350165
60
66
61
67
query T
62
68
SELECT arrow_cast(decode(hex_field, 'hex'), 'Utf8') FROM test ORDER BY num;
63
69
----
64
70
abc
65
71
qweqwe
66
72
NULL
73
+ 8f50d3f60eae370ddbf85c86219c55108a350165
67
74
68
75
query T
69
76
select to_hex(num) from test ORDER BY num;
70
77
----
71
78
0
72
79
1
73
80
2
81
+ 3
82
+
83
+ query T
84
+ select encode(bin_field, 'base64') FROM test WHERE num = 3;
85
+ ----
86
+ j1DT9g6uNw3b+FyGIZxVEIo1AWU
87
+
88
+ query B
89
+ select decode(encode(bin_field, 'base64'), 'base64') = X'8f50d3f60eae370ddbf85c86219c55108a350165' FROM test WHERE num = 3;
90
+ ----
91
+ true
74
92
75
93
# test for Utf8View support for encode
76
94
statement ok
@@ -102,3 +120,9 @@ Andrew QW5kcmV3 416e64726577 X WA 58
102
120
Xiangpeng WGlhbmdwZW5n 5869616e6770656e67 Xiangpeng WGlhbmdwZW5n 5869616e6770656e67
103
121
Raphael UmFwaGFlbA 5261706861656c R Ug 52
104
122
NULL NULL NULL R Ug 52
123
+
124
+ # test for hex digest
125
+ query T
126
+ select encode(digest('hello', 'sha256'), 'hex');
127
+ ----
128
+ 2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824
0 commit comments