Esempio n. 1
0
 public WindowGroup(
     AnalyticExpr analyticExpr,
     SlotDescriptor logicalOutputSlot,
     SlotDescriptor logicalIntermediateSlot) {
   partitionByExprs = analyticExpr.getPartitionExprs();
   orderByElements = analyticExpr.getOrderByElements();
   window = analyticExpr.getWindow();
   analyticExprs.add(analyticExpr);
   analyticFnCalls.add(analyticExpr.getFnCall());
   logicalOutputSlots.add(logicalOutputSlot);
   logicalIntermediateSlots.add(logicalIntermediateSlot);
 }
Esempio n. 2
0
    /**
     * True if the partition exprs and ordering elements and the window of analyticExpr match ours.
     */
    public boolean isCompatible(AnalyticExpr analyticExpr) {
      if (requiresIndependentEval(analyticExprs.get(0)) || requiresIndependentEval(analyticExpr)) {
        return false;
      }

      if (!Expr.equalSets(analyticExpr.getPartitionExprs(), partitionByExprs)) {
        return false;
      }
      if (!analyticExpr.getOrderByElements().equals(orderByElements)) return false;
      if ((window == null) != (analyticExpr.getWindow() == null)) return false;
      if (window == null) return true;
      return analyticExpr.getWindow().equals(window);
    }
Esempio n. 3
0
 /** True if this analytic function must be evaluated in its own WindowGroup. */
 private static boolean requiresIndependentEval(AnalyticExpr analyticExpr) {
   return analyticExpr
       .getFnCall()
       .getFnName()
       .getFunction()
       .equals(AnalyticExpr.FIRST_VALUE_REWRITE);
 }
Esempio n. 4
0
 /**
  * Adds the given analytic expr and its logical slots to this window group. Assumes the
  * corresponding analyticExpr is compatible with 'this'.
  */
 public void add(
     AnalyticExpr analyticExpr,
     SlotDescriptor logicalOutputSlot,
     SlotDescriptor logicalIntermediateSlot) {
   Preconditions.checkState(isCompatible(analyticExpr));
   analyticExprs.add(analyticExpr);
   analyticFnCalls.add(analyticExpr.getFnCall());
   logicalOutputSlots.add(logicalOutputSlot);
   logicalIntermediateSlots.add(logicalIntermediateSlot);
 }