Uploaded image for project: 'Apache Drill'
  1. Apache Drill
  2. DRILL-6075

Drill-provided UDF helper functions may prevent scalar replacement

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • 1.10.0
    • None
    • None
    • None

    Description

      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 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:

      public static String getStringFromVarCharHolder(VarCharHolder varCharHolder);
      public static String getStringFromVarCharHolder(NullableVarCharHolder varCharHolder);
      

      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*]

      Attachments

        Activity

          People

            Unassigned Unassigned
            Paul.Rogers Paul Rogers
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: