Uploaded image for project: 'Apache Drill'
  1. Apache Drill
  2. DRILL-5330 NPE in FunctionImplementationRegistry.functionReplacement()
  3. DRILL-5331

NPE in FunctionImplementationRegistry.findDrillFunction() if dynamic UDFs disabled

    XMLWordPrintableJSON

Details

    • Sub-task
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 1.10.0
    • 1.11.0
    • None
    • None

    Description

      Drill provides the Dynamic UDF (DUDF) functionality. DUFDs can be disabled using the following option in ExecConstants:

        String USE_DYNAMIC_UDFS_KEY = "exec.udf.use_dynamic";
        BooleanValidator USE_DYNAMIC_UDFS = new BooleanValidator(USE_DYNAMIC_UDFS_KEY, true);
      

      In a unit test, we created a setup in which we wish to use only the local function registry, no DUDF support is needed. Run the code. The following code is invoked when asking for a non-existent function:

        public DrillFuncHolder findDrillFunction(FunctionResolver functionResolver, FunctionCall functionCall) {
          ...
          if (holder == null) {
            syncWithRemoteRegistry(version.get());
            List<DrillFuncHolder> updatedFunctions = localFunctionRegistry.getMethods(newFunctionName, version);
            holder = functionResolver.getBestMatch(updatedFunctions, functionCall);
          }
      

      The result is an NPE:

      ERROR o.a.d.e.e.f.r.RemoteFunctionRegistry - Problem during trying to access remote function registry [registry]
      java.lang.NullPointerException: null
      	at org.apache.drill.exec.expr.fn.registry.RemoteFunctionRegistry.getRegistryVersion(RemoteFunctionRegistry.java:119) ~[classes/:na]
      

      The fix is simply to add a DUDF-enabled check:

          if (holder == null) {
            boolean useDynamicUdfs = optionManager != null && optionManager.getOption(ExecConstants.USE_DYNAMIC_UDFS);
            if (useDynamicUdfs) {
              syncWithRemoteRegistry(version.get());
              ...
      

      Then, disable dynamic UDFs for the test case by setting ExecConstants.USE_DYNAMIC_UDFS to false.

      Attachments

        Activity

          People

            paul-rogers Paul Rogers
            paul-rogers Paul Rogers
            Arina Ielchiieva Arina Ielchiieva
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: