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


##########
docs/source/user-guide/sql/scalar_functions.md:
##########
@@ -1120,6 +1121,21 @@ Returns UUID v4 string value which is unique per row.
 uuid()
 ```
 
+### `overlay`
+
+Returns the string which is replaced by another string from the specified 
position and specified count length
+
+```
+overlay(str PLACING substr FROM pos [FOR count])
+```
+

Review Comment:
   Having the example made it much easier for me to see what was going on in 
postgres. Can we add an example here as well?
   
   ```suggestion
   For example, `overlay('Txxxxas' placing 'hom' from 2 for 4) → Thomas`
   ```
   



##########
datafusion/sqllogictest/test_files/functions.slt:
##########
@@ -815,3 +815,33 @@ SELECT products.* REPLACE (price*2 AS price, 
product_id+1000 AS product_id) FROM
 1002 OldBrand Product 2 59.98
 1003 OldBrand Product 3 79.98
 1004 OldBrand Product 4 99.98
+
+#overlay tests
+statement ok
+CREATE TABLE over_test(
+  str TEXT,
+  characters TEXT,
+  pos INT,
+  len INT
+) as VALUES
+  ('123', 'abc', 4, 5),
+  ('abcdefg', 'qwertyasdfg', 1, 7),
+  ('xyz', 'ijk', 1, 2),
+  ('Txxxxas', 'hom', 2, 4)

Review Comment:
   Can you please also test `NULL` handling here? I think your code handles it 
properly, but it would be good to have this in the SQL tests. We can do this as 
a follow on PR if you prefer. 
   
   Specifically
   ```suggestion
     ('Txxxxas', 'hom', 2, 4),
     (NULL, 'hom', 2, 4), -- expect NULL output
     ('Txxxxas', 'hom', NULL, 4), -- expect NULL output
     ('Txxxxas', 'hom', 2, NULL) -- expect NULL output
   ```



##########
docs/source/user-guide/sql/scalar_functions.md:
##########
@@ -1120,6 +1121,21 @@ Returns UUID v4 string value which is unique per row.
 uuid()
 ```
 
+### `overlay`
+
+Returns the string which is replaced by another string from the specified 
position and specified count length
+
+```
+overlay(str PLACING substr FROM pos [FOR count])
+```
+

Review Comment:
   Having the example made it much easier for me to see what was going on in 
postgres. Can we add an example here as well?
   
   ```suggestion
   For example, `overlay('Txxxxas' placing 'hom' from 2 for 4) → Thomas`
   ```
   



##########
docs/source/user-guide/sql/scalar_functions.md:
##########
@@ -1120,6 +1121,21 @@ Returns UUID v4 string value which is unique per row.
 uuid()
 ```
 
+### `overlay`
+
+Returns the string which is replaced by another string from the specified 
position and specified count length
+
+```
+overlay(str PLACING substr FROM pos [FOR count])
+```
+
+#### Arguments
+
+- **str**: String expression to operate on.
+- **substr**: the string to replace part of str.
+- **pos**: the start position to replace of str.
+- **count**: the count of characters to be replaced from start position of 
str.If not specified, will use substr length instead.

Review Comment:
   ```suggestion
   - **count**: the count of characters to be replaced from start position of 
str. If not specified, will use substr length instead.
   ```



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