Uploaded image for project: 'Calcite'
  1. Calcite
  2. CALCITE-6383

The class SameOperandTypeChecker is incorrectly documented

    XMLWordPrintableJSON

Details

    Description

      The SameOperandTypeChecker claims that it checks whether operands have the same type (the class name suggests this, as does the JavaDoc).

      /**
       * Parameter type-checking strategy where all operand types must be the same.
       */
      public class SameOperandTypeChecker implements SqlSingleOperandTypeChecker {
      

      But the code does something this:

          for (int i : operandList) {
            if (prev >= 0) {
              if (!SqlTypeUtil.isComparable(types[i], types[prev])) {
      

      The documentation for isComparable says:

        /**
         * Returns whether two types are comparable. They need to be scalar types of
         * the same family, or struct types whose fields are pairwise comparable.
      

      Thus the class only checks that the operands have the same type family, not the same type.

      I am not sure what the right fix is, though, since changing the class name would be a pretty big breaking change. But I suspect this confusion is a source of a few bugs. An instance is CALCITE-6382

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              mbudiu Mihai Budiu
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: