展达OLAP框架说明

Cube

Fact Table

  • table name
  • fact table filter

Fact

  • fact name
  • calculation
  • fact filter

Dimension

  • dimension name
  • dimension table
  • key
  • foreign key
  • join type
  • dimension filter

Level

  • level name
  • level label
  • level key
  • level order

OlapReporter#report函数

  • cube
  • facts string
  • levels string
  • runtime filter

Example

Order Table

id price cost customer_id sale_date status
1 1520 1023 93 2017-05-03 6
2 2785 1972 1172 2017-05-03 6
3 582 179 11237 2017-05-03 8

Customer Table

id customer_name is_internal city province country
1 张三 T 杭州 浙江 中国
2 李四 F 上海 上海 中国
3 王五 F 洛杉矶 加利福尼亚 美国

Date Table

date day month year
2015-01-01 1 1 2015
2015-01-02 2 1 2015
2015-01-03 3 1 2015

Fact

语法

avg|sum|count|max|min(fact_field)

说明

Fact的计算,要求只做一次统计预算,fact_field是已有的字段。不允许在统计操作符里再做额外的计算。例如sum(case when enter_type = 1 then 1 then 0 end)是不允许的。这就要求有计算字段(computed field),而且已经提前计算好。计算字段的方式可以有两种方式实现:

  • ETL
  • 数据库里的视图(View)
    视图方案更轻量,优先考虑。

Dimension

例子

{ "dimension_name": "sa", "table": "employee_buser", "key": "id", "foreign_key": "sa_id", "levels": [{ "name": "sa_level", "label": "b_user_name", "key": "id", "order": 1 }, { "name": "section_level", "label": "section_name", "key": "section_id", "order": 2 }] }

说明

dimension因为包含levels,比较复杂,所以采用json的格式。注意:除了foreign_key是fact的字段,其他的都是dimension的字段


Filter

语法

dimension_name:level_name operator value AND|OR ...
或者
fact_field operator value AND|OR

例子

sa:sa_level in (35,47,56)
created_time_dimension:month = '2017-04'
order_status != (8)

说明

operator支持以下操作符

  • =
  • >=
  • <
  • <=
  • !=
  • in
  • not in
  • is null
  • is not null
    注意 在实现dimension的filter时,和value比较的是level_key,而非level_label
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 135,087评论 19 139
  • 【导读】:小白创业失败,重新启航进入LED行业项目销售,开始寸步难行,幸得高手指点,苦练三十六计,利用人情做透四招...
    _大道无形_阅读 441评论 2 1
  • 独自的生活于蓝天之下,欢快的唱着悲伤的歌, 坚强的挺立于大地之上,不舍的看着悲伤的叶 树不舍,但不留,叶不舍,但不...
    迁的邂逅阅读 289评论 0 1