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

Random functions are incorrectly considered deterministic

    XMLWordPrintableJSON

Details

    Description

      RAND, RANDOM, and RAND_INTEGER don't override the isDeterministic method, so they get the default behavior, i.e. true, which is incorrect.

      This can lead to undesired consequences, e.g.:
      A) RelMetadataQuery#getPulledUpPredicates can consider them as constants (and place them inside RelOptPredicateList#constantMap) since RelMdPredicates calls RexUtil#isConstant, which uses a ConstantFinder that evaluates whether a RexCall is constant or not based on the operator's isDeterministic value.
      B) As a consequence of A) SortRemoveConstantKeyRule can incorrectly remove an "ORDER BY RAND()"

      Attachments

        Issue Links

          Activity

            People

              rubenql Ruben Q L
              rubenql Ruben Q L
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: