greptimedb-flow

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

GreptimeDB Flow Guide

GreptimeDB Flow 指南

Create GreptimeDB flow definition to do time window based aggregation on the fly while data ingested into GreptimeDB. This is how GreptimeDB's lightweight streaming engine works.
Flow is also known as:
  1. Stream computing
  2. Materialized View
  3. Continuous aggregation
创建GreptimeDB流定义,以便在数据写入GreptimeDB时,实时执行基于时间窗口的聚合操作。这就是GreptimeDB轻量级流处理引擎的工作方式。
Flow也被称为:
  1. 流计算
  2. Materialized View(物化视图)
  3. Continuous Aggregation(持续聚合)

The workflow

工作流程

To create GreptimeDB flow task, we should follow these phases:
要创建GreptimeDB流任务,需遵循以下阶段:

Phase 1. Learn and understand GreptimeDB Flow

阶段1:学习并理解GreptimeDB Flow

First, we read GreptimeDB flow definitions and how it works from the documentation.
There are doc pages available, use WebFetch to load and understand them:
  1. Overview and quick example: https://docs.greptime.com/user-guide/flow-computation/overview/
  2. Examples for continuous aggregation: https://docs.greptime.com/user-guide/flow-computation/continuous-aggregation/
  3. SQL DDL for flow, sink table and related concepts: https://docs.greptime.com/user-guide/flow-computation/manage-flow/
首先,我们从官方文档中学习GreptimeDB流的定义及其工作原理。
可通过WebFetch加载以下文档页面进行学习:
  1. 概述与快速示例: https://docs.greptime.com/user-guide/flow-computation/overview/
  2. 持续聚合示例: https://docs.greptime.com/user-guide/flow-computation/continuous-aggregation/
  3. 流、目标表及相关概念的SQL DDL: https://docs.greptime.com/user-guide/flow-computation/manage-flow/

Phase 2. Create flow tasks

阶段2:创建流任务

We should try to understand:
  1. time window the user wants to use
  2. aggregation fields and group-by rules
Create the flow and sink table DDL. Note that we will always provide
CREATE TABLE
statement for sink table, together with the
CREATE FLOW
statement because it's required.
我们需要明确:
  1. 用户想要使用的时间窗口
  2. 聚合字段与分组规则
创建流和目标表的DDL语句。请注意,我们需要同时提供目标表的
CREATE TABLE
语句和流的
CREATE FLOW
语句,因为这是必填要求。

Phase 3. Verify the tasks

阶段3:验证任务

If greptimedb-mcp-server is available, we can use its
execute_sql
tools to execute the DDL. Try to generate some sample data, insert into source table, then verify the sink table via SQL SELECT statements. We can use MySQL style SELECT statements on GreptimeDB for most cases.
如果greptimedb-mcp-server可用,我们可以使用其
execute_sql
工具执行DDL语句。尝试生成一些示例数据并插入源表,然后通过SQL SELECT语句验证目标表的数据。大多数情况下,我们可以在GreptimeDB上使用MySQL风格的SELECT语句。

Reference

参考资料