arina-ielchiieva 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_r227347397
##########
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:
Did you check what will happen if delimiter is passed as null?
----------------------------------------------------------------
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]
With regards,
Apache Git Services