Kylin - 分析数据

简介: I. Create a Project Go to Query page in top menu bar, then click Manage Projects.


I. Create a Project

  1. Go to Query page in top menu bar, then click Manage Projects.

  2. Click the + Project button to add a new project.

  3. Enter a project name, e.g, “Tutorial”, with a description (optional), then click submit button to send the request.

  4. After success, the project will show in the table.

II. Sync up Hive Table

  1. Click Model in top bar and then click Data Source tab in the left part, it lists all the tables loaded into Kylin; click Load Hive Table button.

  2. Enter the hive table names, separated with commad, and then click Sync to send the request.

  3. [Optional] If you want to browser the hive database to pick tables, click the Load Hive Table From Tree button.

  4. [Optional] Expand the database node, click to select the table to load, and then click Sync.

  5. A success message will pop up. In the left Tables section, the newly loaded table is added. Click the table name will expand the columns.

  6. In the background, Kylin will run a MapReduce job to calculate the approximate cardinality for the newly synced table. After the job be finished, refresh web page and then click the table name, the cardinality will be shown in the table info.

III. Create Data Model

Before create a cube, need define a data model. The data model defines the star schema. One data model can be reused in multiple cubes.

  1. Click Model in top bar, and then click Models tab. Click +New button, in the drop-down list select New Model.

  2. Enter a name for the model, with an optional description.

  3. In the Fact Table box, select the fact table of this data model.

  4. [Optional] Click Add Lookup Table button to add a lookup table. Select the table name and join type (inner or left).

  5. [Optional] Click New Join Condition button, select the FK column of fact table in the left, and select the PK column of lookup table in the right side. Repeat this if have more than one join columns.

  6. Click “OK”, repeat step 4 and 5 to add more lookup tables if any. After finished, click “Next”.

  7. The “Dimensions” page allows to select the columns that will be used as dimension in the child cubes. Click the Columns cell of a table, in the drop-down list select the column to the list.

  8. Click “Next” go to the “Measures” page, select the columns that will be used in measure/metrics. The measure column can only from fact table.

  9. Click “Next” to the “Settings” page. If the data in fact table increases by day, select the corresponding date column in the Partition Date Column, and select the date format, otherwise leave it as blank.

  10. [Optional] Select Cube Size, which is an indicator on the scale of the cube, by default it is MEDIUM.

  11. [Optional] If some records want to excluded from the cube, like dirty data, you can input the condition in Filter.

  12. Click Save and then select Yes to save the data model. After created, the data model will be shown in the left Models list.

IV. Create Cube

After the data model be created, you can start to create cube.

Click Model in top bar, and then click Models tab. Click +New button, in the drop-down list select New Cube.

Step 1. Cube Info

Select the data model, enter the cube name; Click Next to enter the next step.

You can use letters, numbers and ‘_’ to name your cube (blank space in name is not allowed). Notification List is a list of email addresses which be notified on cube job success/failure.

Step 2. Dimensions

  1. Click Add Dimension, it popups two option: “Normal” and “Derived”: “Normal” is to add a normal independent dimension column, “Derived” is to add a derived dimension column. Read more in How to optimize cubes.

  2. Click “Normal” and then select a dimension column, give it a meaningful name.

  3. [Optional] Click “Derived” and then pickup 1 more multiple columns on lookup table, give them a meaningful name.

  4. Repeate 2 and 3 to add all dimension columns; you can do this in batch for “Normal” dimension with the button Auto Generator.

  5. Click “Next” after select all dimensions.

Step 3. Measures

  1. Click the +Measure to add a new measure.

  2. There are 6 types of measure according to its expression: SUM, MAX, MIN, COUNT, COUNT_DISTINCT and TOP_N. Properly select the return type for COUNT_DISTINCT and TOP_N, as it will impact on the cube size.

    • SUM

    • MIN

    • MAX

    • COUNT

    • DISTINCT_COUNT
      This measure has two implementations:
      a) approximate implementation with HyperLogLog, select an acceptable error rate, lower error rate will take more storage.
      b) precise implementation with bitmap (see limitation in https://issues.apache.org/jira/browse/KYLIN-1186).

    Pleaste note: distinct count is a very heavy data type, it is slower to build and query comparing to other measures.

    • TOP_N
      Approximate TopN measure pre-calculates the top records in each dimension combination, it will provide higher performance in query time than no pre-calculation; Need specify two parameters here: the first is the column will be used as metrics for Top records (aggregated with SUM and then sorted in descending order); the second is the literal ID, represents the record like seller_id;

    Properly select the return type, depends on how many top records to inspect: top 10, top 100 or top 1000.

Step 4. Refresh Setting

This step is designed for incremental cube build.

Auto Merge Time Ranges (days): merge the small segments into medium and large segment automatically. If you don’t want to auto merge, remove the default two ranges.

Retention Range (days): only keep the segment whose data is in past given days in cube, the old segment will be automatically dropped from head; 0 means not enable this feature.

Partition Start Date: the start date of this cube.

Step 5. Advanced Setting

Aggregation Groups: by default Kylin put all dimensions into one aggregation group; you can create multiple aggregation groups by knowing well about your query patterns. For the concepts of “Mandatory Dimensions”, “Hierarchy Dimensions” and “Joint Dimensions”, read this blog: New Aggregation Group

Rowkeys: the rowkeys are composed by the dimension encoded values. “Dictionary” is the default encoding method; If a dimension is not fit with dictionary (e.g., cardinality > 10 million), select “false” and then enter the fixed length for that dimension, usually that is the max. length of that column; if a value is longer than that size it will be truncated. Please note, without dictionary encoding, the cube size might be much bigger.

You can drag & drop a dimension column to adjust its position in rowkey; Put the mandantory dimension at the begining, then followed the dimensions that heavily involved in filters (where condition). Put high cardinality dimensions ahead of low cardinality dimensions.

Step 6. Overview & Save

You can overview your cube and go back to previous step to modify it. Click the Save button to complete the cube creation.

目录
相关文章
|
安全 算法 区块链
花无涯带你走进黑客世界之Tor洋葱网络
Tor本来是为用户提供匿名上网保护用户隐私的工具,但是对于一些用户来说,他们可以利用Tor的隐蔽性进行黑客攻击或非法交易活动。总结Tor的恶意应用主要表现在以下几方面。
1226 0
|
SQL 关系型数据库 MySQL
Flink CDC 2.0 正式发布,详解核心改进
Flink CDC 2.0.0 版本于 8 月 10 日正式发布,点击了解详情~
Flink CDC 2.0 正式发布,详解核心改进
|
12月前
|
JSON Java API
解锁高性能并发:Java 虚拟线程实战指南
解锁高性能并发:Java 虚拟线程实战指南
495 117
|
8月前
|
人工智能 JSON BI
DeepSeek V4 来了!超越 Claude Sonnet 4.5,赶紧对接 Claude Code 体验一把
JeecgBoot AI专题研究 把 Claude Code 接入 DeepSeek V4Pro 的真实体验与避坑记录 本文记录我将 Claude Code 对接 DeepSeek 最新模型(V4Pro)后的真实体验,测试了 Skills 自动化查询和积木报表 AI 建表两个场景——有惊喜,也踩
11296 21
|
7月前
|
边缘计算 安全 网络安全
AIWCLOUD:高防CDN在金融级业务场景下的零信任防护架构
本文介绍金融级高防CDN:融合零信任架构、边缘计算与AI行为分析,实现身份化访问控制、加密流量无感清洗及边缘Bot防护,在保障业务连续性与数据隐私前提下,达成“防得住、通得快”的双重目标。(239字)
247 5
|
11月前
|
API Apache
OPIK:一个开源的自动提示词优化框架
本文介绍如何用OPIK的MetaPromptOptimizer实现自动提示词优化,通过几轮迭代将大模型在复杂推理任务上的准确率从34%提升至97%。详解环境搭建、代码实现及优缺点,展示如何让LLM自我改进提示词,大幅提升效率与性能,推动提示工程迈向自动化。
1183 2
|
数据采集 数据处理 数据安全/隐私保护
小红书爬虫采集工具, 小红书截流获客软件,直播间评论作品提取软件
这个项目包含三个主要模块:爬虫核心、数据处理和代理管理。使用时需要安装requests
|
存储 算法 数据处理
进程基础:概念、状态与生命周期
进程是操作系统进行资源分配和调度的基本单位,由程序段、数据段和进程控制块(PCB)组成。线程是进程中更小的执行单元,能独立运行且共享进程资源,具有轻量级和并发性特点。进程状态包括就绪、运行和阻塞,其生命周期分为创建、就绪、运行、阻塞和终止阶段。
1247 2
|
C语言 索引 编译器
【植物大战僵尸杂交版】致敬传奇游戏玩家——一个普通人的六年坚持
【植物大战僵尸杂交版】致敬传奇游戏玩家——一个普通人的六年坚持