alamb commented on code in PR #8862:
URL: https://github.com/apache/arrow-datafusion/pull/8862#discussion_r1457890765


##########
datafusion/physical-expr/src/functions.rs:
##########
@@ -2497,6 +2557,38 @@ mod tests {
             Boolean,
             BooleanArray
         );
+        test_function!(
+            EndsWith,
+            &[lit("alphabet"), lit("alph"),],
+            Ok(Some(false)),
+            bool,
+            Boolean,
+            BooleanArray
+        );
+        test_function!(
+            EndsWith,
+            &[lit("alphabet"), lit("bet"),],
+            Ok(Some(true)),
+            bool,
+            Boolean,
+            BooleanArray
+        );
+        test_function!(

Review Comment:
   💯  for testing with NULL



##########
datafusion/physical-expr/src/functions.rs:
##########
@@ -1379,6 +1399,46 @@ mod tests {
             Utf8,
             StringArray
         );
+        test_function!(
+            InStr,
+            &[lit("abc"), lit("b")],
+            Ok(Some(2)),
+            i32,
+            Int32,
+            Int32Array
+        );
+        test_function!(
+            InStr,
+            &[lit("abc"), lit("c")],
+            Ok(Some(3)),
+            i32,
+            Int32,
+            Int32Array
+        );
+        test_function!(
+            InStr,
+            &[lit("abc"), lit("d")],
+            Ok(Some(0)),
+            i32,
+            Int32,
+            Int32Array
+        );
+        test_function!(

Review Comment:
   Can you also add null cases like `lit(ScalarValue::Utf8(None)`)
   
   for both the string and the search argument?



##########
datafusion/physical-expr/src/string_expressions.rs:
##########
@@ -476,6 +520,24 @@ pub fn starts_with<T: OffsetSizeTrait>(args: &[ArrayRef]) 
-> Result<ArrayRef> {
     Ok(Arc::new(result) as ArrayRef)
 }
 
+/// Returns true if string ends with suffix.
+/// ends_with('alphabet', 'abet') = 't'
+pub fn ends_with<T: OffsetSizeTrait>(args: &[ArrayRef]) -> Result<ArrayRef> {
+    let string_array = as_generic_string_array::<T>(&args[0])?;

Review Comment:
   > Do you mean that I can call this library function directly in the code or 
do I not need to implement this function?
   
   Yes, I think  the body of thus function could be reduced to something like
   
   ```suggestion
       compute::comparison::ends_with(&args[0])
   ```



##########
datafusion/physical-expr/src/string_expressions.rs:
##########
@@ -296,6 +296,50 @@ pub fn initcap<T: OffsetSizeTrait>(args: &[ArrayRef]) -> 
Result<ArrayRef> {
     Ok(Arc::new(result) as ArrayRef)
 }
 
+/// Returns the position of the first occurrence of substring in string.
+/// The position is counted from 1. If the substring is not found, returns 0.
+/// For example, instr('Helloworld', 'world') = 6.
+pub fn instr<T: OffsetSizeTrait>(args: &[ArrayRef]) -> Result<ArrayRef> {

Review Comment:
   I hunted around in the arrow kernels and I did not find an equivalent
   
   @tustvold  do you know off hand if there is an arrow compute kernel that 
compute the equivalent of `instr`?
   



-- 
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]

Reply via email to