sam-1112 commented on code in PR #5215:
URL: https://github.com/apache/datafusion-comet/pull/5215#discussion_r3964426068
##########
native/spark-expr/src/predicate_funcs/rlike.rs:
##########
@@ -225,4 +245,122 @@ mod tests {
let result =
expr.evaluate(&RecordBatch::new_empty(Arc::new(Schema::empty())));
assert!(result.is_err());
}
+
+ #[test]
+ fn test_rlike_string_array_layouts() {
+ let pattern = "R[a-z]+";
+ let cases: Vec<(DataType, ArrayRef)> = vec![
+ (
+ DataType::Utf8,
+ Arc::new(StringArray::from(vec![Some("Rose"), None,
Some("Daisy")])),
+ ),
+ (
+ DataType::LargeUtf8,
+ Arc::new(LargeStringArray::from(vec![
+ Some("Rose"),
+ None,
+ Some("Daisy"),
+ ])),
+ ),
+ (
+ DataType::Utf8View,
+ Arc::new(StringViewArray::from(vec![
+ Some("Rose"),
+ None,
+ Some("Daisy"),
+ ])),
+ ),
+ ];
+
+ for (data_type, array) in cases {
+ let schema = Arc::new(Schema::new(vec![Field::new("s", data_type,
true)]));
+ let batch = RecordBatch::try_new(Arc::clone(&schema),
vec![array]).unwrap();
+ let expr = RLike::try_new(Arc::new(Column::new("s", 0)),
pattern).unwrap();
+ assert_bool_results(
+ expr.evaluate(&batch).unwrap(),
+ &[Some(true), None, Some(false)],
+ );
+ }
+ }
+
+ #[test]
+ fn test_rlike_string_array_no_nulls() {
+ let schema = Arc::new(Schema::new(vec![Field::new("s", DataType::Utf8,
false)]));
+ let batch = RecordBatch::try_new(
+ Arc::clone(&schema),
+ vec![Arc::new(StringArray::from(vec!["Rose", "Daisy"]))],
+ )
+ .unwrap();
+
+ let expr = RLike::try_new(Arc::new(Column::new("s", 0)),
"R[a-z]+").unwrap();
+ let ColumnarValue::Array(arr) = expr.evaluate(&batch).unwrap() else {
+ panic!("expected array result");
+ };
+ // All-valid input must not allocate a null buffer (filter fast path).
Review Comment:
Agreed. I reworded the comment to describe preserving the null-buffer-free
output shape and avoiding the unnecessary validity allocation, without
referring to the filter fast path.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]