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



##########
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:
       hm, I see. But, the existing other functions (e.g., `StringLocate`) can 
accept a negative value for a position param. So, how about following the Spark 
way?




----------------------------------------------------------------
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:
us...@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to