maropu commented on a change in pull request #29891:
URL: https://github.com/apache/spark/pull/29891#discussion_r503604990



##########
File path: 
sql/core/src/test/resources/sql-tests/results/regexp-functions.sql.out
##########
@@ -252,3 +252,53 @@ SELECT regexp_extract_all('a 2b 14m', '(\\d+)?([a-z]+)', 1)
 struct<regexp_extract_all(a 2b 14m, (\d+)?([a-z]+), 1):array<string>>
 -- !query output
 ["","2","14"]
+
+
+-- !query
+SELECT regexp_replace('healthy, wealthy, and wise', '\\w+thy', 'something')
+-- !query schema
+struct<regexp_replace(healthy, wealthy, and wise, \w+thy, something, 1):string>
+-- !query output
+something, something, and wise
+
+
+-- !query
+SELECT regexp_replace('healthy, wealthy, and wise', '\\w+thy', 'something', -2)
+-- !query schema
+struct<>
+-- !query output
+org.apache.spark.sql.AnalysisException
+cannot resolve 'regexp_replace('healthy, wealthy, and wise', '\\w+thy', 
'something', -2)' due to data type mismatch: Position expression must be 
positive, but got: -2; line 1 pos 7

Review comment:
       All the other databases have the same behaviour? (they cannot accept a 
negative value?)
   It seems Redshift can accept it?
   ```
   ...The default is 1. If position is less than 1, the search begins at the 
first character of source_string. If position is greater than the number of 
characters in source_string, the result is source_string.
   ```




----------------------------------------------------------------
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:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to