Skip to content

Commit 522580c

Browse files
committed
feature:init master code
1 parent bbbb52f commit 522580c

File tree

1,211 files changed

+131576
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,211 files changed

+131576
-0
lines changed

README.md

+152
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
# Fast Modeling Language
2+
3+
FML(Fast Modeling Language) 用于维度建模领域快速构建的一门类SQL语言。主要目标是提供一套kimball维度建模理论下,结合大数据开发场景下的一种领域特定语言。
4+
FML采用了类SQL的语言方式, 创建表语法是参考了SQL标准语法,并有自己的扩展。 FML是一种模型设计语言,期望做到设计与实现解耦,在设计过程中,不用特别考虑各个大数据引擎的实现方式。
5+
建模引擎会根据FML定义的Schema去驱动底层各个数据引擎的执行和操作。用户在使用FML时,并不需要特别关注底层数据引擎的细节部分,只有在实际物化(将设计的表转换为底层引擎的物理表时)阶段,建模引擎会根据物化的选择,将FML语言,转换为数据引擎可识别的SQL语法,并提交任务节点执行。具体与各个数据引擎的转换,请参考
6+
FML Transformer。
7+
8+
### Features
9+
10+
* 一种支持维度建模的领域特定语言,类SQL语法。
11+
12+
* 支持数仓规划、字段标准、标准代码、指标等数仓建设中全流程的语法定义。
13+
14+
* 使用Java编写,可以方便的构造语法的节点API进行模型构建。
15+
16+
* 支持FML语法转换到常见引擎,如Hive, Hologres,Mysql 等Transform API.
17+
18+
* 提供基于JDBC Driver的方式,来使用FML语言来与模型引擎进行交互处理。
19+
20+
21+
22+
### Quick Start
23+
24+
```xml
25+
<dependencyManagement>
26+
<dependencies>
27+
<dependency>
28+
<groupId>com.aliyun.fastmodel</groupId>
29+
<artifactId>fastmodel-bom</artifactId>
30+
<version>${lastest}</version>
31+
<type>pom</type>
32+
<scope>import</scope>
33+
</dependency>
34+
</dependencies>
35+
</dependencyManagement>
36+
37+
<dependencies>
38+
<!-- core parser-->
39+
<dependency>
40+
<groupId>com.aliyun.fastmodel</groupId>
41+
<artifactId>fastmodel-core</artifactId>
42+
</dependency>
43+
<dependency>
44+
<groupId>com.aliyun.fastmodel</groupId>
45+
<artifactId>fastmodel-parser</artifactId>
46+
</dependency>
47+
48+
<!--transformer-->
49+
<dependency>
50+
<groupId>com.aliyun.fastmodel</groupId>
51+
<artifactId>fastmodel-transform-api</artifactId>
52+
</dependency>
53+
<dependency>
54+
<groupId>com.aliyun.fastmodel</groupId>
55+
<artifactId>fastmodel-transform-hive</artifactId>
56+
</dependency>
57+
58+
<dependency>
59+
<groupId>com.aliyun.fastmodel</groupId>
60+
<artifactId>fastmodel-transform-mysql</artifactId>
61+
</dependency>
62+
63+
<dependency>
64+
<groupId>com.aliyun.fastmodel</groupId>
65+
<artifactId>fastmodel-transform-hologres</artifactId>
66+
</dependency>
67+
</dependencies>
68+
```
69+
70+
### Parser Example
71+
72+
```java
73+
74+
import com.aliyun.fastmodel.core.parser.FastModelParser;
75+
import com.aliyun.fastmodel.core.parser.FastModelParserFactory;
76+
77+
public class HelloFML {
78+
79+
//单例
80+
private static final FastModelParser PARSER = FastModelParserFactory.getInstance()
81+
.get();
82+
83+
public static void main(String[] args) {
84+
String fml
85+
= "create dim table t_1 alias 'alias_name' (col bigint alias 'alias_name' comment 'col_comment') comment 'comment';";
86+
CreateDimTable createDimTable = PARSER.parseStatement(fml);
87+
//do your work
88+
}
89+
}
90+
91+
```
92+
93+
### Transformer Example
94+
95+
```java
96+
import com.aliyun.fastmodel.core.tree.BaseStatement;
97+
import com.aliyun.fastmodel.transform.api.Transformer;
98+
import com.aliyun.fastmodel.transform.api.TransformerFactory;
99+
import com.aliyun.fastmodel.transform.api.context.TransformContext;
100+
import com.aliyun.fastmodel.transform.api.dialect.DialectMeta;
101+
102+
public class HelloFMLTransformer {
103+
104+
public static void main(String[] args) {
105+
DialectMeta dialectMeta = DialectMeta.DEFAULT_HIVE;
106+
Transformer<BaseStatement> statementTransformer = TransformerFactory.getInstance()
107+
.get(dialectMeta);
108+
statementTransformer.transform(statement, context).getNode();
109+
}
110+
}
111+
```
112+
113+
## Building FML from Source
114+
115+
FML构建准备条件:
116+
117+
* Unix-like environment (we use Linux, Mac OS X, Cygwin, WSL)
118+
* Git
119+
* Maven (we recommend version 3.5.0+)
120+
* Java 8
121+
122+
```
123+
git clone [email protected]:alibaba/fast-modeling-language.git
124+
cd fast-modeling-language
125+
mvn clean package -DskipTests # this will take up to 10 minutes
126+
```
127+
128+
## Developing FML
129+
130+
FML提交者使用IntelliJ IDEA来开发FML代码库,我们推荐IntelliJ IDEA开发Java工程
131+
132+
IDE的最小支持集包括:
133+
134+
* 支持Java工程
135+
* 支持Maven
136+
137+
### IntelliJ IDEA
138+
139+
IntelliJ IDE 支持以下插件
140+
141+
* IntelliJ 下载地址: [https://www.jetbrains.com/idea/](https://www.jetbrains.com/idea/)
142+
* IntelliJ ANTLR
143+
插件地址: [https://plugins.jetbrains.com/plugin/7358-antlr-v4](https://plugins.jetbrains.com/plugin/7358-antlr-v4)
144+
145+
## Documentation
146+
147+
FML语法介绍可以在 `docs/` 目录查看源文件, docs编写使用了:`docsify` 进行文档管理,具体使用可以参考:
148+
[docsify quickstart](https://docsify.js.org/#/quickstart)
149+
150+
## Notice
151+
fast-modeling-language is a modeling DSL developed by Alibaba and licensed under the Apache License (Version 2.0) This product contains various third-party components under other open source licenses.
152+
See the NOTICE file for more information.

docs/.nojekyll

Whitespace-only changes.

docs/index.html

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<!--
2+
~ Copyright 2021-2022 Alibaba Group Holding Ltd.
3+
~
4+
~ Licensed under the Apache License, Version 2.0 (the "License");
5+
~ you may not use this file except in compliance with the License.
6+
~ You may obtain a copy of the License at
7+
~
8+
~ http://www.apache.org/licenses/LICENSE-2.0
9+
~
10+
~ Unless required by applicable law or agreed to in writing, software
11+
~ distributed under the License is distributed on an "AS IS" BASIS,
12+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
~ See the License for the specific language governing permissions and
14+
~ limitations under the License.
15+
-->
16+
17+
<!DOCTYPE html>
18+
<html lang="en">
19+
<head>
20+
<meta charset="UTF-8">
21+
<title>FML Document</title>
22+
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
23+
<meta name="description" content="Description">
24+
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0">
25+
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/docsify@4/lib/themes/vue.css">
26+
<!-- markmap is based on d3, so must load those files first. -->
27+
<script src="//unpkg.com/d3@3/d3.min.js"></script>
28+
<script src="//unpkg.com/[email protected]/lib/d3-flextree.js"></script>
29+
<script src="//unpkg.com/[email protected]/lib/view.mindmap.js"></script>
30+
</head>
31+
<body>
32+
<div id="app"></div>
33+
<script>
34+
window.$docsify = {
35+
name: 'Fast Modeling Language',
36+
repo: 'https://github.com/alibaba/fastmodel',
37+
loadSidebar: 'zh-cn/_sidebar.md',
38+
subMaxLevel: 2,
39+
plantuml: {
40+
skin: 'default',
41+
},
42+
homepage: 'zh-cn/guide.md',
43+
mindmap: {
44+
preset: 'colorful', // or default
45+
linkShape: 'diagonal' // or bracket
46+
},
47+
copyCode: {
48+
buttonText: 'Copy to clipboard',
49+
errorText: 'Error',
50+
successText: 'Copied'
51+
}
52+
}
53+
</script>
54+
<!-- Docsify v4 -->
55+
<script src="//cdn.jsdelivr.net/npm/docsify@4"></script>
56+
<script src="//cdn.jsdelivr.net/npm/docsify/lib/plugins/search.min.js"></script>
57+
<script src="//unpkg.com/docsify-plantuml/dist/docsify-plantuml.min.js"></script>
58+
<script src="//unpkg.com/docsify-mindmap/dist/docsify-mindmap.min.js"></script>
59+
<script src="//unpkg.com/docsify-copy-code@2"></script>
60+
</body>
61+
</html>

docs/zh-cn/_sidebar.md

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<!-- docs/_sidebar.md -->
2+
3+
* [首页](zh-cn/README.md)
4+
* [入门](zh-cn/guide.md)
5+
* [与SQL的差异](zh-cn/difference.md)
6+
* [基本元素](zh-cn/basic.md)
7+
* 数仓规划
8+
* [概述](zh-cn/layer/guide.md)
9+
* [数仓分层](zh-cn/layer/data_layer.md)
10+
* [业务分类](zh-cn/layer/business_category.md)
11+
* [数据域](zh-cn/layer/data_domain.md)
12+
* [业务过程](zh-cn/layer/business_process.md)
13+
* 维度建模
14+
* [表操作](zh-cn/model/table.md)
15+
* [列和约束](zh-cn/model/column.md)
16+
* [数据质量](zh-cn/model/quality.md)
17+
* [维度定义](zh-cn/model/dimension.md)
18+
* 数据标准
19+
* [数据标准](zh-cn/standard/standard_dict.md)
20+
* [标准代码](zh-cn/standard/code_table.md)
21+
* [度量单位](zh-cn/standard/measure_unit.md)
22+
* 指标管理
23+
* [原子指标](zh-cn/indicator/atomic.md)
24+
* [修饰词](zh-cn/indicator/adjunct.md)
25+
* [时间周期](zh-cn/indicator/time_period.md)
26+
* [派生指标](zh-cn/indicator/derivative.md)
27+
* 查询语句
28+
* [总览](zh-cn/query/guide.md)
29+
* 引用
30+
* [查看引用](zh-cn/references/show_references.md)
31+
* [移动引用](zh-cn/references/move_references.md)
32+
* 命令语句
33+
* [导入导出](zh-cn/command/impexp.md)
34+
* 逆向
35+
* [逆向建模](zh-cn/reverse/model.md)
36+
* 发布
37+
* [模型发布](zh-cn/publish/model.md)
38+
* DDL转换
39+
* [总览](zh-cn/transformer/guide.md)
40+
* [Hive](zh-cn/transformer/hive.md)
41+
* [Hologres](zh-cn/transformer/hologres.md)
42+
* [Mysql](zh-cn/transformer/mysql.md)
43+
* [Oracle](zh-cn/transformer/oracle.md)
44+
* [其他](zh-cn/transformer/other.md)
45+
* [比较](zh-cn/transformer/compare.md)
46+
* JDBC
47+
* [快速开始](zh-cn/jdbc/guide.md)
48+
* [CLI程序](zh-cn/jdbc/cli.md)
49+
* IDE
50+
* [IDE设计](zh-cn/ide/design.md)
51+
* 其他
52+
* [如何贡献](zh-cn/how-to-contribute.md)
53+
* [RoadMap](zh-cn/roadmap.md)

docs/zh-cn/basic.md

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
## 基本元素
2+
3+
FML支持建模95%场景的模型对象定义,每种的模型对象,在使用DDL定义时,会有相似的基本元素组成。
4+
5+
## 例子
6+
7+
先以一个基本的例子开始, 比如创建一个名为:example的维度表
8+
9+
```
10+
CREATE DIM TABLE example
11+
(
12+
name ALIAS 'Name' STRING COMMENT 'name comment'
13+
)
14+
COMMENT 'comment'
15+
WITH ('param' = 'value');
16+
```
17+
18+
## CODE-编码
19+
20+
模型对象的唯一标识, 支持全英文或者英文+数字组合的标识,支持多个单词以"."连接起来。
21+
22+
## ALIAS-别名
23+
24+
模型对象的别名,一般用于显示名,以单引号括起来作为字符字面量。
25+
26+
## COMMENT-备注
27+
28+
模型对象的备注。
29+
30+
## PROPERTY-扩展属性
31+
32+
模型对象的扩展属性,采用key-value的方式,key和value需要用单引号括起来。
33+
34+
## 业务对象英文表
35+
36+
| 单词 | 复数 | 说明 |
37+
|-------------------|---------------------|------|
38+
| ADJUNCT | ADJUNCTS | 修饰词 |
39+
| DICT | DICTS | 数据标准 |
40+
| LAYER | LAYERS | 数仓分层 |
41+
| BUSINESS_PROCESS | BUSINESS_PROCESSES | 业务过程 |
42+
| BUSINESS_CATEGORY | BUSINESS_CATEGORIES | 业务分类 |
43+
| MARKET | MARKETS | 数据集市 |
44+
| SUBJECT | SUBJECTS | 主题域 |
45+
| TABLE | TABLES | 表模型 |
46+
| INDICATOR | INDICATORS | 指标 |
47+
48+

docs/zh-cn/command/impexp.md

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
## 概览
2+
3+
| 命令 | 英文 | 说明 |
4+
|------|-------------|--------------------------|
5+
| 导入 | import_sql | 导入其他引擎的sql, 输出FML模型内容 |
6+
| 导出 | export_sql | 将fml模型导出为其他引擎的sql。 |
7+
8+
## IMPORT_SQL
9+
10+
将其他引擎的文本内容,转换为FML语句。
11+
12+
- 命令格式
13+
14+
```
15+
IMPORT_SQL -m <mode> -t <text> | -u <uri> [WITH <properties>]
16+
```
17+
18+
- 参数说明
19+
- mode : 必选,导入的sql的模式,比如mysql,oracle,hologres等
20+
- text:导入的sql文本内容
21+
- uri:支持从其他uri导入的sql文本内容
22+
- properties:可选,配置属性信心
23+
24+
- 示例1, 导入mysql的创建表的语句
25+
26+
```
27+
IMPORT_SQL -m mysql -t "create table a (col1 bigint comment 'col1 comment')" WITH ('reverseTableType' = 'normal')
28+
```
29+
30+
## EXPORT_SQL
31+
32+
将其他引擎的文本内容,转换为FML语句。
33+
34+
- 命令格式
35+
36+
```
37+
EXPORT_SQL -m <mode> -t <text> | -u <uri> [WITH <properties>]
38+
```
39+
40+
- 参数说明
41+
- mode : 必选,导出的sql的模式,比如mysql,oracle,hologres等
42+
- text:导出的fml文本内容
43+
- uri:支持从其他uri导出的fml文本内容
44+
- properties:可选,配置属性信心
45+
46+
- 示例1, 将fml语句导出为mysql的创建表的语句
47+
48+
```
49+
EXPORT_SQL -m mysql -t "create dim table a (col1 bigint comment 'col1 comment')"
50+
```

0 commit comments

Comments
 (0)