Support expressions $min, $max, $avg, $sum, $stdDevPop, $stdDevSamp in SBE

    • Type: Improvement
    • Resolution: Unresolved
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Query Execution
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      We need to support ExpressionFromAccumulator for these accumulators in SBE.

      Importantly, to stay consistent with SBE and with Classic, we must re-use the same underlying functions that we use for corresponding accumulators.

      For example, for $sum we must do something like this 

           auto [accTag, accVal] = genericInitializeDoubleDoubleSumState();
          value::ValueGuard accGuard{accTag, accVal};
          auto* accumulator = value::getArrayView(accVal);
      
          value::arrayForEach(arr.tag, arr.value, [&](value::TypeTags elemTag, value::Value elemVal) {
              if (value::isNumber(elemTag)) {
                  aggDoubleDoubleSumImpl(accumulator, elemTag, elemVal);
              }
          });    
      
          return aggDoubleDoubleSumFinalizeImpl(accumulator).releaseToRaw();

            Assignee:
            Ivan Fefer
            Reporter:
            Ivan Fefer
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: