How to use the plywood.ApplyExpression function in plywood

To help you get started, we’ve selected a few plywood examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github allegro / turnilo / src / common / models / expression / percent.ts View on Github external
public toExpression(expression: Expression, name: string, nestingLevel: number): ApplyExpression {
    const relativeNesting = this.relativeNesting(nestingLevel);
    const formulaName = `__formula_${name}`;
    if (relativeNesting < 0) throw new Error(`wrong nesting level: ${relativeNesting}`);
    return new ApplyExpression({
      name,
      operand: new ApplyExpression({ expression, name: formulaName }),
      expression: $(formulaName).divide($(formulaName, relativeNesting)).fallback(0)
    });
  }
github allegro / turnilo / src / common / models / expression / concreteArithmeticOperation.ts View on Github external
toExpression(expression: Expression, name: string, _nestingLevel: number): ApplyExpression {
    return new ApplyExpression({
      name,
      expression: this.calculate(expression)
    });
  }
}
github allegro / turnilo / src / common / models / series / quantile-concrete-series.ts View on Github external
protected applyExpression(quantileExpression: PlywoodExpression, name: string, nestingLevel: number): ApplyExpression {
    if (!(quantileExpression instanceof QuantileExpression)) throw new Error(`Expected QuantileExpression, got ${quantileExpression}`);
    const expression = new QuantileExpression({ ...quantileExpression.valueOf(), value: this.definition.percentile / 100 });
    return new ApplyExpression({ name, expression });
  }
}
github allegro / turnilo / src / common / models / series / measure-concrete-series.ts View on Github external
protected applyExpression(expression: Expression, name: string, nestingLevel: number): ApplyExpression {
    return new ApplyExpression({ expression, name });
  }
}
github allegro / turnilo / src / common / models / expression / percent.ts View on Github external
public toExpression(expression: Expression, name: string, nestingLevel: number): ApplyExpression {
    const relativeNesting = this.relativeNesting(nestingLevel);
    const formulaName = `__formula_${name}`;
    if (relativeNesting < 0) throw new Error(`wrong nesting level: ${relativeNesting}`);
    return new ApplyExpression({
      name,
      operand: new ApplyExpression({ expression, name: formulaName }),
      expression: $(formulaName).divide($(formulaName, relativeNesting)).fallback(0)
    });
  }