You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@drill.apache.org by "ASF GitHub Bot (Jira)" <ji...@apache.org> on 2023/02/21 04:04:00 UTC
[jira] [Commented] (DRILL-8402) Add REGEXP_EXTRACT Function
[ https://issues.apache.org/jira/browse/DRILL-8402?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17691361#comment-17691361 ]
ASF GitHub Bot commented on DRILL-8402:
---------------------------------------
cgivre opened a new pull request, #2762:
URL: https://github.com/apache/drill/pull/2762
# [DRILL-8402](https://issues.apache.org/jira/browse/DRILL-8402): Add REGEXP_EXTRACT Function
## Description
Adds `regexp_extract` functions to Drill.
## Documentation
This PR adds support for `regexp_extract(<text>, <pattern>)` which returns an array of text corresponding with the capturing groups in the regex. It also includes `regexp_extract(<text>, <pattern>, <index>)` which returns the text of a specific capturing group.
```sql
SELECT regexp_extract('123-456-789', '([0-9]{3})-([0-9]{3})-([0-9]{3})');
+---------------------+
| EXPR$0 |
+---------------------+
| ["123","456","789"] |
+---------------------+
SELECT regexp_extract('123-456-789', '([0-9]{3})-([0-9]{3})-([0-9]{3})', 0);
+-------------+
| EXPR$0 |
+-------------+
| 123-456-789 |
+-------------+
SELECT regexp_extract('123-456-789', '([0-9]{3})-([0-9]{3})-([0-9]{3})', 3);
+--------+
| EXPR$0 |
+--------+
| 789 |
+--------+
```
## Testing
Added unit tests.
> Add REGEXP_EXTRACT Function
> ---------------------------
>
> Key: DRILL-8402
> URL: https://issues.apache.org/jira/browse/DRILL-8402
> Project: Apache Drill
> Issue Type: Improvement
> Components: Functions - Drill
> Affects Versions: 1.21.0
> Reporter: Charles Givre
> Assignee: Charles Givre
> Priority: Major
> Fix For: 1.21.0
>
>
> This PR adds two UDFs to Drill:
> regexp_extract(<text>, <pattern>) which returns an array of strings which were captured by capturing groups in the regex.
> regexp_extract(<text>, <pattern>, <index>) returns the text captured by a specific capturing group.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)