dongjoon-hyun commented on a change in pull request #24802: [SPARK-27949][SQL]
Support ANSI SQL grammar `substring(string_expression from n1 [for n2])`
URL: https://github.com/apache/spark/pull/24802#discussion_r291879703
##########
File path: sql/core/src/test/resources/sql-tests/inputs/string-functions.sql
##########
@@ -24,3 +24,13 @@ select right(null, -2), right("abcd", -2), right("abcd",
0), right("abcd", 'a');
-- split function
SELECT split('aa1cc2ee3', '[1-9]+');
SELECT split('aa1cc2ee3', '[1-9]+', 2);
+
+--substring function
+SELECT substring('abcdefg', 1);
+SELECT substring('abcdefg', -1, 5);
+SELECT substr('abcdefg', 1);
+SELECT substr('abcdefg', -1, 5);
+SELECT substring('abcdefg' from 1);
+SELECT substring('abcdefg' from -1 for 5);
+SELECT substr('abcdefg' from 1);
+SELECT substr('abcdefg' from -1 for 5);
Review comment:
Could you change the test case? We can have a better test case for the
parameters of `substring`. Please use the example from the `substring` function
description.
```
Examples:
> SELECT _FUNC_('Spark SQL', 5);
k SQL
> SELECT _FUNC_('Spark SQL', -3);
SQL
> SELECT _FUNC_('Spark SQL', 5, 1);
k
```
----------------------------------------------------------------
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]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]