cube.js 一些预聚合分区新特性
主要介绍cube.js 支持的一些rollup 分区特性
基于时间的
- time 分区
参考
cube(`Orders`, {
sql: `select * from orders`,
//...
preAggregations: {
categoryAndDate: {
type: `rollup`,
external: true,
measureReferences: [Orders.count, revenue],
dimensionReferences: [category],
timeDimensionReference: createdAt,
granularity: `day`,
partitionGranularity: `month`,
},
},
});
- segment 模式的
cube(`Orders`, {
sql: `select * from orders`,
segments: {
toys: {
sql: `category = 'toys'`,
},
},
preAggregations: {
categoryAndDate: {
type: `rollup`,
external: true,
measureReferences: [Orders.count, revenue],
segmentReferences: [toys],
timeDimensionReference: createdAt,
granularity: `day`,
partitionGranularity: `month`,
},
},
});
说明
cube.js 对与预聚合的支持还是很多的,而且特性也比较多,以上只是关于数据分片的简单说明,详细的可以参考官方文档
参考资料
https://cube.dev/docs/pre-aggregations#rollup-time-partitioning