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 2016/05/17 20:58:12 UTC
[jira] [Commented] (DRILL-4607) Add a split function that allows to
separate string by a delimiter
[ https://issues.apache.org/jira/browse/DRILL-4607?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15287543#comment-15287543 ]
ASF GitHub Bot commented on DRILL-4607:
---------------------------------------
Github user sudheeshkatkam commented on a diff in the pull request:
https://github.com/apache/drill/pull/481#discussion_r63602468
--- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/StringFunctions.java ---
@@ -1280,6 +1280,43 @@ public void eval() {
} // end of eval
}
+ @FunctionTemplate(name = "split", scope = FunctionScope.SIMPLE, nulls = NullHandling.NULL_IF_NULL)
+ public static class Split implements DrillSimpleFunc {
+ @Param VarCharHolder input;
+ @Param VarCharHolder delimiter;
+
+ @Workspace char splitChar;
--- End diff --
How about reusing the Splitter?
Create a workspace splitter once in setup, and use in eval.
> Add a split function that allows to separate string by a delimiter
> ------------------------------------------------------------------
>
> Key: DRILL-4607
> URL: https://issues.apache.org/jira/browse/DRILL-4607
> Project: Apache Drill
> Issue Type: New Feature
> Components: Functions - Drill
> Affects Versions: 1.6.0
> Reporter: Alicia Alvarez
>
> Ex: Let's say I have records in a CSV file with the following schema
> {noformat}
> user_name, friend_list_separated_by_a_delimiter,other_fields
> ali,sam;adi;tom,45,...
> {noformat}
> I want to run a query which returns the friend list files as a repeated value.
> {noformat}
> select user_name, split(friend_list, ';') friends from userdata;
> {noformat}
> This should return the records in the following format
> {noformat}
> ---------------------------------
> | user_name | friends |
> ---------------------------------
> | ali | [sam, adi, tom] |
> ---------------------------------
> {noformat}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)