Skip to content

Commit

Permalink
merge: #4
Browse files Browse the repository at this point in the history
  • Loading branch information
Willam2004 committed Jun 8, 2024
1 parent aa9c9a2 commit 6c6d945
Show file tree
Hide file tree
Showing 120 changed files with 11,309 additions and 176 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,5 @@ deploy.sh
/fastmodel-parser/src/test/resources/lsp/FastModelLexer.g4
/fastmodel-parser/gen/lsp/FastModelLexer.java
/fastmodel-parser/src/test/resources/lsp/keyword.txt
/fastmodel-transform/fastmodel-transform-adbmysql/src/main/antlr4/com/aliyun/fastmodel/transform/adbmysql/parser/gen/AdbMysqlLexer.java
/fastmodel-transform/fastmodel-transform-mysql/src/main/antlr4/com/aliyun/fastmodel/transform/mysql/parser/gen/MySqlLexer.java
20 changes: 20 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,26 @@ Core
• 新增Show Statics语句


Transformer
• 新增FML到Sqlite的转换
• 新增FML到Adb Mysql的转换

向下兼容(compatibility)
• 暂无

过期功能(deprecations)
安全漏洞修复(vulnerability)


## 0.5.8
新功能(new features)
Core
• 新增Create ODS TABLE
• 新增Show Statics语句


Transformer
• 新增FML到Sqlite的转换
• 新增FML到Adb Mysql的转换
Expand Down
3 changes: 3 additions & 0 deletions docs/zh-cn/layer/business_process.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# 业务过程

业务过程是企业在指定的数据域中所执行的业务活动,是数据建模所需要分析的逻辑主体。例如,交易域中可以有加入购物车、下单、支付等业务过程。本文为您介绍如何创建并使用业务过程。
具体描述:[链接](https://help.aliyun.com/document_detail/276956.html?spm=a2c4g.397548.4.1.35e72121xqDgoR&scm=20140722.H_276956._.ID_276956-OR_rec-V_1)

业务过程是企业在指定的数据域中所执行的业务活动,是数据建模所需要分析的逻辑主体。例如,交易域中可以有加入购物车、下单、支付等业务过程。本文为您介绍如何创建并使用业务过程。
具体描述:[链接](https://help.aliyun.com/document_detail/276956.html?spm=a2c4g.397548.4.1.35e72121xqDgoR&scm=20140722.H_276956._.ID_276956-OR_rec-V_1)
49 changes: 27 additions & 22 deletions fastmodel-bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,129 +47,134 @@
<artifactId>fastmodel-compare</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>com.aliyun.fastmodel</groupId>
<artifactId>fastmodel-parser</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>com.aliyun.fastmodel</groupId>
<artifactId>fastmodel-transform-api</artifactId>
<artifactId>fastmodel-driver-model</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>com.aliyun.fastmodel</groupId>
<artifactId>fastmodel-transform-template</artifactId>
<artifactId>fastmodel-driver-client</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>com.aliyun.fastmodel</groupId>
<artifactId>fastmodel-transform-hive</artifactId>
<artifactId>fastmodel-ide-spi</artifactId>
<version>${project.version}</version>
</dependency>


<dependency>
<groupId>com.aliyun.fastmodel</groupId>
<artifactId>fastmodel-transform-hologres</artifactId>
<artifactId>fastmodel-converter-spi</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>com.aliyun.fastmodel</groupId>
<artifactId>fastmodel-transform-fml</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>com.aliyun.fastmodel</groupId>
<artifactId>fastmodel-transform-plantuml</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>com.aliyun.fastmodel</groupId>
<artifactId>fastmodel-driver-model</artifactId>
<artifactId>fastmodel-transform-zen</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>com.aliyun.fastmodel</groupId>
<artifactId>fastmodel-driver-client</artifactId>
<artifactId>fastmodel-transform-mysql</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>com.aliyun.fastmodel</groupId>
<artifactId>fastmodel-processor</artifactId>
<artifactId>fastmodel-transform-oracle</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>com.aliyun.fastmodel</groupId>
<artifactId>fastmodel-transform-excel</artifactId>
<artifactId>fastmodel-transform-graph</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>com.aliyun.fastmodel</groupId>
<artifactId>fastmodel-converter-spi</artifactId>
<artifactId>fastmodel-transform-clickhouse</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>com.aliyun.fastmodel</groupId>
<artifactId>fastmodel-converter-dqc</artifactId>
<artifactId>fastmodel-transform-adbmysql</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>com.aliyun.fastmodel</groupId>
<artifactId>fastmodel-transform-zen</artifactId>
<artifactId>fastmodel-transform-spark</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>com.aliyun.fastmodel</groupId>
<artifactId>fastmodel-transform-mysql</artifactId>
<artifactId>fastmodel-transform-sqlite</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>com.aliyun.fastmodel</groupId>
<artifactId>fastmodel-transform-oracle</artifactId>
<artifactId>fastmodel-transform-starrocks</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>com.aliyun.fastmodel</groupId>
<artifactId>fastmodel-transform-graph</artifactId>
<artifactId>fastmodel-transform-api</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>com.aliyun.fastmodel</groupId>
<artifactId>fastmodel-transform-clickhouse</artifactId>
<artifactId>fastmodel-transform-template</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>com.aliyun.fastmodel</groupId>
<artifactId>fastmodel-transform-adbmysql</artifactId>
<artifactId>fastmodel-transform-hive</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>com.aliyun.fastmodel</groupId>
<artifactId>fastmodel-transform-spark</artifactId>
<artifactId>fastmodel-transform-hologres</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>com.aliyun.fastmodel</groupId>
<artifactId>fastmodel-transform-sqlite</artifactId>
<artifactId>fastmodel-transform-fml</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>com.aliyun.fastmodel</groupId>
<artifactId>fastmodel-ide-spi</artifactId>
<artifactId>fastmodel-transform-plantuml</artifactId>
<version>${project.version}</version>
</dependency>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@
import com.aliyun.fastmodel.core.tree.QualifiedName;
import com.aliyun.fastmodel.core.tree.datatype.BaseDataType;
import com.aliyun.fastmodel.core.tree.datatype.DataTypeEnums;
import com.aliyun.fastmodel.core.tree.datatype.DataTypeParameter;
import com.aliyun.fastmodel.core.tree.datatype.GenericDataType;
import com.aliyun.fastmodel.core.tree.datatype.NumericParameter;
import com.aliyun.fastmodel.core.tree.datatype.TypeParameter;
import com.aliyun.fastmodel.core.tree.expr.Identifier;
import com.aliyun.fastmodel.core.tree.statement.constants.ColumnPropertyDefaultKey;
import com.aliyun.fastmodel.core.tree.statement.constants.TableDetailType;
Expand All @@ -43,6 +46,7 @@
import com.aliyun.fastmodel.core.tree.statement.table.constraint.PrimaryConstraint;
import com.aliyun.fastmodel.core.tree.util.DataTypeUtil;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import org.junit.Test;

import static org.junit.Assert.assertEquals;
Expand Down Expand Up @@ -513,6 +517,7 @@ public void testCommentIsNull() {
assertEquals(1, baseStatements.size());
}


private CreateDimTable getCreateDimTable(Comment comment) {
CreateDimTable before = CreateDimTable.builder().tableName(QualifiedName.of("dim_shop")).columns(
ImmutableList.of(ColumnDefinition.builder().dataType(DataTypeUtil.simpleType(DataTypeEnums.BIGINT))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,19 @@

package com.aliyun.fastmodel.compare.table;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

import com.aliyun.fastmodel.compare.impl.table.ColumnCompare;
import com.aliyun.fastmodel.core.tree.BaseStatement;
import com.aliyun.fastmodel.core.tree.Property;
import com.aliyun.fastmodel.core.tree.QualifiedName;
import com.aliyun.fastmodel.core.tree.datatype.BaseDataType;
import com.aliyun.fastmodel.core.tree.datatype.DataTypeEnums;
import com.aliyun.fastmodel.core.tree.datatype.DataTypeParameter;
import com.aliyun.fastmodel.core.tree.datatype.GenericDataType;
import com.aliyun.fastmodel.core.tree.datatype.TypeParameter;
import com.aliyun.fastmodel.core.tree.expr.Identifier;
import com.aliyun.fastmodel.core.tree.statement.constants.ColumnCategory;
import com.aliyun.fastmodel.core.tree.statement.constants.ColumnPropertyDefaultKey;
Expand Down Expand Up @@ -287,6 +292,35 @@ public void testComparePropertiesAfterNull() {
assertEquals(join, "ALTER TABLE dim_shop CHANGE COLUMN c1 c1 BIGINT WITH ('code_table'='')");
}

@Test
public void testCompareWithMultiDataType() {
ArrayList<DataTypeParameter> anInt = Lists.newArrayList(new TypeParameter(DataTypeUtil.simpleType("int", null)));
BaseDataType build = new GenericDataType("array", anInt);
List<ColumnDefinition> leftList = ImmutableList.of(
ColumnDefinition.builder().colName(new Identifier("col1"))
.dataType(build)
.build()
);
BaseDataType build2 = new GenericDataType("ARRAY", anInt);
List<ColumnDefinition> rightList = ImmutableList.of(
ColumnDefinition.builder().colName(new Identifier("col1"))
.dataType(build2)
.build()
);

CreateTable before = CreateTable.builder()
.columns(leftList)
.tableName(QualifiedName.of("dim_shop")).build();

CreateTable after = CreateTable.builder()
.columns(rightList)
.tableName(QualifiedName.of("dim_shop")).build();

List<BaseStatement> baseStatementList = columnCompare.compareTableElement(before, after);
String join = Joiner.on("\n").join(baseStatementList);
assertEquals("", join);
}

@Test
public void testComparePropertiesBeforeNull() {
ColumnDefinition columnDefinition = ColumnDefinition.builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -351,8 +351,7 @@ public String visitLongLiteral(LongLiteral node, Void context) {
@Override
public String visitIntervalLiteral(IntervalLiteral node, Void context) {
StringBuilder builder = new StringBuilder()
.append("INTERVAL ")
.append(" '").append(node.getValue()).append("' ")
.append("INTERVAL").append(" ").append(process(node.getValue())).append(" ")
.append(node.getFromDateTime());

if (node.getToDateTime() != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@
*/
public class FastModelVisitor extends AstVisitor<Boolean, Integer> {

private static final String INDENT = " ";
protected static final String INDENT = " ";
public static final String CONSTRAINT = "CONSTRAINT ";
public static final String SUFFIX = ";";
public static final String NEW_LINE = "\n";
Expand Down Expand Up @@ -414,18 +414,20 @@ public Boolean visitRenameTable(RenameTable renameTable, Integer context) {

@Override
public Boolean visitCreateTable(CreateTable node, Integer indent) {
builder.append("CREATE ");
builder.append("CREATE");
if (node.getCreateOrReplace() != null && node.getCreateOrReplace()) {
builder.append("OR REPLACE ");
}
ITableDetailType tableDetailType = node.getTableDetailType() == null ? TableDetailType.NORMAL_DIM
: node.getTableDetailType();
boolean isNormalOrTransaction = tableDetailType == TableDetailType.NORMAL_DIM
|| tableDetailType == TableDetailType.TRANSACTION_FACT;
if (!isNormalOrTransaction && !tableDetailType.isSingle()) {
builder.append(tableDetailType.getCode()).append(" ");
builder.append(" OR REPLACE");
}
ITableDetailType tableDetailType = null;
if (node.getTableDetailType() != null) {
tableDetailType = node.getTableDetailType();
boolean isNormalOrTransaction = tableDetailType == TableDetailType.NORMAL_DIM
|| tableDetailType == TableDetailType.TRANSACTION_FACT;
if (!isNormalOrTransaction && !tableDetailType.isSingle()) {
builder.append(" ").append(tableDetailType.getCode());
}
builder.append(" ").append(tableDetailType.getParent());
}
builder.append(tableDetailType.getParent());
builder.append(" TABLE ");
if (node.isNotExists()) {
builder.append("IF NOT EXISTS ");
Expand Down Expand Up @@ -606,7 +608,7 @@ public Boolean visitPrimaryConstraint(PrimaryConstraint primaryConstraint, Integ
builder.append(indentString(ident)).append("PRIMARY KEY(");
}
builder.append(
primaryConstraint.getColNames().stream().map(ExpressionFormatter::formatExpression).collect(joining(",")));
primaryConstraint.getColNames().stream().map(this::formatExpression).collect(joining(",")));
builder.append(")");
if (primaryConstraint.getEnable() != null) {
if (!primaryConstraint.getEnable()) {
Expand Down Expand Up @@ -1214,7 +1216,7 @@ public Boolean visitSetTableProperties(SetTableProperties setTableProperties, In
@Override
public Boolean visitDropCol(DropCol dropCol, Integer context) {
builder.append("ALTER TABLE ").append(getCode(dropCol.getQualifiedName()));
builder.append(" DROP COLUMN ").append(ExpressionFormatter.formatExpression(dropCol.getColumnName()));
builder.append(" DROP COLUMN ").append(formatExpression(dropCol.getColumnName()));
return true;
}

Expand Down Expand Up @@ -1947,7 +1949,7 @@ private String formatWith(List<Property> properties, boolean isNewLine) {
return stringBuilder.toString();
}

public String indentString(int indent) {
protected String indentString(int indent) {
return Strings.repeat(INDENT, indent);
}

Expand Down Expand Up @@ -1980,7 +1982,7 @@ protected String formatGroupBy(List<GroupingElement> groupingElements) {
return Joiner.on(", ").join(resultStrings.build());
}

public String formatStringLiteral(String s) {
protected String formatStringLiteral(String s) {
if (s == null) {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
import java.util.List;

import com.google.common.collect.ImmutableList;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import org.apache.commons.lang3.StringUtils;

/**
* 备注描述信息
Expand All @@ -29,7 +29,6 @@
* @date 2020/11/6
*/
@Getter
@EqualsAndHashCode(callSuper = false)
public class Comment extends AbstractNode {

private final String comment;
Expand All @@ -52,4 +51,12 @@ public List<? extends Node> getChildren() {
public <R, C> R accept(IAstVisitor<R, C> visitor, C context) {
return visitor.visitComment(this, context);
}

@Override
public boolean equals(Object o) {
if (this == o) {return true;}
if (o == null || getClass() != o.getClass()) {return false;}
Comment c = (Comment)o;
return StringUtils.equals(comment, c.getComment());
}
}
Loading

0 comments on commit 6c6d945

Please sign in to comment.