cube.js 学习(七)cube.js type 以及format 说明
cube.js 对于measure以及dimension 提供了丰富的数据类型,基本满足我们常见应用的开发,同时对于不同类型也提供了
格式化的操作
measure类型
number
- 格式
purchasesRatio: {
sql: `${purchases} / ${count} * 100.0`,
type: `number`,
format: `percent`
}
count
- 格式
numerOfUsers: {
type: `count`,
// optional
drillMembers: [id, name, email, company]
}
countDistinct
类似sql 的count distinct
- 格式
uniqueUserCount: {
sql: `user_id`,
type: "countDistinct"
}
countDistinctApprox
字面意思是countDistinct 的添加剂,同时和countDistinct 不一样,他是利用rollup-pre-aggregations,后端利用
hll或者类似的算法,加速数据的计算
- 格式
uniqueUserCount: {
sql: `user_id`,
type: "countDistinctApprox"
}
sum
类似sql 的sum,但是与原生sql 不同,他将正确的计算数据,尽管连接可能导致数据重复
- 格式
revenue: {
sql: `amount`,
type: `sum`
}
avg
类似sql 的avg 进行平均数的计算,但是与原生sql 不同,他将正确的计算数据,尽管连接可能导致数据重复
- 格式
averageTransaction: {
sql: `${transactionAmount}`,
type: `avg`
}
min
- 格式
dateFirstPurchase: {
sql: `date_purchase`,
type: `min`
}
max
- 格式
dateLastPurchase: {
sql: `date_purchase`,
type: `max`
}
runningTotal
计算概述sql 中的值
- 格式
totalSubscriptions: {
sql: `subscription_amount`,
type: `runningTotal`
}
measure格式化
百分比
- 格式
purchaseConversion: {
sql: `${purchase}/${checkout}*100.0`,
type: `number`,
format: `percent`
}
货币
- 格式
totalAmount: {
sql: `amount`,
type: `runningTotal`,
format: `currency`
}
dimension 类型
time
- 格式
completedAt: {
sql: `completed_at`,
type: `time`
}
string
- 格式
fullName: {
sql: `CONCAT(${firstName}, ' ', ${lastName})`,
type: `string`
}
number
- 格式
amount: {
sql: `amount`,
type: `number`
}
geo
- 格式
location: {
type: `geo`,
latitude: {
sql: `${TABLE}.latitude`,
},
longitude: {
sql: `${TABLE}.longitude`
}
}
dimension 格式
imageUrl
- 格式
image: {
sql: `CONCAT('https://img.example.com/id/', ${id})`,
type: `string`,
format: `imageUrl`
}
id
- 格式
image: {
sql: `id`,
type: `number`,
format: `id`
}
link
- 格式
orderLink: {
sql: `'http://myswebsite.com/orders/' || id`,
type: `string`,
format: `link`
}
crmLink: {
sql: `'https://na1.salesforce.com/' || id`,
type: `string`,
format: {
label: `View in Salesforce`,
type: `link`
}
}
货币
- 格式
amount: {
sql: `abount`,
type: `number`,
format: `currency`
}
百分比
- 格式
penRate: {
sql: `COALESCE(100.0 * ${uniqOpenCount} / NULLIF(${deliveredCount}, 0), 0)`,
type: `number`,
format: `percent`
}
参考资料
https://cube.dev/docs/types-and-formats
cube.js 学习(七)cube.js type 以及format 说明的更多相关文章
- Node.js学习笔记——Node.js开发Web后台服务
一.简介 Node.js 是一个基于Google Chrome V8 引擎的 JavaScript 运行环境.Node.js 使用了一个事件驱动.非阻塞式 I/O 的模型,使其轻量又高效.Node.j ...
- Sea.js学习4——Sea.js的配置
可以对 Sea.js 进行配置,让模块编写.开发调试更方便. seajs.config seajs.config(options) 用来进行配置的方法. seajs.config({ // 别名配置 ...
- Node.js学习(Node.js基础)
1.开发环境搭建 v8引擎是作为解析JavaScript程序来运行的 nodejs是一个高性能的,第一个体现在他的JavaScript解析速度很快,v8引擎性能很高,第二个事件驱动和非阻塞 2.全局对 ...
- Sea.js学习5——Sea.js的构建工具spm
如果项目遵循推荐的标准目录结构: foo-module/ |-- dist 存放构建好的文件 |-- src 存放 js.css 等源码 | |-- foo.js | `-- style.css `- ...
- Sea.js学习3——Sea.js的CMD 模块定义规范
在 Sea.js 中,所有 JavaScript 模块都遵循 CMD(Common Module Definition) 模块定义规范.该规范明确了模块的基本书写格式和基本交互规则. 在 CMD 规范 ...
- Sea.js学习2——Sea.js的API 快速参考
(7 个接口是最常用的) 一.seajs.config:用来对 Sea.js 进行配置. seajs.config({ // 设置路径,方便跨目录调用 paths: { 'arale': 'https ...
- [node.js学习]为node.js写的一个操作mysql的类
不支持一个对象在不同异步中使用,模仿的php框架 speedphp中的model模块 GaryMysql.js var mysql = require('mysql'); var pool = nul ...
- js学习之原生js实现懒加载
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title&g ...
- cube.js 学习(十一)cube + gitbase 分析git 代码
这个是一个简单的demo,使用gitbase+cube 分析git 仓库代码 需求 我们平时使用的gitlab,或者gogs 等git 仓库管理工具,有自己的管理强项,但是对于分析上可能就不是那么强大 ...
随机推荐
- Scratch编程:贪吃鱼(十一)
“ 上节课的内容全部掌握了吗?反复练习了没有,编程最好的学习方法就是练习.练习.再练习.一定要记得多动手.多动脑筋哦~~” 01 — 游戏介绍 这是一个小游戏,通过键盘的方向键控制着大鲨鱼追着吃掉海星 ...
- ColorMatrixFilter色彩矩阵滤镜
ColorMatrixFilter色彩矩阵滤镜: /** * * *----------------------------------------* * | *** ColorMatrixFilte ...
- BUAA OO 2019 第三单元作业总结
目录 总 JML规格化设计 理论基础 工具链 规格验证 验证代码 代码静态检查 自动生成测试样例 生成结果 错误分析 作业设计 第九次作业 架构 代码实现 第十次作业 架构 代码实现 第十一次作业 架 ...
- input中blur失去焦点事件与点击事件冲突时如何解决
方法一 使用setTimeout $(function(){ $(".cy-name-input input").on({ focus:function() { $(". ...
- VS2017 Git failed with a fatal error. error: open(".vs/xxxxxx/v15/Server/sqlite3/db.lock"): Permission denied fatal: Unable to process path .vs/xxxxxx/v15/Server/sqlite3/db.lock
具体错误信息:Git failed with a fatal error. error: open(".vs/xxxxxx/v15/Server/sqlite3/db.lock") ...
- Part_one:Redis第一次接触
1.redis学习 数据默认写入到内存,如果断电,服务器宕机,redis进程挂掉,数据会丢失. selenium操作浏览器时,要注意浏览器资源释放,方式内存泄露,崩溃 mysql是文件型数据库,默认持 ...
- JavaScript之控制标签内容
function abb(a){ return document.getElementById(a); } console.log(abb('box').innerHTML); 标签.innerHTM ...
- git提交代码并将develop分支合并到master分支上
提交合并代码流程: git add .git commit -m ''git pushgit checkout mastergit merge develop //将develop 分支与master ...
- DRF 筛选
from rest_framework.generics import ListAPIView,CreateAPIView,UpdateAPIView,RetrieveAPIView,DestroyA ...
- python selenium八大定位方法
一.定位方法 注意:元素属性必须唯一存在 #id定位 find_element_by_id() #name定位 find_element_by_name() #class_name定位 find_el ...