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_r227348128
########## File path: exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/ParseQueryFunction.java ########## @@ -23,65 +23,157 @@ import org.apache.drill.exec.expr.annotations.Output; import org.apache.drill.exec.expr.annotations.Param; import org.apache.drill.exec.expr.holders.NullableVarCharHolder; +import org.apache.drill.exec.expr.holders.VarCharHolder; import org.apache.drill.exec.vector.complex.writer.BaseWriter; import javax.inject.Inject; -@FunctionTemplate( - name="parse_query", - scope= FunctionTemplate.FunctionScope.SIMPLE, - nulls = FunctionTemplate.NullHandling.NULL_IF_NULL -) +/** + * The function splits up a query string and returns a map of the key-value pairs. + * For example, {@code parse_query('url?arg1=x&arg2=y')} will return: + * <pre> + * { + * "arg1": "x", + * "arg2": "y" + * } + * </pre> + */ +public class ParseQueryFunction { -public class ParseQueryFunction implements DrillSimpleFunc { + @FunctionTemplate(name = "parse_query", scope = FunctionTemplate.FunctionScope.SIMPLE) + public static class ParseQuery implements DrillSimpleFunc { @Param - NullableVarCharHolder input; - + VarCharHolder in; @Output BaseWriter.ComplexWriter outWriter; - @Inject DrillBuf outBuffer; + @Override public void setup() { } + @Override public void eval() { - - org.apache.drill.exec.vector.complex.writer.BaseWriter.MapWriter queryMapWriter = outWriter.rootAsMap(); - - String queryString = org.apache.drill.exec.expr.fn.impl.StringFunctionHelpers.toStringFromUTF8(input.start, input.end, input.buffer); - - if( queryString.isEmpty() || queryString.equals("null")){ - queryString = ""; + org.apache.drill.exec.vector.complex.writer.BaseWriter.MapWriter mapWriter = outWriter.rootAsMap(); + + String queryString = + org.apache.drill.exec.expr.fn.impl.StringFunctionHelpers.toStringFromUTF8(in.start, in.end, in.buffer); + int questionMarkIndex = queryString.indexOf("?"); Review comment: Please add comment with explanation. ---------------------------------------------------------------- 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: us...@infra.apache.org With regards, Apache Git Services