@@ -108,7 +108,7 @@ impl ScalarUDFImpl for EncodeFunc {
108
108
}
109
109
110
110
match arg_types[ 0 ] {
111
- DataType :: Utf8 | DataType :: Binary | DataType :: Null => {
111
+ DataType :: Utf8 | DataType :: Utf8View | DataType :: Binary | DataType :: Null => {
112
112
Ok ( vec ! [ DataType :: Utf8 ; 2 ] )
113
113
}
114
114
DataType :: LargeUtf8 | DataType :: LargeBinary => {
@@ -195,7 +195,7 @@ impl ScalarUDFImpl for DecodeFunc {
195
195
}
196
196
197
197
match arg_types[ 0 ] {
198
- DataType :: Utf8 | DataType :: Binary | DataType :: Null => {
198
+ DataType :: Utf8 | DataType :: Utf8View | DataType :: Binary | DataType :: Null => {
199
199
Ok ( vec ! [ DataType :: Binary , DataType :: Utf8 ] )
200
200
}
201
201
DataType :: LargeUtf8 | DataType :: LargeBinary => {
@@ -224,6 +224,7 @@ fn encode_process(value: &ColumnarValue, encoding: Encoding) -> Result<ColumnarV
224
224
ColumnarValue :: Array ( a) => match a. data_type ( ) {
225
225
DataType :: Utf8 => encoding. encode_utf8_array :: < i32 > ( a. as_ref ( ) ) ,
226
226
DataType :: LargeUtf8 => encoding. encode_utf8_array :: < i64 > ( a. as_ref ( ) ) ,
227
+ DataType :: Utf8View => encoding. encode_utf8_array :: < i32 > ( a. as_ref ( ) ) ,
227
228
DataType :: Binary => encoding. encode_binary_array :: < i32 > ( a. as_ref ( ) ) ,
228
229
DataType :: LargeBinary => encoding. encode_binary_array :: < i64 > ( a. as_ref ( ) ) ,
229
230
other => exec_err ! (
@@ -237,6 +238,9 @@ fn encode_process(value: &ColumnarValue, encoding: Encoding) -> Result<ColumnarV
237
238
}
238
239
ScalarValue :: LargeUtf8 ( a) => Ok ( encoding
239
240
. encode_large_scalar ( a. as_ref ( ) . map ( |s : & String | s. as_bytes ( ) ) ) ) ,
241
+ ScalarValue :: Utf8View ( a) => {
242
+ Ok ( encoding. encode_scalar ( a. as_ref ( ) . map ( |s : & String | s. as_bytes ( ) ) ) )
243
+ }
240
244
ScalarValue :: Binary ( a) => Ok (
241
245
encoding. encode_scalar ( a. as_ref ( ) . map ( |v : & Vec < u8 > | v. as_slice ( ) ) )
242
246
) ,
@@ -255,6 +259,7 @@ fn decode_process(value: &ColumnarValue, encoding: Encoding) -> Result<ColumnarV
255
259
ColumnarValue :: Array ( a) => match a. data_type ( ) {
256
260
DataType :: Utf8 => encoding. decode_utf8_array :: < i32 > ( a. as_ref ( ) ) ,
257
261
DataType :: LargeUtf8 => encoding. decode_utf8_array :: < i64 > ( a. as_ref ( ) ) ,
262
+ DataType :: Utf8View => encoding. decode_utf8_array :: < i32 > ( a. as_ref ( ) ) ,
258
263
DataType :: Binary => encoding. decode_binary_array :: < i32 > ( a. as_ref ( ) ) ,
259
264
DataType :: LargeBinary => encoding. decode_binary_array :: < i64 > ( a. as_ref ( ) ) ,
260
265
other => exec_err ! (
@@ -268,6 +273,9 @@ fn decode_process(value: &ColumnarValue, encoding: Encoding) -> Result<ColumnarV
268
273
}
269
274
ScalarValue :: LargeUtf8 ( a) => encoding
270
275
. decode_large_scalar ( a. as_ref ( ) . map ( |s : & String | s. as_bytes ( ) ) ) ,
276
+ ScalarValue :: Utf8View ( a) => {
277
+ encoding. decode_scalar ( a. as_ref ( ) . map ( |s : & String | s. as_bytes ( ) ) )
278
+ }
271
279
ScalarValue :: Binary ( a) => {
272
280
encoding. decode_scalar ( a. as_ref ( ) . map ( |v : & Vec < u8 > | v. as_slice ( ) ) )
273
281
}
@@ -512,7 +520,7 @@ impl FromStr for Encoding {
512
520
}
513
521
}
514
522
515
- /// Encodes the given data, accepts Binary, LargeBinary, Utf8 or LargeUtf8 and returns a [`ColumnarValue`].
523
+ /// Encodes the given data, accepts Binary, LargeBinary, Utf8, Utf8View or LargeUtf8 and returns a [`ColumnarValue`].
516
524
/// Second argument is the encoding to use.
517
525
/// Standard encodings are base64 and hex.
518
526
fn encode ( args : & [ ColumnarValue ] ) -> Result < ColumnarValue > {
@@ -524,7 +532,7 @@ fn encode(args: &[ColumnarValue]) -> Result<ColumnarValue> {
524
532
}
525
533
let encoding = match & args[ 1 ] {
526
534
ColumnarValue :: Scalar ( scalar) => match scalar {
527
- ScalarValue :: Utf8 ( Some ( method) ) | ScalarValue :: LargeUtf8 ( Some ( method) ) => {
535
+ ScalarValue :: Utf8 ( Some ( method) ) | ScalarValue :: Utf8View ( Some ( method ) ) | ScalarValue :: LargeUtf8 ( Some ( method) ) => {
528
536
method. parse :: < Encoding > ( )
529
537
}
530
538
_ => not_impl_err ! (
@@ -538,7 +546,7 @@ fn encode(args: &[ColumnarValue]) -> Result<ColumnarValue> {
538
546
encode_process ( & args[ 0 ] , encoding)
539
547
}
540
548
541
- /// Decodes the given data, accepts Binary, LargeBinary, Utf8 or LargeUtf8 and returns a [`ColumnarValue`].
549
+ /// Decodes the given data, accepts Binary, LargeBinary, Utf8, Utf8View or LargeUtf8 and returns a [`ColumnarValue`].
542
550
/// Second argument is the encoding to use.
543
551
/// Standard encodings are base64 and hex.
544
552
fn decode ( args : & [ ColumnarValue ] ) -> Result < ColumnarValue > {
@@ -550,7 +558,7 @@ fn decode(args: &[ColumnarValue]) -> Result<ColumnarValue> {
550
558
}
551
559
let encoding = match & args[ 1 ] {
552
560
ColumnarValue :: Scalar ( scalar) => match scalar {
553
- ScalarValue :: Utf8 ( Some ( method) ) | ScalarValue :: LargeUtf8 ( Some ( method) ) => {
561
+ ScalarValue :: Utf8 ( Some ( method) ) | ScalarValue :: Utf8View ( Some ( method ) ) | ScalarValue :: LargeUtf8 ( Some ( method) ) => {
554
562
method. parse :: < Encoding > ( )
555
563
}
556
564
_ => not_impl_err ! (
0 commit comments