1616// under the License.
1717
1818use std:: { any:: Any , sync:: Arc } ;
19-
20- use arrow :: {
21- array :: { ArrayRef , GenericStringBuilder } ,
22- datatypes :: {
23- DataType ,
24- DataType :: { Int64 , Utf8 } ,
25- } ,
26- } ;
19+ extern crate arrow ;
20+ extern crate datafusion_common ;
21+ extern crate datafusion_expr ;
22+ use arrow :: array :: ArrayRef ;
23+ use arrow :: array :: GenericStringBuilder ;
24+ use arrow :: datatypes :: DataType ;
25+ use arrow :: datatypes :: DataType :: Int64 ;
26+ use arrow :: datatypes :: DataType :: Utf8 ;
2727
2828use datafusion_common:: { cast:: as_int64_array, exec_err, Result , ScalarValue } ;
2929use datafusion_expr:: {
@@ -33,25 +33,25 @@ use datafusion_expr::{
3333/// Spark-compatible `char` expression
3434/// <https://spark.apache.org/docs/latest/api/sql/index.html#char>
3535#[ derive( Debug ) ]
36- pub struct SparkChar {
36+ pub struct CharFunc {
3737 signature : Signature ,
3838}
3939
40- impl Default for SparkChar {
40+ impl Default for CharFunc {
4141 fn default ( ) -> Self {
4242 Self :: new ( )
4343 }
4444}
4545
46- impl SparkChar {
46+ impl CharFunc {
4747 pub fn new ( ) -> Self {
4848 Self {
4949 signature : Signature :: uniform ( 1 , vec ! [ Int64 ] , Volatility :: Immutable ) ,
5050 }
5151 }
5252}
5353
54- impl ScalarUDFImpl for SparkChar {
54+ impl ScalarUDFImpl for CharFunc {
5555 fn as_any ( & self ) -> & dyn Any {
5656 self
5757 }
@@ -119,7 +119,11 @@ fn chr(args: &[ArrayRef]) -> Result<ArrayRef> {
119119 } else {
120120 match core:: char:: from_u32 ( ( integer % 256 ) as u32 ) {
121121 Some ( ch) => builder. append_value ( ch. to_string ( ) ) ,
122- None => return exec_err ! ( "requested character not compatible for encoding." )
122+ None => {
123+ return exec_err ! (
124+ "requested character not compatible for encoding."
125+ )
126+ }
123127 }
124128 }
125129 }
0 commit comments