Paul Rogers created DRILL-6075:
----------------------------------

             Summary: Drill-provided UDF helper functions may prevent scalar 
replacement
                 Key: DRILL-6075
                 URL: https://issues.apache.org/jira/browse/DRILL-6075
             Project: Apache Drill
          Issue Type: Bug
    Affects Versions: 1.10.0
            Reporter: Paul Rogers
            Priority: Minor


Users can write UDFs which use "holders" to pass data into and out of 
functions. UDFs are templates, written in a Drill-defined DSL, that Drill uses 
to copy UDF code into the generated code (often in the Project operator.)

Our 
[documentation|http://drill.apache.org/docs/tutorial-develop-a-simple-function/]
 has vague warnings about not referencing methods in the holders because doing 
so prevents scalar replacement.

But, at the same time, Drill provides the {{StringFunctionHelpers}} class that 
contains, among others, these two methods:

{code}
public static String getStringFromVarCharHolder(VarCharHolder varCharHolder);
public static String getStringFromVarCharHolder(NullableVarCharHolder 
varCharHolder);
{code}

The example shown in the documentation calls one of the above methods.

We're sending mixed signals (or are confused) here. By passing a holder to a 
method, we prevent any reasonable scalar replacement algorithm from working. 
So, if we believe that not replacing holders is slow, we should not encourage 
use of the above methods.

Instead, the rules for holders should be:

* Call no methods on the holders.
* Do not pass holders to other functions.

A number of Drill's own functions make this mistake:

{{SqlToDate}}
{{SqlToTime}}
{{SqlToTimestamp}}
{{DirectoryExplorers.[IMax*, IMin*, Max*, Min*]}}




--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to