Dandandan commented on a change in pull request #303: URL: https://github.com/apache/arrow-datafusion/pull/303#discussion_r629298188
########## File path: datafusion/src/physical_plan/math_expressions.rs ########## @@ -116,3 +116,21 @@ math_unary_function!("exp", exp); math_unary_function!("ln", ln); math_unary_function!("log2", log2); math_unary_function!("log10", log10); + +/// random SQL function +pub fn random(args: &[ColumnarValue]) -> Result<ColumnarValue> { + let len = match &args[0] { + ColumnarValue::Array(array) => array.len(), + _ => { + return Err(DataFusionError::Internal( + "Expect random function to take no param".to_string(), + )) + } + }; + let mut rng = thread_rng(); + let mut array = Vec::with_capacity(len); + for _ in 0..len { + array.push(Some(rng.gen_range(0.0..1.0))) Review comment: `arrow::compute::kernels::arity::unary` could be probably used here. see also: https://github.com/apache/arrow-datafusion/pull/309 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org