@@ -169,6 +169,8 @@ pub enum BuiltinScalarFunction {
169169 NullIf ,
170170 /// octet_length
171171 OctetLength ,
172+ /// random
173+ Random ,
172174 /// regexp_replace
173175 RegexpReplace ,
174176 /// repeat
@@ -219,7 +221,10 @@ impl BuiltinScalarFunction {
219221 /// an allowlist of functions to take zero arguments, so that they will get special treatment
220222 /// while executing.
221223 fn supports_zero_argument ( & self ) -> bool {
222- matches ! ( self , BuiltinScalarFunction :: Now )
224+ matches ! (
225+ self ,
226+ BuiltinScalarFunction :: Random | BuiltinScalarFunction :: Now
227+ )
223228 }
224229}
225230
@@ -275,6 +280,7 @@ impl FromStr for BuiltinScalarFunction {
275280 "md5" => BuiltinScalarFunction :: MD5 ,
276281 "nullif" => BuiltinScalarFunction :: NullIf ,
277282 "octet_length" => BuiltinScalarFunction :: OctetLength ,
283+ "random" => BuiltinScalarFunction :: Random ,
278284 "regexp_replace" => BuiltinScalarFunction :: RegexpReplace ,
279285 "repeat" => BuiltinScalarFunction :: Repeat ,
280286 "replace" => BuiltinScalarFunction :: Replace ,
@@ -438,6 +444,7 @@ pub fn return_type(
438444 ) ) ;
439445 }
440446 } ) ,
447+ BuiltinScalarFunction :: Random => Ok ( DataType :: Float64 ) ,
441448 BuiltinScalarFunction :: RegexpReplace => Ok ( match arg_types[ 0 ] {
442449 DataType :: LargeUtf8 => DataType :: LargeUtf8 ,
443450 DataType :: Utf8 => DataType :: Utf8 ,
@@ -742,6 +749,7 @@ pub fn create_physical_expr(
742749 BuiltinScalarFunction :: Ln => math_expressions:: ln,
743750 BuiltinScalarFunction :: Log10 => math_expressions:: log10,
744751 BuiltinScalarFunction :: Log2 => math_expressions:: log2,
752+ BuiltinScalarFunction :: Random => math_expressions:: random,
745753 BuiltinScalarFunction :: Round => math_expressions:: round,
746754 BuiltinScalarFunction :: Signum => math_expressions:: signum,
747755 BuiltinScalarFunction :: Sin => math_expressions:: sin,
@@ -1307,6 +1315,7 @@ fn signature(fun: &BuiltinScalarFunction) -> Signature {
13071315 Signature :: Exact ( vec![ DataType :: Utf8 , DataType :: Utf8 , DataType :: Utf8 ] ) ,
13081316 Signature :: Exact ( vec![ DataType :: LargeUtf8 , DataType :: Utf8 , DataType :: Utf8 ] ) ,
13091317 ] ) ,
1318+ BuiltinScalarFunction :: Random => Signature :: Exact ( vec ! [ ] ) ,
13101319 // math expressions expect 1 argument of type f64 or f32
13111320 // priority is given to f64 because e.g. `sqrt(1i32)` is in IR (real numbers) and thus we
13121321 // return the best approximation for it (in f64).
0 commit comments