How to use the plywood.AttributeInfo.fromJSs 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 geo-opensource / pivot / src / common / models / data-cube / data-cube.mocha.ts View on Github external
it("works in basic case (no count) + re-add", () => {
      var attributes1 = AttributeInfo.fromJSs([
        { name: '__time', type: 'TIME' },
        { name: 'page', type: 'STRING' },
        { name: 'added', type: 'NUMBER' },
        { name: 'unique_user', special: 'unique' }
      ]);

      var dataCube1 = dataCubeStub.fillAllFromAttributes(attributes1);
      expect(dataCube1.toJS()).to.deep.equal({
        "name": "wiki",
        "title": "Wiki",
        "description": "",
        "clusterName": "druid",
        "source": "wiki",
        "refreshRule": {
          "rule": "realtime"
        },
github allegro / turnilo / src / common / models / data-cube / data-cube.mocha.ts View on Github external
it("adds new dimensions", () => {
      var columns: any = [
        { name: "__time", type: "TIME" },
        { name: "added", makerAction: { action: "sum", expression: { name: "added", op: "ref" } }, type: "NUMBER", unsplitable: true },
        { name: "count", makerAction: { action: "count" }, type: "NUMBER", unsplitable: true },
        { name: "delta_hist", special: "histogram", type: "NUMBER" },
        { name: "page", type: "STRING" },
        { name: "page_unique", special: "unique", type: "STRING" }
      ];

      var dataCube1 = dataCube.addAttributes(AttributeInfo.fromJSs(columns));

      expect(dataCube1.toJS().dimensions).to.deep.equal([
        {
          kind: "time",
          name: "__time",
          title: "Time",
          formula: "$__time"
        },
        {
          kind: "string",
          name: "page",
          title: "Page",
          formula: "$page"
        }
      ]);
github allegro / turnilo / src / common / models / data-cube / data-cube.mocha.ts View on Github external
it("works with existing dimension", () => {
      var attributes1 = AttributeInfo.fromJSs([
        { name: "__time", type: "TIME" },
        { name: "added", type: "NUMBER" },
        { name: "added!!!", type: "NUMBER" },
        { name: "deleted", type: "NUMBER" }
      ]);

      var dataCubeWithDim = DataCube.fromJS({
        name: "wiki",
        title: "Wiki",
        clusterName: "druid",
        source: "wiki",
        subsetFormula: null,
        introspection: "autofill-all",
        defaultTimezone: "Etc/UTC",
        refreshRule: {
          rule: "realtime"
github geo-opensource / pivot / src / client / modals / data-cube-seed-modal / data-cube-seed-modal.tsx View on Github external
(resp) => {
          var attributes = AttributeInfo.fromJSs(resp.attributes);
          if (autoFill) {
            newDataCube = newDataCube.fillAllFromAttributes(attributes);
          } else {
            newDataCube = newDataCube.changeAttributes(attributes);
          }

          this.loadingDelegate.stop();
          this.props.onNext(newDataCube);
        },
        (xhr: XMLHttpRequest) => {
github allegro / turnilo / src / common / models / data-cube / data-cube.ts View on Github external
if (!parameters.name) throw new Error("DataCube must have a name");

    const introspection = parameters.introspection;
    if (introspection && DataCube.INTROSPECTION_VALUES.indexOf(introspection) === -1) {
      throw new Error(`invalid introspection value ${introspection}, must be one of ${DataCube.INTROSPECTION_VALUES.join(", ")}`);
    }

    const refreshRule = parameters.refreshRule ? RefreshRule.fromJS(parameters.refreshRule) : null;

    let timeAttributeName = parameters.timeAttribute;
    if (cluster && cluster.type === "druid" && !timeAttributeName) {
      timeAttributeName = "__time";
    }
    const timeAttribute = timeAttributeName ? $(timeAttributeName) : null;

    const attributeOverrides = AttributeInfo.fromJSs(parameters.attributeOverrides || []);
    const attributes = AttributeInfo.fromJSs(parameters.attributes || []);
    let derivedAttributes: Record = null;
    if (parameters.derivedAttributes) {
      derivedAttributes = Expression.expressionLookupFromJS(parameters.derivedAttributes);
    }

    let dimensions: Dimensions;
    let measures: Measures;
    try {
      dimensions = Dimensions.fromJS(parameters.dimensions || []);
      measures = Measures.fromJS(parameters.measures || []);

      if (timeAttribute && !dimensions.getDimensionByExpression(timeAttribute)) {
        dimensions = dimensions.prepend(new Dimension({
          name: timeAttributeName,
          kind: "time",
github hortonworks / streamline / pivot / src / client / applications / pivot-application / pivot-application.tsx View on Github external
(resp) => {
              var attributes = AttributeInfo.fromJSs(resp.attributes);
              c_newDataCube = c_newDataCube.fillAllFromAttributes(attributes);
              cubesArr.push(c_newDataCube);
              var o = { cubesArr, sources, appSettings };
              this.makeFinalCall(o);
            },
            (xhr: XMLHttpRequest) => {
github geo-opensource / pivot / src / client / views / settings-view / settings-view.tsx View on Github external
.then((resp) => {
      var attributes = AttributeInfo.fromJSs(resp.attributes);
      return dataCube.fillAllFromAttributes(attributes);
    });
}
github geo-opensource / pivot / src / client / views / settings-view / data-table / data-table.tsx View on Github external
(resp) => {
          if (!this.mounted) return;

          this.loadingDelegate.stop();
          this.setState({
            attributeSuggestions: dataCube.filterAttributes(AttributeInfo.fromJSs(resp.attributes))
          });
        },
        (xhr: XMLHttpRequest) => {
github allegro / turnilo / src / client / views / settings-view / data-cube-edit / data-cube-edit.tsx View on Github external
        stringToValue={(str: string) => str ? AttributeInfo.fromJSs(JSON.parse(str)) : undefined}
        type="textarea"
github allegro / turnilo / src / common / models / data-cube / data-cube.ts View on Github external
const introspection = parameters.introspection;
    if (introspection && DataCube.INTROSPECTION_VALUES.indexOf(introspection) === -1) {
      throw new Error(`invalid introspection value ${introspection}, must be one of ${DataCube.INTROSPECTION_VALUES.join(", ")}`);
    }

    const refreshRule = parameters.refreshRule ? RefreshRule.fromJS(parameters.refreshRule) : null;

    let timeAttributeName = parameters.timeAttribute;
    if (cluster && cluster.type === "druid" && !timeAttributeName) {
      timeAttributeName = "__time";
    }
    const timeAttribute = timeAttributeName ? $(timeAttributeName) : null;

    const attributeOverrides = AttributeInfo.fromJSs(parameters.attributeOverrides || []);
    const attributes = AttributeInfo.fromJSs(parameters.attributes || []);
    let derivedAttributes: Record = null;
    if (parameters.derivedAttributes) {
      derivedAttributes = Expression.expressionLookupFromJS(parameters.derivedAttributes);
    }

    let dimensions: Dimensions;
    let measures: Measures;
    try {
      dimensions = Dimensions.fromJS(parameters.dimensions || []);
      measures = Measures.fromJS(parameters.measures || []);

      if (timeAttribute && !dimensions.getDimensionByExpression(timeAttribute)) {
        dimensions = dimensions.prepend(new Dimension({
          name: timeAttributeName,
          kind: "time",
          formula: timeAttribute.toString()