How to use the plywood.AttributeInfo.override 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 / data-cube / data-cube.ts View on Github external
filter: this.subsetExpression
    };

    if (cluster.type === "druid") {
      externalValue.rollup = this.rollup;
      externalValue.timeAttribute = this.timeAttribute.name;
      externalValue.introspectionStrategy = cluster.getIntrospectionStrategy();
      externalValue.allowSelectQueries = true;

      let externalContext: Record = options.druidContext || {};
      externalContext["timeout"] = cluster.getTimeout();
      externalValue.context = externalContext;
    }

    if (this.introspection === "none") {
      externalValue.attributes = AttributeInfo.override(this.deduceAttributes(), this.attributeOverrides);
      externalValue.derivedAttributes = this.derivedAttributes;
    } else {
      // ToDo: else if (we know that it will GET introspect) and there are no overrides apply special attributes as overrides
      externalValue.attributeOverrides = this.attributeOverrides;
    }

    return External.fromValue(externalValue);
  }
github allegro / turnilo / src / common / models / data-cube / data-cube.ts View on Github external
attributes.push(AttributeInfo.fromJS({ name: reference, type: "STRING" }));
      }
    });

    measures.forEachMeasure(measure => {
      const references = Measure.getReferences(measure.expression);
      for (let reference of references) {
        if (NamedArray.findByName(attributes, reference)) continue;
        if (Measure.hasCountDistinctReferences(measure.expression)) continue;
        if (Measure.hasQuantileReferences(measure.expression)) continue;
        attributes.push(AttributeInfo.fromJS({ name: reference, type: "NUMBER" }));
      }
    });

    if (attributeOverrides.length) {
      attributes = AttributeInfo.override(attributes, attributeOverrides);
    }

    return attributes;
  }
github allegro / turnilo / src / common / models / data-cube / data-cube.ts View on Github external
break;

        default:
          throw new Error(`unsupported attribute ${name}; type ${type}, native type ${nativeType}`);
      }
    }

    if (!this.rolledUp() && !measures.containsMeasureWithName("count")) {
      measures = measures.prepend(new Measure({
        name: "count",
        formula: $main.count().toString()
      }));
    }

    let value = this.valueOf();
    value.attributes = attributes ? AttributeInfo.override(attributes, newAttributes) : newAttributes;
    value.dimensions = dimensions;
    value.measures = measures;

    if (!value.defaultSortMeasure) {
      value.defaultSortMeasure = measures.size() ? measures.first().name : null;
    }

    if (!value.timeAttribute && dimensions.size && dimensions.first().kind === "time") {
      value.timeAttribute = dimensions.first().expression as RefExpression;
    }

    return new DataCube(value);
  }