cube.js 预聚合处理

cube.js 的预聚合处理是cube.js 比较吸引人的一个地方,同时cube.js 也支持外部模式的数据预聚合处理
以下是一个参考试用

环境准备

  • docker-compose
 
version: '3'
services:
  pg: 
    image: postgres:12
    environment:
      - "POSTGRES_PASSWORD=dalong"
    ports:
    - "5432:5432"
  cubestorage:
    image:  cubejs/cubestore:build-100
    ports:
    - "3306:3306" 
  • 创建一个pg 的查询处理
npx cubejs-cli create pre-age -d postgres 
  • 添加cubestore驱动
yarn add @cubejs-backend/cubestore-driver --dev
  • 创建pg 的测试表
docker-compose up -d
CREATE TABLE demoapp (
    id SERIAL PRIMARY KEY,
    name text
);

一些问题

  • pre-age 数据存储位置
    默认是在源数据的,所以需要源数据有读写权限,但是有写场景就是没有的(比如基于大数据的查询引擎)
    解决方法,源数据添加readOnly: true, pg 源数据的预聚合处理结构,但是目前如果集成cubestore 会有一些问题
    数据类型支持的问题(比如奇怪,默认是可以写入的,但是全部到cubestore就有问题了),参考信息

     

     


     

     

  • provider 问题
    因为使用了cubestorage cube 自己开发的外部预聚合处理框架,存在此问题

 

 


实际上这个问题是关于schema 的问题,我们需要指定查询的sql schema
schema 查询,注意dev 以及prod是不一样的

 
show schemas

 

 


查询tables

 
show tables;

 

 


查询数据

 
select * from dev_pre_aggregations.demoapp_mydemo_y5h2jiat_mxrifsrp_1g09tl
 

 

 

参考资料

https://github.com/cube-js/cube.js/tree/master/rust
https://cube.dev/docs/pre-aggregations
https://cube.dev/docs/connecting-to-the-database#configuring-a-connection-to-an-external-database
https://github.com/cube-js/cube.js/issues/1796
https://github.com/rongfengliang/cubejs-pre-age

posted on   荣锋亮  阅读(291)  评论(0编辑  收藏  举报

编辑推荐:
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
阅读排行:
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 单元测试从入门到精通
· 上周热点回顾(3.3-3.9)
· winform 绘制太阳,地球,月球 运作规律
历史上的今天:
2020-01-18 electron 7 typescript @types/node v13 问题
2020-01-18 actix rust actor 框架学习 二 ping actor demo 代码
2020-01-18 actix rust actor 框架学习 一 基本试用
2019-01-18 gearman openresty 集成试用
2019-01-18 madlib 集成 hasura graphql-engine 试用
2019-01-18 gearman kubernetes 运行
2019-01-18 gearman 简单试用

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
点击右上角即可分享
微信分享提示