Lordworms commented on code in PR #9329: URL: https://github.com/apache/arrow-datafusion/pull/9329#discussion_r1504505832
########## datafusion/physical-expr/src/functions.rs: ########## @@ -3191,89 +3167,89 @@ mod tests { Ok(()) } - #[test] - #[cfg(feature = "regex_expressions")] - fn test_regexp_match() -> Result<()> { - use datafusion_common::cast::{as_list_array, as_string_array}; - let schema = Schema::new(vec![Field::new("a", DataType::Utf8, false)]); - let execution_props = ExecutionProps::new(); - - let col_value: ArrayRef = Arc::new(StringArray::from(vec!["aaa-555"])); - let pattern = lit(r".*-(\d*)"); - let columns: Vec<ArrayRef> = vec![col_value]; - let expr = create_physical_expr_with_type_coercion( - &BuiltinScalarFunction::RegexpMatch, - &[col("a", &schema)?, pattern], - &schema, - &execution_props, - )?; - - // type is correct - assert_eq!( - expr.data_type(&schema)?, - DataType::List(Arc::new(Field::new("item", DataType::Utf8, true))) - ); - - // evaluate works - let batch = RecordBatch::try_new(Arc::new(schema.clone()), columns)?; - let result = expr - .evaluate(&batch)? - .into_array(batch.num_rows()) - .expect("Failed to convert to array"); - - // downcast works - let result = as_list_array(&result)?; - let first_row = result.value(0); - let first_row = as_string_array(&first_row)?; - - // value is correct - let expected = "555".to_string(); - assert_eq!(first_row.value(0), expected); - - Ok(()) - } - - #[test] - #[cfg(feature = "regex_expressions")] - fn test_regexp_match_all_literals() -> Result<()> { - use datafusion_common::cast::{as_list_array, as_string_array}; - let schema = Schema::new(vec![Field::new("a", DataType::Int32, false)]); - let execution_props = ExecutionProps::new(); - - let col_value = lit("aaa-555"); - let pattern = lit(r".*-(\d*)"); - let columns: Vec<ArrayRef> = vec![Arc::new(Int32Array::from(vec![1]))]; - let expr = create_physical_expr_with_type_coercion( - &BuiltinScalarFunction::RegexpMatch, - &[col_value, pattern], - &schema, - &execution_props, - )?; - - // type is correct - assert_eq!( - expr.data_type(&schema)?, - DataType::List(Arc::new(Field::new("item", DataType::Utf8, true))) - ); - - // evaluate works - let batch = RecordBatch::try_new(Arc::new(schema.clone()), columns)?; - let result = expr - .evaluate(&batch)? - .into_array(batch.num_rows()) - .expect("Failed to convert to array"); - - // downcast works - let result = as_list_array(&result)?; - let first_row = result.value(0); - let first_row = as_string_array(&first_row)?; - - // value is correct - let expected = "555".to_string(); - assert_eq!(first_row.value(0), expected); - - Ok(()) - } + // #[test] Review Comment: I would port it to .slt -- 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. To unsubscribe, e-mail: github-unsubscr...@arrow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org