How to use the plywood.Expression.parse 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 / series / quantile-concrete-series.mocha.ts View on Github external
it("should throw if expression is not a quantile expression", () => {
      const expression = Expression.parse("$main.count()");
      // @ts-ignore: access protected property
      expect(() => quantileConcreteSeries.applyExpression(expression, "name", 0)).throws();
    });
github geo-opensource / pivot / src / common / models / measure / measure.ts View on Github external
constructor(parameters: MeasureValue) {
    super(parameters);

    this.title = this.title || makeTitle(this.name);
    this.expression = Expression.parse(this.formula);
    this.formatFn = formatFnFactory(this.getFormat());
  }
github geo-opensource / pivot / src / common / models / dimension / dimension.ts View on Github external
constructor(parameters: DimensionValue) {
    var name = parameters.name;
    verifyUrlSafeName(name);
    this.name = name;
    this.title = parameters.title || makeTitle(name);

    var formula = parameters.formula || $(name).toString();
    this.formula = formula;
    this.expression = Expression.parse(formula);

    var kind = parameters.kind || typeToKind(this.expression.type) || 'string';
    this.kind = kind;

    if (kind === 'string' && isGeo(name)) {
      this.className = 'string-geo';
    } else {
      this.className = kind;
    }
    if (parameters.url) {
      if (typeof parameters.url !== 'string') {
        throw new Error(`unsupported url: ${parameters.url}: only strings are supported`);
      }
      this.url = parameters.url;
    }
github allegro / turnilo / src / common / models / measure / measure.ts View on Github external
constructor(parameters: MeasureValue) {
    super(parameters);

    this.title = this.title || makeTitle(this.name);
    this.expression = Expression.parse(this.formula);
    this.formatFn = formatFnFactory(this.getFormat());
  }
github allegro / turnilo / src / common / models / dimension / dimension.ts View on Github external
constructor(parameters: DimensionValue) {
    const name = parameters.name;
    verifyUrlSafeName(name);
    this.name = name;
    this.title = parameters.title || makeTitle(name);
    this.description = parameters.description;

    const formula = parameters.formula || $(name).toString();
    this.formula = formula;
    this.expression = Expression.parse(formula);

    const kind = parameters.kind ? readKind(parameters.kind) : typeToKind(this.expression.type);
    this.kind = kind;
    this.multiValue = true === parameters.multiValue;
    this.className = kind;

    if (parameters.url) {
      if (typeof parameters.url !== "string") {
        throw new Error(`unsupported url: ${parameters.url}: only strings are supported`);
      }
      this.url = parameters.url;
    }

    const granularities = parameters.granularities;
    if (granularities) {
      if (!Array.isArray(granularities) || granularities.length !== 5) {