【问题标题】:CubeJs Preaggregation index fail to compileCubeJs 预聚合索引编译失败
【发布时间】:2020-12-10 16:34:00
【问题描述】:

我想在我的汇总预聚合多维数据集 js 表上放置一个索引:

  preAggregations: {
    projectDate: {
      type: `rollup`,
      measureReferences: [count, amount],
      dimensionReferences: [state, Projects.slug],
      timeDimensionReference: confirmedAt,
      granularity: `day`,
      refreshKey: {
        every: '1 day'
      },
      indexes: {
        main: {
          columns: [state]
        }
      }
    },
  }

但是,多维数据集没有编译,我收到以下错误:

Error: Compile errors:
ShopperOrders.js:84
          columns: [state]
                    ^

ReferenceError: state is not defined
    at ShopperOrders.js:84:21
    at Script.runInContext (vm.js:127:20)
    at Script.runInNewContext (vm.js:133:17)
    at Object.runInNewContext (vm.js:299:38)
    at DataSchemaCompiler.compileFile

我的state 维度定义明确,当我删除索引时预聚合有效。这是架构:

cube(`ShopperOrders`, {
  sql: `SELECT * FROM shopper_orders`,

  joins: {
    ShopperOrderLines: {
      sql: `${CUBE}.id = ${ShopperOrderLines}.order_id`,
      relationship: `hasMany`
    }
  },

  measures: {
    count: {
      type: `count`
    },

    amount: {
      sql: `amount`,
      type: `sum`
    },
  },

  dimensions: {
    id: {
      sql: `id`,
      type: `number`,
      primaryKey: true
    },

    state: {
      sql: `state`,
      type: `string`
    },

    confirmedAt: {
      sql: `confirmed_at`,
      type: `time`
    }
  },

  preAggregations: {
    projectDate: {
      type: `rollup`,
      measureReferences: [count, amount],
      dimensionReferences: [state, Projects.slug],
      timeDimensionReference: confirmedAt,
      granularity: `day`,
      refreshKey: {
        every: '1 day'
      },
      index: {
        main: {
          columns: [state]
        }
      }
    },
  }
});

你知道我可能错误地声明或遗漏了什么吗?

我使用了文档中给出的示例: https://cube.dev/docs/pre-aggregations#indexes

【问题讨论】:

  • 在这里分享整个 Cube.js 架构会很有帮助。
  • 我编辑了问题以共享 Cube.js 架构
  • 您好,请检查您的架构的有效性。我怀疑问题可能是您需要使用indexes参数而不是index
  • 我也尝试了indexes,但结果相同。

标签: indexing cube.js


【解决方案1】:

能否请您更新版本并重试? 我几乎可以肯定您使用的是旧版本的 cube.js

【讨论】:

  • 我将我的 Cube 软件包版本从 0.15.0 升级到 0.20.0,它就像一个魅力!谢谢!
猜你喜欢
  • 2014-03-15
  • 1970-01-01
  • 1970-01-01
  • 2015-02-04
  • 2012-11-29
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多