[ 
https://issues.apache.org/jira/browse/DRILL-6810?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16666940#comment-16666940
 ] 

ASF GitHub Bot commented on DRILL-6810:
---------------------------------------

KazydubB commented on a change in pull request #1509: DRILL-6810: Disable 
NULL_IF_NULL NullHandling for functions with Comp…
URL: https://github.com/apache/drill/pull/1509#discussion_r228190067
 
 

 ##########
 File path: 
exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/StringFunctions.java
 ##########
 @@ -1396,20 +1395,66 @@ public void setup() {
 
     @Override
     public void eval() {
+      String inputString =
+          
org.apache.drill.exec.expr.fn.impl.StringFunctionHelpers.toStringFromUTF8(in.start,
 in.end, in.buffer);
       // Convert the iterable to an array as Janino will not handle generics.
-      Object[] tokens = 
com.google.common.collect.Iterables.toArray(splitter.split(
-          
org.apache.drill.exec.expr.fn.impl.StringFunctionHelpers.toStringFromUTF8(input.start,
 input.end, input.buffer)), String.class);
+      Object[] tokens = 
com.google.common.collect.Iterables.toArray(splitter.split(inputString), 
String.class);
       org.apache.drill.exec.vector.complex.writer.BaseWriter.ListWriter list = 
writer.rootAsList();
       list.startList();
-      for(int i = 0; i < tokens.length; i++ ) {
-        final byte[] strBytes = 
((String)tokens[i]).getBytes(com.google.common.base.Charsets.UTF_8);
+      for (Object token : tokens) {
+        final byte[] strBytes = ((String) 
token).getBytes(com.google.common.base.Charsets.UTF_8);
         buffer = buffer.reallocIfNeeded(strBytes.length);
         buffer.setBytes(0, strBytes);
         list.varChar().writeVarChar(0, strBytes.length, buffer);
       }
       list.endList();
     }
+  }
+
+  @FunctionTemplate(name = "split", scope = FunctionScope.SIMPLE, nulls = 
NullHandling.INTERNAL,
+      outputWidthCalculatorType = 
OutputWidthCalculatorType.CUSTOM_FIXED_WIDTH_DEFAULT)
+  public static class SplitNullableInput implements DrillSimpleFunc {
+    @Param NullableVarCharHolder in;
+    @Param VarCharHolder delimiter;
 
 Review comment:
   An error will be thrown, because there is no implementation for nullable 
(OPTIONAL) delimiter. For example:
   ```
   Error: Missing function implementation: [split(VARCHAR-OPTIONAL, 
VARCHAR-OPTIONAL)].
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


> Disable NULL_IF_NULL NullHandling for functions with ComplexWriter
> ------------------------------------------------------------------
>
>                 Key: DRILL-6810
>                 URL: https://issues.apache.org/jira/browse/DRILL-6810
>             Project: Apache Drill
>          Issue Type: Bug
>    Affects Versions: 1.14.0
>            Reporter: Bohdan Kazydub
>            Assignee: Bohdan Kazydub
>            Priority: Major
>             Fix For: 1.15.0
>
>
> Currently NullHandling.NULL_IF_NULL is allowed for UDFs with @Output of type 
> org.apache.drill.exec.vector.complex.writer.BaseWriter.ComplexWriter but no 
> null handling is performed for the kind of functions which leads to 
> confusion. The problem is ComplexWriter holds list/map values and Drill does 
> not yet support NULL values for the types (there is an issue to allow null 
> maps/lists in [DRILL-4824|https://issues.apache.org/jira/browse/DRILL-4824]).
> For such functions support for NULL_IF_NULL will be disabled, as it is done 
> for aggregate functions, and NullHandling.INTERNAL should be used instead.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to