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

NPE in FunctionImplementationRegistry.functionReplacement()

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 1.10.0
    • 1.11.0
    • None

    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

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

              Dates

                Created:
                Updated:
                Resolved: