簡體   English   中英

CubeJs 預聚合索引編譯失敗

[英]CubeJs Preaggregation index fail to compile

我想在我的匯總預聚合多維數據集 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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM