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

NPE in FunctionImplementationRegistry.functionReplacement()

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.10.0
    • Fix Version/s: 1.11.0
    • Component/s: None
    • Labels:

      Description

      The code in FunctionImplementationRegistry.functionReplacement() will produce an NPE if ever it is called:

                if (optionManager != null
                    && optionManager.getOption(
                         ExecConstants.CAST_TO_NULLABLE_NUMERIC).bool_val
                    ...
      

      If an option manager is provided, then get the specified option. The option manager will contain a value for that option only if the user has explicitly set that option. Suppose the user had not set the option. Then the return from getOption() will be null.

      The next thing we do is assume that the option exists and is a boolean by dereferencing the option. This will trigger an NPE. This NPE was seen in detail-level unit tests.

      The proper way to handle such options is to use an option validator. Strangely, one actually exists in ExecConstants:

        String CAST_TO_NULLABLE_NUMERIC = "drill.exec.functions.cast_empty_string_to_null";
        OptionValidator CAST_TO_NULLABLE_NUMERIC_OPTION = new BooleanValidator(CAST_TO_NULLABLE_NUMERIC, false);
      

      Then do:

      optionManager.getOption(
               ExecConstants.CAST_TO_NULLABLE_NUMERIC_OPTION)
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                paul-rogers Paul Rogers
                Reporter:
                paul-rogers Paul Rogers
                Reviewer:
                Arina Ielchiieva
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: