diff --git a/fastmodel-bom/pom.xml b/fastmodel-bom/pom.xml
index 8671048..7ad3206 100644
--- a/fastmodel-bom/pom.xml
+++ b/fastmodel-bom/pom.xml
@@ -145,6 +145,12 @@
${project.version}
+
+ com.aliyun.fastmodel
+ fastmodel-transform-oceanbase
+ ${project.version}
+
+
com.aliyun.fastmodel
fastmodel-transform-api
diff --git a/fastmodel-common/src/main/java/com/aliyun/fastmodel/common/parser/ParserHelper.java b/fastmodel-common/src/main/java/com/aliyun/fastmodel/common/parser/ParserHelper.java
index 9009796..b625d8d 100644
--- a/fastmodel-common/src/main/java/com/aliyun/fastmodel/common/parser/ParserHelper.java
+++ b/fastmodel-common/src/main/java/com/aliyun/fastmodel/common/parser/ParserHelper.java
@@ -13,7 +13,12 @@
import java.util.Locale;
import java.util.Objects;
import java.util.Optional;
+import java.util.function.Function;
+import com.aliyun.fastmodel.common.parser.lexer.CaseChangingCharStream;
+import com.aliyun.fastmodel.common.utils.StripUtils;
+import com.aliyun.fastmodel.core.tree.ListNode;
+import com.aliyun.fastmodel.core.tree.Node;
import com.aliyun.fastmodel.core.tree.NodeLocation;
import com.aliyun.fastmodel.core.tree.expr.Identifier;
import com.aliyun.fastmodel.core.tree.expr.literal.BaseLiteral;
@@ -21,9 +26,17 @@
import com.aliyun.fastmodel.core.tree.expr.literal.DoubleLiteral;
import com.aliyun.fastmodel.core.tree.expr.literal.LongLiteral;
import com.aliyun.fastmodel.core.tree.expr.literal.StringLiteral;
+import com.google.common.collect.Lists;
import org.antlr.v4.runtime.CharStream;
+import org.antlr.v4.runtime.CharStreams;
+import org.antlr.v4.runtime.CodePointCharStream;
+import org.antlr.v4.runtime.CommonTokenStream;
+import org.antlr.v4.runtime.Lexer;
+import org.antlr.v4.runtime.Parser;
import org.antlr.v4.runtime.ParserRuleContext;
import org.antlr.v4.runtime.Token;
+import org.antlr.v4.runtime.TokenStream;
+import org.antlr.v4.runtime.atn.PredictionMode;
import org.antlr.v4.runtime.misc.Interval;
import org.antlr.v4.runtime.tree.AbstractParseTreeVisitor;
import org.antlr.v4.runtime.tree.ParseTree;
@@ -159,4 +172,64 @@ private static Identifier getIdentifier(String text, String regex, ParserRuleCon
text = text.substring(1, text.length() - 1).replaceAll(regex, StringUtils.EMPTY);
return new Identifier(getLocation(ctx), getOrigin(ctx), text, true);
}
+
+ public static ParserRuleContext getNode(String text,
+ Function lexerFunction,
+ Function parserFunction,
+ Function functionalInterface) {
+
+ String code = StripUtils.appendSemicolon(text);
+ CodePointCharStream charStream = CharStreams.fromString(code);
+ CaseChangingCharStream caseChangingCharStream = new CaseChangingCharStream(charStream, true);
+ Lexer lexer = lexerFunction.apply(caseChangingCharStream);
+ lexer.removeErrorListeners();
+ ThrowingErrorListener LISTENER = new ThrowingErrorListener();
+ lexer.addErrorListener(LISTENER);
+ CommonTokenStream commonTokenStream = new CommonTokenStream(lexer);
+ Parser parser = parserFunction.apply(commonTokenStream);
+ parser.removeErrorListeners();
+ parser.addErrorListener(LISTENER);
+ ParserRuleContext tree;
+ try {
+ parser.getInterpreter().setPredictionMode(PredictionMode.SLL);
+ tree = functionalInterface.apply(parser);
+ } catch (Throwable e) {
+ commonTokenStream.seek(0);
+ parser.getInterpreter().setPredictionMode(PredictionMode.LL);
+ tree = functionalInterface.apply(parser);
+ }
+ return tree;
+ }
+
+ public static T getNode(ListNode node, Class clazz) {
+ List listNode = getListNode(node, clazz);
+ if (listNode == null || listNode.isEmpty()) {
+ return null;
+ }
+ return listNode.get(0);
+ }
+
+ public static List getListNode(ListNode node, Class clazz) {
+ if (node == null || node.getChildren() == null || node.getChildren().isEmpty()) {
+ return null;
+ }
+ if (clazz == null) {
+ return null;
+ }
+ List list = Lists.newArrayList();
+ List extends Node> children = node.getChildren();
+ for (Node node1 : children) {
+ if (node1.getClass().getName() == clazz.getName()) {
+ list.add((T)node1);
+ }
+ if (node1 instanceof ListNode) {
+ ListNode node2 = (ListNode)node1;
+ List listNode = getListNode(node2, clazz);
+ if (listNode != null) {
+ list.addAll(listNode);
+ }
+ }
+ }
+ return list;
+ }
}
diff --git a/fastmodel-core/src/main/java/com/aliyun/fastmodel/core/formatter/ExpressionFormatter.java b/fastmodel-core/src/main/java/com/aliyun/fastmodel/core/formatter/ExpressionFormatter.java
index 668723e..ca1ef7a 100644
--- a/fastmodel-core/src/main/java/com/aliyun/fastmodel/core/formatter/ExpressionFormatter.java
+++ b/fastmodel-core/src/main/java/com/aliyun/fastmodel/core/formatter/ExpressionFormatter.java
@@ -1,30 +1,14 @@
/*
- * Copyright 2021-2022 Alibaba Group Holding Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Copyright (c) 2020. Aliyun.com All right reserved. This software is the
+ * confidential and proprietary information of Aliyun.com ("Confidential
+ * Information"). You shall not disclose such Confidential Information and shall
+ * use it only in accordance with the terms of the license agreement you entered
+ * into with Aliyun.com.
*/
package com.aliyun.fastmodel.core.formatter;
-import java.util.List;
-
-import com.aliyun.fastmodel.core.tree.QualifiedName;
import com.aliyun.fastmodel.core.tree.expr.BaseExpression;
-import com.aliyun.fastmodel.core.tree.statement.select.order.OrderBy;
-import com.google.common.base.Joiner;
-
-import static java.lang.String.format;
-import static java.util.stream.Collectors.joining;
/**
* 格式化处理
diff --git a/fastmodel-core/src/main/java/com/aliyun/fastmodel/core/formatter/ExpressionVisitor.java b/fastmodel-core/src/main/java/com/aliyun/fastmodel/core/formatter/ExpressionVisitor.java
index ea543d8..3d92fc5 100644
--- a/fastmodel-core/src/main/java/com/aliyun/fastmodel/core/formatter/ExpressionVisitor.java
+++ b/fastmodel-core/src/main/java/com/aliyun/fastmodel/core/formatter/ExpressionVisitor.java
@@ -1,17 +1,9 @@
/*
- * Copyright 2021-2022 Alibaba Group Holding Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Copyright (c) 2021. Aliyun.com All right reserved. This software is the
+ * confidential and proprietary information of Aliyun.com ("Confidential
+ * Information"). You shall not disclose such Confidential Information and shall
+ * use it only in accordance with the terms of the license agreement you entered
+ * into with Aliyun.com.
*/
package com.aliyun.fastmodel.core.formatter;
@@ -250,7 +242,7 @@ public String visitSearchedCaseExpression(SearchedCaseExpression node, Void cont
@Override
public String visitNullLiteral(NullLiteral node, Void context) {
- return "null";
+ return "NULL";
}
@Override
diff --git a/fastmodel-core/src/main/java/com/aliyun/fastmodel/core/formatter/FastModelFormatter.java b/fastmodel-core/src/main/java/com/aliyun/fastmodel/core/formatter/FastModelFormatter.java
index 83c4f7f..de23976 100644
--- a/fastmodel-core/src/main/java/com/aliyun/fastmodel/core/formatter/FastModelFormatter.java
+++ b/fastmodel-core/src/main/java/com/aliyun/fastmodel/core/formatter/FastModelFormatter.java
@@ -1,17 +1,9 @@
/*
- * Copyright 2021-2022 Alibaba Group Holding Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Copyright (c) 2020. Aliyun.com All right reserved. This software is the
+ * confidential and proprietary information of Aliyun.com ("Confidential
+ * Information"). You shall not disclose such Confidential Information and shall
+ * use it only in accordance with the terms of the license agreement you entered
+ * into with Aliyun.com.
*/
package com.aliyun.fastmodel.core.formatter;
diff --git a/fastmodel-core/src/main/java/com/aliyun/fastmodel/core/formatter/FastModelVisitor.java b/fastmodel-core/src/main/java/com/aliyun/fastmodel/core/formatter/FastModelVisitor.java
index 6b0a99d..1c5c0f8 100644
--- a/fastmodel-core/src/main/java/com/aliyun/fastmodel/core/formatter/FastModelVisitor.java
+++ b/fastmodel-core/src/main/java/com/aliyun/fastmodel/core/formatter/FastModelVisitor.java
@@ -1,17 +1,9 @@
/*
- * Copyright 2021-2022 Alibaba Group Holding Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Copyright (c) 2020. Aliyun.com All right reserved. This software is the
+ * confidential and proprietary information of Aliyun.com ("Confidential
+ * Information"). You shall not disclose such Confidential Information and shall
+ * use it only in accordance with the terms of the license agreement you entered
+ * into with Aliyun.com.
*/
package com.aliyun.fastmodel.core.formatter;
@@ -148,6 +140,8 @@
import com.aliyun.fastmodel.core.tree.statement.table.constraint.TimePeriodConstraint;
import com.aliyun.fastmodel.core.tree.statement.table.constraint.UniqueConstraint;
import com.aliyun.fastmodel.core.tree.statement.table.index.IndexColumnName;
+import com.aliyun.fastmodel.core.tree.statement.table.index.IndexExpr;
+import com.aliyun.fastmodel.core.tree.statement.table.index.IndexSortKey;
import com.aliyun.fastmodel.core.tree.statement.table.index.SortType;
import com.aliyun.fastmodel.core.tree.statement.table.index.TableIndex;
import com.aliyun.fastmodel.core.tree.statement.table.type.ITableDetailType;
@@ -441,7 +435,8 @@ public Boolean visitCreateTable(CreateTable node, Integer indent) {
String elementIndent = indentString(newIndent);
builder.append(formatColumnList(node.getColumnDefines(), elementIndent));
if (!node.isConstraintEmpty()) {
- Iterator iterator = node.getConstraintStatements().iterator();
+ Iterator iterator = node.getConstraintStatements().stream()
+ .iterator();
while (iterator.hasNext()) {
builder.append(",\n");
process(iterator.next(), newIndent);
@@ -666,14 +661,36 @@ public Boolean visitTableIndex(TableIndex tableIndex, Integer ident) {
return true;
}
- protected void appendTableIndex(List tableIndex) {
+ protected void appendTableIndex(List tableIndex) {
builder.append(" (");
builder.append(tableIndex.stream().map(
- this::formatIndexColumnName
+ index -> {
+ if (index instanceof IndexColumnName) {
+ IndexColumnName indexColumnName = (IndexColumnName)index;
+ return formatIndexColumnName(indexColumnName);
+ }
+ if (index instanceof IndexExpr) {
+ IndexExpr indexExpr = (IndexExpr)index;
+ return formatIndexExpr(indexExpr);
+ }
+ return StringUtils.EMPTY;
+ }
).collect(joining(",")));
builder.append(")");
}
+ private String formatIndexExpr(IndexExpr indexExpr) {
+ StringBuilder stringBuilder = new StringBuilder("(");
+ String expression = formatExpression(indexExpr.getExpression());
+ stringBuilder.append(expression);
+ stringBuilder.append(")");
+ SortType sortType = indexExpr.getSortType();
+ if (sortType != null) {
+ stringBuilder.append(" ").append(sortType.name());
+ }
+ return stringBuilder.toString();
+ }
+
@Override
public Boolean visitDropIndex(DropIndex dropIndex, Integer context) {
builder.append("DROP INDEX ");
@@ -729,7 +746,7 @@ protected String formatPartitions(List partitionCol, boolean i
}
protected String formatColumnList(List list,
- String elementIndent) {
+ String elementIndent) {
OptionalInt max = list.stream().map(ColumnDefinition::getColName).mapToInt(
x -> formatExpression(x).length()
).max();
@@ -1506,7 +1523,7 @@ public Boolean visitCreateDqcRule(CreateDqcRule createRules, Integer context) {
}
protected void appendPartition(StringBuilder builder,
- List partitionSpecList, String split) {
+ List partitionSpecList, String split) {
if (partitionSpecList == null || partitionSpecList.isEmpty()) {
return;
}
@@ -1947,7 +1964,10 @@ private String formatWith(List properties, boolean isNewLine) {
return stringBuilder.toString();
}
- protected String indentString(int indent) {
+ protected String indentString(Integer indent) {
+ if (indent == null) {
+ return StringUtils.EMPTY;
+ }
return Strings.repeat(INDENT, indent);
}
diff --git a/fastmodel-core/src/main/java/com/aliyun/fastmodel/core/parser/LanguageParser.java b/fastmodel-core/src/main/java/com/aliyun/fastmodel/core/parser/LanguageParser.java
index d057b50..04198c5 100644
--- a/fastmodel-core/src/main/java/com/aliyun/fastmodel/core/parser/LanguageParser.java
+++ b/fastmodel-core/src/main/java/com/aliyun/fastmodel/core/parser/LanguageParser.java
@@ -46,12 +46,24 @@ default T parseNode(String text) throws ParseException {
/**
* parse data type
*
- * @param code
+ * @param text
* @param context
* @return {@link BaseDataType}
* @throws ParseException
*/
- default BaseDataType parseDataType(String code, C context) throws ParseException {
+ default BaseDataType parseDataType(String text, C context) throws ParseException {
+ return null;
+ }
+
+ /**
+ * 解析表达式,支持泛型, 不需要强转
+ *
+ * @param text¬ 表达式
+ * @param T
+ * @return T
+ * @throws ParseException 解析异常
+ */
+ default T parseExpression(String text) throws ParseException {
return null;
}
}
diff --git a/fastmodel-core/src/main/java/com/aliyun/fastmodel/core/tree/IAstVisitor.java b/fastmodel-core/src/main/java/com/aliyun/fastmodel/core/tree/IAstVisitor.java
index 1c92b6f..f4dda20 100644
--- a/fastmodel-core/src/main/java/com/aliyun/fastmodel/core/tree/IAstVisitor.java
+++ b/fastmodel-core/src/main/java/com/aliyun/fastmodel/core/tree/IAstVisitor.java
@@ -110,6 +110,7 @@
import com.aliyun.fastmodel.core.tree.statement.show.ConditionElement;
import com.aliyun.fastmodel.core.tree.statement.show.LikeCondition;
import com.aliyun.fastmodel.core.tree.statement.show.WhereCondition;
+import com.aliyun.fastmodel.core.tree.statement.table.index.IndexExpr;
/**
* AST visitor interface
@@ -1354,4 +1355,8 @@ default R visitHexLiteral(HexLiteral hexLiteral, C context) {
default R visitJsonDataType(JsonDataType jsonDataType, C context) {
return visitRowDataType(jsonDataType, context);
}
+
+ default R visitIndexExpr(IndexExpr indexExpr, C context) {
+ return visitNode(indexExpr, context);
+ }
}
diff --git a/fastmodel-core/src/main/java/com/aliyun/fastmodel/core/tree/expr/enums/BitOperator.java b/fastmodel-core/src/main/java/com/aliyun/fastmodel/core/tree/expr/enums/BitOperator.java
index 5f4d409..c68f0ce 100644
--- a/fastmodel-core/src/main/java/com/aliyun/fastmodel/core/tree/expr/enums/BitOperator.java
+++ b/fastmodel-core/src/main/java/com/aliyun/fastmodel/core/tree/expr/enums/BitOperator.java
@@ -43,6 +43,16 @@ public enum BitOperator {
*/
NOT_MARK("!"),
+ /**
+ * <<
+ */
+ SHIFT_LEFT("<<"),
+
+ /**
+ * >>
+ */
+ SHIFT_RIGHT(">>"),
+
/**
* ^
*/
diff --git a/fastmodel-core/src/main/java/com/aliyun/fastmodel/core/tree/expr/enums/ComparisonOperator.java b/fastmodel-core/src/main/java/com/aliyun/fastmodel/core/tree/expr/enums/ComparisonOperator.java
index 808e941..d915eee 100644
--- a/fastmodel-core/src/main/java/com/aliyun/fastmodel/core/tree/expr/enums/ComparisonOperator.java
+++ b/fastmodel-core/src/main/java/com/aliyun/fastmodel/core/tree/expr/enums/ComparisonOperator.java
@@ -56,12 +56,13 @@ public enum ComparisonOperator {
*/
NOT_EQUAL_MS("!="),
+ NS_EQUAL("<=>"),
+
/**
* is distinct from
*/
IS_DISTINCT_FROM("IS DISTINCT FROM");
-
/**
* code
*/
diff --git a/fastmodel-core/src/main/java/com/aliyun/fastmodel/core/tree/expr/literal/EscapeStringLiteral.java b/fastmodel-core/src/main/java/com/aliyun/fastmodel/core/tree/expr/literal/EscapeStringLiteral.java
index 82179d1..4b1095b 100644
--- a/fastmodel-core/src/main/java/com/aliyun/fastmodel/core/tree/expr/literal/EscapeStringLiteral.java
+++ b/fastmodel-core/src/main/java/com/aliyun/fastmodel/core/tree/expr/literal/EscapeStringLiteral.java
@@ -9,7 +9,7 @@
package com.aliyun.fastmodel.core.tree.expr.literal;
import com.aliyun.fastmodel.core.tree.IAstVisitor;
-import lombok.Data;
+import lombok.Getter;
/**
* escape string literal
@@ -17,7 +17,7 @@
* @author panguanjing
* @date 2022/6/10
*/
-@Data
+@Getter
public class EscapeStringLiteral extends StringLiteral {
/**
* escape value
diff --git a/fastmodel-core/src/main/java/com/aliyun/fastmodel/core/tree/statement/table/CreateIndex.java b/fastmodel-core/src/main/java/com/aliyun/fastmodel/core/tree/statement/table/CreateIndex.java
index 089fef4..266773d 100644
--- a/fastmodel-core/src/main/java/com/aliyun/fastmodel/core/tree/statement/table/CreateIndex.java
+++ b/fastmodel-core/src/main/java/com/aliyun/fastmodel/core/tree/statement/table/CreateIndex.java
@@ -24,7 +24,7 @@
import com.aliyun.fastmodel.core.tree.QualifiedName;
import com.aliyun.fastmodel.core.tree.statement.BaseOperatorStatement;
import com.aliyun.fastmodel.core.tree.statement.constants.StatementType;
-import com.aliyun.fastmodel.core.tree.statement.table.index.IndexColumnName;
+import com.aliyun.fastmodel.core.tree.statement.table.index.IndexSortKey;
import lombok.EqualsAndHashCode;
import lombok.Getter;
@@ -40,13 +40,13 @@ public class CreateIndex extends BaseOperatorStatement {
private final QualifiedName tableName;
- private final List indexColumnNameList;
+ private final List indexColumnNameList;
private final List propertyList;
public CreateIndex(QualifiedName qualifiedName, QualifiedName tableName,
- List indexColumnNameList,
- List propertyList) {
+ List indexColumnNameList,
+ List propertyList) {
super(qualifiedName);
this.tableName = tableName;
this.indexColumnNameList = indexColumnNameList;
@@ -55,9 +55,9 @@ public CreateIndex(QualifiedName qualifiedName, QualifiedName tableName,
}
public CreateIndex(NodeLocation nodeLocation, String origin,
- QualifiedName qualifiedName, QualifiedName tableName,
- List indexColumnNameList,
- List propertyList) {
+ QualifiedName qualifiedName, QualifiedName tableName,
+ List indexColumnNameList,
+ List propertyList) {
super(nodeLocation, origin, qualifiedName);
this.tableName = tableName;
this.indexColumnNameList = indexColumnNameList;
diff --git a/fastmodel-core/src/main/java/com/aliyun/fastmodel/core/tree/statement/table/index/IndexColumnName.java b/fastmodel-core/src/main/java/com/aliyun/fastmodel/core/tree/statement/table/index/IndexColumnName.java
index b89a1f5..0dada33 100644
--- a/fastmodel-core/src/main/java/com/aliyun/fastmodel/core/tree/statement/table/index/IndexColumnName.java
+++ b/fastmodel-core/src/main/java/com/aliyun/fastmodel/core/tree/statement/table/index/IndexColumnName.java
@@ -1,24 +1,15 @@
/*
- * Copyright 2021-2022 Alibaba Group Holding Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Copyright (c) 2021. Aliyun.com All right reserved. This software is the
+ * confidential and proprietary information of Aliyun.com ("Confidential
+ * Information"). You shall not disclose such Confidential Information and shall
+ * use it only in accordance with the terms of the license agreement you entered
+ * into with Aliyun.com.
*/
package com.aliyun.fastmodel.core.tree.statement.table.index;
import java.util.List;
-import com.aliyun.fastmodel.core.tree.AbstractFmlNode;
import com.aliyun.fastmodel.core.tree.AstVisitor;
import com.aliyun.fastmodel.core.tree.Node;
import com.aliyun.fastmodel.core.tree.expr.Identifier;
@@ -35,7 +26,7 @@
*/
@Getter
@EqualsAndHashCode(callSuper = false)
-public class IndexColumnName extends AbstractFmlNode {
+public class IndexColumnName extends IndexSortKey {
private final Identifier columnName;
diff --git a/fastmodel-core/src/main/java/com/aliyun/fastmodel/core/tree/statement/table/index/IndexExpr.java b/fastmodel-core/src/main/java/com/aliyun/fastmodel/core/tree/statement/table/index/IndexExpr.java
new file mode 100644
index 0000000..f6ce498
--- /dev/null
+++ b/fastmodel-core/src/main/java/com/aliyun/fastmodel/core/tree/statement/table/index/IndexExpr.java
@@ -0,0 +1,44 @@
+package com.aliyun.fastmodel.core.tree.statement.table.index;
+
+import java.util.List;
+
+import com.aliyun.fastmodel.core.tree.AstVisitor;
+import com.aliyun.fastmodel.core.tree.IAstVisitor;
+import com.aliyun.fastmodel.core.tree.Node;
+import com.aliyun.fastmodel.core.tree.expr.BaseExpression;
+import com.google.common.collect.ImmutableList;
+import lombok.Getter;
+
+/**
+ * index expr
+ *
+ * @author panguanjing
+ * @date 2024/2/8
+ */
+@Getter
+public class IndexExpr extends IndexSortKey {
+
+ private final BaseExpression expression;
+
+ private final SortType sortType;
+
+ public IndexExpr(BaseExpression expression, SortType sortType) {
+ this.expression = expression;
+ this.sortType = sortType;
+ }
+
+ @Override
+ public R accept(IAstVisitor visitor, C context) {
+ return visitor.visitIndexExpr(this, context);
+ }
+
+ @Override
+ public R accept(AstVisitor visitor, C context) {
+ return visitor.visitIndexExpr(this, context);
+ }
+
+ @Override
+ public List extends Node> getChildren() {
+ return ImmutableList.of(expression);
+ }
+}
diff --git a/fastmodel-core/src/main/java/com/aliyun/fastmodel/core/tree/statement/table/index/IndexSortKey.java b/fastmodel-core/src/main/java/com/aliyun/fastmodel/core/tree/statement/table/index/IndexSortKey.java
new file mode 100644
index 0000000..c89b094
--- /dev/null
+++ b/fastmodel-core/src/main/java/com/aliyun/fastmodel/core/tree/statement/table/index/IndexSortKey.java
@@ -0,0 +1,12 @@
+package com.aliyun.fastmodel.core.tree.statement.table.index;
+
+import com.aliyun.fastmodel.core.tree.AbstractFmlNode;
+
+/**
+ * index sort key
+ *
+ * @author panguanjing
+ * @date 2024/2/8
+ */
+public abstract class IndexSortKey extends AbstractFmlNode {
+}
diff --git a/fastmodel-core/src/main/java/com/aliyun/fastmodel/core/tree/statement/table/index/SortType.java b/fastmodel-core/src/main/java/com/aliyun/fastmodel/core/tree/statement/table/index/SortType.java
index f74c041..b8e78eb 100644
--- a/fastmodel-core/src/main/java/com/aliyun/fastmodel/core/tree/statement/table/index/SortType.java
+++ b/fastmodel-core/src/main/java/com/aliyun/fastmodel/core/tree/statement/table/index/SortType.java
@@ -1,17 +1,9 @@
/*
- * Copyright 2021-2022 Alibaba Group Holding Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Copyright (c) 2021. Aliyun.com All right reserved. This software is the
+ * confidential and proprietary information of Aliyun.com ("Confidential
+ * Information"). You shall not disclose such Confidential Information and shall
+ * use it only in accordance with the terms of the license agreement you entered
+ * into with Aliyun.com.
*/
package com.aliyun.fastmodel.core.tree.statement.table.index;
diff --git a/fastmodel-core/src/main/java/com/aliyun/fastmodel/core/tree/statement/table/index/TableIndex.java b/fastmodel-core/src/main/java/com/aliyun/fastmodel/core/tree/statement/table/index/TableIndex.java
index e50953f..e171a8a 100644
--- a/fastmodel-core/src/main/java/com/aliyun/fastmodel/core/tree/statement/table/index/TableIndex.java
+++ b/fastmodel-core/src/main/java/com/aliyun/fastmodel/core/tree/statement/table/index/TableIndex.java
@@ -1,17 +1,9 @@
/*
- * Copyright 2021-2022 Alibaba Group Holding Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Copyright (c) 2021. Aliyun.com All right reserved. This software is the
+ * confidential and proprietary information of Aliyun.com ("Confidential
+ * Information"). You shall not disclose such Confidential Information and shall
+ * use it only in accordance with the terms of the license agreement you entered
+ * into with Aliyun.com.
*/
package com.aliyun.fastmodel.core.tree.statement.table.index;
@@ -22,8 +14,7 @@
import com.aliyun.fastmodel.core.tree.Node;
import com.aliyun.fastmodel.core.tree.Property;
import com.aliyun.fastmodel.core.tree.expr.Identifier;
-import com.aliyun.fastmodel.core.tree.statement.constants.ConstraintType;
-import com.aliyun.fastmodel.core.tree.statement.table.constraint.BaseConstraint;
+import com.aliyun.fastmodel.core.tree.statement.table.TableElement;
import com.google.common.collect.ImmutableList;
import lombok.EqualsAndHashCode;
import lombok.Getter;
@@ -36,18 +27,17 @@
*/
@Getter
@EqualsAndHashCode(callSuper = false)
-public class TableIndex extends BaseConstraint {
+public class TableIndex extends TableElement {
private final Identifier indexName;
- private final List indexColumnNames;
+ private final List indexColumnNames;
private final List properties;
public TableIndex(Identifier indexName,
- List indexColumnNames,
+ List indexColumnNames,
List properties) {
- super(indexName, ConstraintType.INDEX);
this.indexName = indexName;
this.indexColumnNames = indexColumnNames;
this.properties = properties;
diff --git a/fastmodel-dependencies-bom/pom.xml b/fastmodel-dependencies-bom/pom.xml
index 6b1e0bf..e00c67a 100644
--- a/fastmodel-dependencies-bom/pom.xml
+++ b/fastmodel-dependencies-bom/pom.xml
@@ -26,7 +26,7 @@
${revision}
- 0.5.10
+ 0.5.11
1.1.0
3.17.1
4.13.1
@@ -44,7 +44,7 @@
jdk11
- 0.5.10
+ 0.5.11
true
@@ -62,7 +62,7 @@
jdk8
- 0.5.10-jdk8
+ 0.5.11-jdk8
diff --git a/fastmodel-parser/src/main/java/com/aliyun/fastmodel/parser/visitor/TableVisitor.java b/fastmodel-parser/src/main/java/com/aliyun/fastmodel/parser/visitor/TableVisitor.java
index 413b8a8..b5a0f2c 100644
--- a/fastmodel-parser/src/main/java/com/aliyun/fastmodel/parser/visitor/TableVisitor.java
+++ b/fastmodel-parser/src/main/java/com/aliyun/fastmodel/parser/visitor/TableVisitor.java
@@ -62,6 +62,7 @@
import com.aliyun.fastmodel.core.tree.statement.table.constraint.TimePeriodConstraint;
import com.aliyun.fastmodel.core.tree.statement.table.constraint.UniqueConstraint;
import com.aliyun.fastmodel.core.tree.statement.table.index.IndexColumnName;
+import com.aliyun.fastmodel.core.tree.statement.table.index.IndexSortKey;
import com.aliyun.fastmodel.core.tree.statement.table.index.SortType;
import com.aliyun.fastmodel.core.tree.statement.table.index.TableIndex;
import com.aliyun.fastmodel.core.tree.util.IdentifierUtil;
@@ -234,7 +235,7 @@ public Node visitDropConstraint(DropConstraintContext ctx) {
@Override
public Node visitTableIndex(TableIndexContext ctx) {
- List list = visit(ctx.indexColumnNames().indexColumnName(), IndexColumnName.class);
+ List list = visit(ctx.indexColumnNames().indexColumnName(), IndexSortKey.class);
List indexProperties = ImmutableList.of();
if (ctx.indexOption() != null) {
indexProperties = getProperties(ctx.indexOption().setProperties());
@@ -397,7 +398,7 @@ public Node visitCreateIndex(CreateIndexContext ctx) {
return new CreateIndex(
getQualifiedName(ctx.qualifiedName()),
getQualifiedName(ctx.tableName()),
- visit(ctx.indexColumnNames().indexColumnName(), IndexColumnName.class),
+ visit(ctx.indexColumnNames().indexColumnName(), IndexSortKey.class),
list
);
}
diff --git a/fastmodel-parser/src/test/java/com/aliyun/fastmodel/parser/statement/QueryTest.java b/fastmodel-parser/src/test/java/com/aliyun/fastmodel/parser/statement/QueryTest.java
index 56fcc5b..656c97c 100644
--- a/fastmodel-parser/src/test/java/com/aliyun/fastmodel/parser/statement/QueryTest.java
+++ b/fastmodel-parser/src/test/java/com/aliyun/fastmodel/parser/statement/QueryTest.java
@@ -32,7 +32,6 @@
import com.aliyun.fastmodel.core.tree.relation.Join;
import com.aliyun.fastmodel.core.tree.relation.join.JoinOn;
import com.aliyun.fastmodel.core.tree.relation.join.JoinToken;
-import com.aliyun.fastmodel.core.tree.relation.querybody.BaseQueryBody;
import com.aliyun.fastmodel.core.tree.relation.querybody.QuerySpecification;
import com.aliyun.fastmodel.core.tree.relation.querybody.Table;
import com.aliyun.fastmodel.core.tree.statement.select.Hint;
@@ -76,40 +75,40 @@ public void testUnion() {
+ " pk1\n"
+ " , pk2\n"
+ " , pk3\n"
- + " , null dim1\n"
- + " , null dim2\n"
- + " , null dim3\n"
+ + " , NULL dim1\n"
+ + " , NULL dim2\n"
+ + " , NULL dim3\n"
+ " , ind1\n"
+ " , ind2\n"
- + " , null ind3\n"
- + " , null ind4\n"
- + " , null ind5\n"
+ + " , NULL ind3\n"
+ + " , NULL ind4\n"
+ + " , NULL ind5\n"
+ " FROM\n"
+ " t1\n"
+ "UNION ALL SELECT\n"
+ " pk1\n"
+ " , pk2\n"
+ " , pk3\n"
- + " , null dim1\n"
- + " , null dim2\n"
- + " , null dim3\n"
- + " , null ind1\n"
- + " , null ind2\n"
+ + " , NULL dim1\n"
+ + " , NULL dim2\n"
+ + " , NULL dim3\n"
+ + " , NULL ind1\n"
+ + " , NULL ind2\n"
+ " , ind3\n"
- + " , null ind4\n"
- + " , null ind5\n"
+ + " , NULL ind4\n"
+ + " , NULL ind5\n"
+ " FROM\n"
+ " t2\n"
+ "UNION ALL SELECT\n"
+ " t2.pk1 pk1\n"
+ " , t2.pk2 pk2\n"
+ " , t2.pk3 pk3\n"
- + " , null dim1\n"
- + " , null dim2\n"
+ + " , NULL dim1\n"
+ + " , NULL dim2\n"
+ " , t2.dim3 dim3\n"
- + " , null ind1\n"
- + " , null ind2\n"
- + " , null ind3\n"
+ + " , NULL ind1\n"
+ + " , NULL ind2\n"
+ + " , NULL ind3\n"
+ " , t2.ind4 ind4\n"
+ " , t2.ind5 ind5\n"
+ " FROM\n"
diff --git a/fastmodel-transform/fastmodel-transform-api/pom.xml b/fastmodel-transform/fastmodel-transform-api/pom.xml
index cf12fd9..8e53251 100644
--- a/fastmodel-transform/fastmodel-transform-api/pom.xml
+++ b/fastmodel-transform/fastmodel-transform-api/pom.xml
@@ -46,5 +46,9 @@
fastmodel-compare
${project.parent.version}
+
+ com.alibaba
+ fastjson
+
\ No newline at end of file
diff --git a/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/client/converter/BaseClientConverter.java b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/client/converter/BaseClientConverter.java
index 1c0f881..db85ab2 100644
--- a/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/client/converter/BaseClientConverter.java
+++ b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/client/converter/BaseClientConverter.java
@@ -18,6 +18,7 @@
import java.util.stream.Collectors;
import java.util.stream.IntStream;
+import com.aliyun.fastmodel.core.parser.LanguageParser;
import com.aliyun.fastmodel.core.tree.Comment;
import com.aliyun.fastmodel.core.tree.Node;
import com.aliyun.fastmodel.core.tree.Property;
@@ -49,6 +50,10 @@
import com.aliyun.fastmodel.core.tree.statement.table.constraint.BaseConstraint;
import com.aliyun.fastmodel.core.tree.statement.table.constraint.PrimaryConstraint;
import com.aliyun.fastmodel.core.tree.statement.table.constraint.UniqueConstraint;
+import com.aliyun.fastmodel.core.tree.statement.table.index.IndexColumnName;
+import com.aliyun.fastmodel.core.tree.statement.table.index.IndexExpr;
+import com.aliyun.fastmodel.core.tree.statement.table.index.IndexSortKey;
+import com.aliyun.fastmodel.core.tree.statement.table.index.SortType;
import com.aliyun.fastmodel.core.tree.statement.table.index.TableIndex;
import com.aliyun.fastmodel.core.tree.util.IdentifierUtil;
import com.aliyun.fastmodel.core.tree.util.StringLiteralUtil;
@@ -57,6 +62,9 @@
import com.aliyun.fastmodel.transform.api.client.dto.constraint.Constraint;
import com.aliyun.fastmodel.transform.api.client.dto.constraint.ConstraintType;
import com.aliyun.fastmodel.transform.api.client.dto.constraint.OutlineConstraintType;
+import com.aliyun.fastmodel.transform.api.client.dto.index.Index;
+import com.aliyun.fastmodel.transform.api.client.dto.index.IndexKey;
+import com.aliyun.fastmodel.transform.api.client.dto.index.IndexSortType;
import com.aliyun.fastmodel.transform.api.client.dto.property.BaseClientProperty;
import com.aliyun.fastmodel.transform.api.client.dto.table.Column;
import com.aliyun.fastmodel.transform.api.client.dto.table.Table;
@@ -64,6 +72,8 @@
import com.aliyun.fastmodel.transform.api.context.TransformContext;
import com.aliyun.fastmodel.transform.api.datatype.simple.ISimpleDataTypeName;
import com.aliyun.fastmodel.transform.api.datatype.simple.SimpleDataTypeName;
+import com.aliyun.fastmodel.transform.api.extension.client.constraint.UniqueKeyExprClientConstraint;
+import com.aliyun.fastmodel.transform.api.extension.tree.constraint.UniqueKeyExprConstraint;
import com.aliyun.fastmodel.transform.api.util.StringJoinUtil;
import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
@@ -87,13 +97,20 @@ public abstract class BaseClientConverter implements
public static final int FIRST_INDEX = 1;
public static final int THIRD_INDEX = 3;
+ /**
+ * 获取语言解析器
+ *
+ * @return
+ */
+ public abstract LanguageParser getLanguageParser();
+
/**
* get DataType
*
* @param column
* @return
*/
- protected abstract BaseDataType getDataType(Column column);
+ public abstract BaseDataType getDataType(Column column);
/**
* get property converter
@@ -122,6 +139,10 @@ protected Boolean isExternal(CreateTable createTable) {
return false;
}
+ protected String formatExpression(BaseExpression baseExpression) {
+ return baseExpression.toString();
+ }
+
/**
* @param table
* @return {@link Node}
@@ -146,6 +167,7 @@ public Node covertToNode(Table table, TableConfig tableConfig) {
.tableIndex(tableIndexList)
.comment(comment)
.constraints(constraints)
+ .tableIndex(tableIndexList)
.properties(properties)
.build();
}
@@ -168,6 +190,7 @@ public Table convertToTable(Node table, T context) {
List columns = toTableColumns(createTable);
List constraints = toOutlineConstraint(createTable);
List properties = toBaseClientProperty(createTable);
+ List indices = toIndex(createTable);
return Table.builder()
.ifNotExist(createTable.isNotExists())
.external(external)
@@ -177,11 +200,113 @@ public Table convertToTable(Node table, T context) {
.lifecycleSeconds(toLifeCycleSeconds(createTable))
.columns(columns)
.constraints(constraints)
+ .indices(indices)
.properties(properties)
.build();
}
+ protected List toIndex(CreateTable createTable) {
+ if (createTable.isIndexEmpty()) {
+ return Collections.emptyList();
+ }
+ List tableIndexList = createTable.getTableIndexList();
+ List indices = Lists.newArrayList();
+ for (TableIndex index : tableIndexList) {
+ List indexSortKeys = index.getIndexColumnNames();
+ List collect = indexSortKeys.stream().map(i -> getIndexKey(i)).filter(Objects::nonNull).collect(Collectors.toList());
+ List es = Lists.newArrayList();
+ List properties = index.getProperties();
+ if (properties != null) {
+ for (Property p : properties) {
+ BaseClientProperty baseClientProperty = getPropertyConverter().create(p.getName(), p.getValue());
+ es.add(baseClientProperty);
+ }
+ }
+ Index constraint = Index.builder()
+ .name(index.getIndexName().getValue())
+ .indexKeys(collect)
+ .properties(es)
+ .build();
+ indices.add(constraint);
+ }
+ return indices;
+ }
+
+ private IndexKey getIndexKey(IndexSortKey i) {
+ IndexKey indexKey = IndexKey.builder().build();
+ if (i instanceof IndexColumnName) {
+ IndexColumnName indexColumnName = (IndexColumnName)i;
+ String column = indexColumnName.getColumnName().toString();
+ indexKey.setColumn(column);
+ if (indexColumnName.getColumnLength() != null) {
+ indexKey.setLength(indexColumnName.getColumnLength().getValue());
+ }
+ indexKey.setSortType(getIndexSortType(indexColumnName.getSortType()));
+ }
+ if (i instanceof IndexExpr) {
+ IndexExpr indexExpr = (IndexExpr)i;
+ BaseExpression expression = indexExpr.getExpression();
+ String formatExpression = formatExpression(expression);
+ indexKey.setExpression(formatExpression);
+ indexKey.setSortType(getIndexSortType(indexExpr.getSortType()));
+ }
+ return indexKey;
+ }
+
+ private IndexSortType getIndexSortType(SortType sortType) {
+ if (sortType == SortType.ASC) {
+ return IndexSortType.ASC;
+ }
+ if (sortType == SortType.DESC) {
+ return IndexSortType.DESC;
+ }
+ return null;
+ }
+
+ protected List toTableIndex(Table table, List columns) {
+ if (table == null || CollectionUtils.isEmpty(table.getIndices())) {
+ return Collections.emptyList();
+ }
+ return table.getIndices().stream().map(indexConstraint -> {
+ Identifier indexName = new Identifier(indexConstraint.getName());
+ List indexSortKeys = null;
+ List indexKeys = indexConstraint.getIndexKeys();
+ if (indexKeys != null) {
+ indexSortKeys = indexKeys.stream()
+ .map(indexKey -> getIndexSortKey(indexKey)).collect(Collectors.toList());
+ }
+
+ List properties = null;
+ if (CollectionUtils.isNotEmpty(indexConstraint.getProperties())) {
+ properties = indexConstraint.getProperties().stream().map(property -> {
+ return new Property(property.getKey(), (String)property.getValue());
+ }).collect(Collectors.toList());
+ }
+ return new TableIndex(indexName, indexSortKeys, properties);
+ }).collect(Collectors.toList());
+ }
+
+ private IndexSortKey getIndexSortKey(IndexKey indexKey) {
+ String column = indexKey.getColumn();
+ if (StringUtils.isNotBlank(column)) {
+ LongLiteral length = indexKey.getLength() != null ? new LongLiteral(String.valueOf(indexKey.getLength())) : null;
+ return new IndexColumnName(new Identifier(column), length, getSortType(indexKey.getSortType()));
+ } else {
+ BaseExpression o = (BaseExpression)getLanguageParser().parseExpression(indexKey.getExpression());
+ IndexExpr indexExpr = new IndexExpr(o, getSortType(indexKey.getSortType()));
+ return indexExpr;
+ }
+ }
+ private SortType getSortType(IndexSortType sortType) {
+ if (sortType == IndexSortType.ASC) {
+ return SortType.ASC;
+ }
+ if (sortType == IndexSortType.DESC) {
+ return SortType.DESC;
+ }
+ return null;
+ }
protected String toSchema(CreateTable createTable, T transformContext) {
QualifiedName qualifiedName = createTable.getQualifiedName();
@@ -199,6 +324,13 @@ protected String toSchema(CreateTable createTable, T transformContext) {
return transformContext.getSchema();
}
+ /**
+ * get database
+ *
+ * @param createTable
+ * @param database
+ * @return
+ */
protected String toDatabase(CreateTable createTable, String database) {
QualifiedName qualifiedName = createTable.getQualifiedName();
boolean isThirdSchema = qualifiedName.isJoinPath() && qualifiedName.getOriginalParts().size() == THIRD_INDEX;
@@ -430,10 +562,6 @@ protected PartitionedBy toPartitionedBy(Table table, List columns) {
return new PartitionedBy(collect);
}
- protected List toTableIndex(Table table, List columns) {
- return Collections.emptyList();
- }
-
/**
* to constraint
*
@@ -464,14 +592,47 @@ protected List toConstraint(List columns, List indexSortKeys = toIndexSortKey(u);
+ UniqueKeyExprConstraint keyExprConstraint = new UniqueKeyExprConstraint(
+ constraintName, null, indexSortKeys, null
+ );
+ constraintList.add(keyExprConstraint);
+ } else {
+ UniqueConstraint primaryConstraint = new UniqueConstraint(constraintName,
+ c.getColumns().stream().map(Identifier::new).collect(Collectors.toList()));
+ constraintList.add(primaryConstraint);
+ }
}
}
return constraintList;
}
+ private List toIndexSortKey(UniqueKeyExprClientConstraint u) {
+ if (CollectionUtils.isNotEmpty(u.getExpression())) {
+ return u.getExpression().stream().map(
+ c -> {
+ BaseExpression baseExpression = (BaseExpression)getLanguageParser().parseExpression(c);
+ IndexExpr indexExpr = new IndexExpr(baseExpression, null);
+ return indexExpr;
+ }
+ ).collect(Collectors.toList());
+ }
+ if (CollectionUtils.isNotEmpty(u.getColumns())) {
+ return u.getColumns().stream().map(
+ c -> {
+ IndexColumnName indexColumnName = new IndexColumnName(
+ new Identifier(c),
+ null, null
+ );
+ return indexColumnName;
+ }
+ ).collect(Collectors.toList());
+ }
+ return null;
+ }
+
protected BaseConstraint setPrimaryConstraintColumns(List columns) {
if (CollectionUtils.isEmpty(columns)) {
return null;
@@ -498,7 +659,6 @@ protected Column getColumn(ColumnDefinition c, boolean partitionKey, Integer par
.id(c.getColName().getValue())
.name(c.getColName().getValue())
.comment(c.getCommentValue())
- .id(c.getColName().getValue())
.dataType(dataType.getTypeName().getValue())
.nullable(BooleanUtils.isNotTrue(c.getNotNull()))
.primaryKey(BooleanUtils.isTrue(c.getPrimary()))
@@ -623,4 +783,4 @@ public final boolean contains(List list, ColumnDefinition columnDefiniti
return list.stream().anyMatch(c -> Objects.equals(new Identifier(c.getName()), columnDefinition.getColName()));
}
-}
+}
\ No newline at end of file
diff --git a/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/client/dto/index/Index.java b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/client/dto/index/Index.java
new file mode 100644
index 0000000..a5ed675
--- /dev/null
+++ b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/client/dto/index/Index.java
@@ -0,0 +1,38 @@
+package com.aliyun.fastmodel.transform.api.client.dto.index;
+
+import java.util.List;
+
+import com.aliyun.fastmodel.transform.api.client.dto.property.BaseClientProperty;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+/**
+ * Index 索引
+ *
+ * @author panguanjing
+ * @date 2024/2/19
+ */
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+@Data
+public class Index {
+ /**
+ * 索引名称
+ */
+ private String name;
+
+ /**
+ * 列
+ */
+ private List indexKeys;
+
+
+ /**
+ * client properties
+ */
+ private List properties;
+
+}
diff --git a/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/client/dto/index/IndexKey.java b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/client/dto/index/IndexKey.java
new file mode 100644
index 0000000..1a8137b
--- /dev/null
+++ b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/client/dto/index/IndexKey.java
@@ -0,0 +1,23 @@
+package com.aliyun.fastmodel.transform.api.client.dto.index;
+
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+/**
+ * Desc:
+ *
+ * @author panguanjing
+ * @date 2024/2/19
+ */
+@Data
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+public class IndexKey {
+ private String column;
+ private String expression;
+ private Long length;
+ private IndexSortType sortType;
+}
diff --git a/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/client/dto/index/IndexSortType.java b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/client/dto/index/IndexSortType.java
new file mode 100644
index 0000000..4e9e5c5
--- /dev/null
+++ b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/client/dto/index/IndexSortType.java
@@ -0,0 +1,9 @@
+package com.aliyun.fastmodel.transform.api.client.dto.index;
+
+/**
+ * sort type
+ */
+public enum IndexSortType {
+ ASC,
+ DESC
+}
diff --git a/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/client/dto/table/Table.java b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/client/dto/table/Table.java
index 55a0b43..7e52637 100644
--- a/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/client/dto/table/Table.java
+++ b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/client/dto/table/Table.java
@@ -11,6 +11,7 @@
import java.util.List;
import com.aliyun.fastmodel.transform.api.client.dto.constraint.Constraint;
+import com.aliyun.fastmodel.transform.api.client.dto.index.Index;
import com.aliyun.fastmodel.transform.api.client.dto.property.BaseClientProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
@@ -23,6 +24,7 @@
*
* @author panguanjing
* @date 2022/6/6
+ * @date 2024/2/19 add the index
*/
@Data
@Builder
@@ -71,6 +73,11 @@ public class Table {
*/
private List constraints;
+ /**
+ * 索引列表
+ */
+ private List indices;
+
/**
* 生命周期, 单位秒
*/
diff --git a/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/dialect/DialectMeta.java b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/dialect/DialectMeta.java
index 6ebb51e..30beabc 100644
--- a/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/dialect/DialectMeta.java
+++ b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/dialect/DialectMeta.java
@@ -48,6 +48,16 @@ public class DialectMeta {
*/
public static final DialectMeta DEFAULT_STARROCKS = createDefault(DialectName.STARROCKS);
+ /**
+ * starRocks
+ */
+ public static final DialectMeta DEFAULT_DORIS = createDefault(DialectName.DORIS);
+
+ /**
+ * oceanbase mysql
+ */
+ public static final DialectMeta DEFAULT_OB_MYSQL = createDefault(DialectName.OB_MYSQL);
+
/**
* 引擎的名字,唯一标示,大小写不敏感
*/
diff --git a/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/dialect/DialectName.java b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/dialect/DialectName.java
index 6d0bd2b..fc3caf7 100644
--- a/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/dialect/DialectName.java
+++ b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/dialect/DialectName.java
@@ -117,9 +117,22 @@ public enum DialectName implements IDialectName {
/**
* StarRocks
*/
- STARROCKS(Constants.STARROCKS)
+ STARROCKS(Constants.STARROCKS),
- ;
+ /**
+ * Doris
+ */
+ DORIS(Constants.DORIS),
+
+ /**
+ * ObMysql
+ */
+ OB_MYSQL(Constants.OB_MYSQL),
+
+ /**
+ * ObOracle
+ */
+ OB_ORACLE(Constants.OB_ORACLE);
@Getter
private final String value;
@@ -147,6 +160,9 @@ public static class Constants {
public static final String SQLITE = "SQLITE";
public static final String JSON = "JSON";
public static final String STARROCKS = "STAR_ROCKS";
+ public static final String DORIS = "DORIS";
+ public static final String OB_MYSQL = "OB_MYSQL";
+ public static final String OB_ORACLE = "OB_ORACLE";
}
public static DialectName getByCode(String name) {
diff --git a/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/domain/factory/DomainFactorys.java b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/domain/factory/DomainFactorySingleton.java
similarity index 96%
rename from fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/domain/factory/DomainFactorys.java
rename to fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/domain/factory/DomainFactorySingleton.java
index aac3966..8c40c22 100644
--- a/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/domain/factory/DomainFactorys.java
+++ b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/domain/factory/DomainFactorySingleton.java
@@ -26,7 +26,7 @@
* @author panguanjing
* @date 2021/12/12
*/
-public class DomainFactorys {
+public class DomainFactorySingleton {
private static final TableDomainFactory INSTANCE = new TableDomainFactory();
diff --git a/fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/client/constraint/StarRocksConstraintType.java b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/client/constraint/ClientConstraintType.java
similarity index 66%
rename from fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/client/constraint/StarRocksConstraintType.java
rename to fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/client/constraint/ClientConstraintType.java
index 9de9b3d..de65d3d 100644
--- a/fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/client/constraint/StarRocksConstraintType.java
+++ b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/client/constraint/ClientConstraintType.java
@@ -1,4 +1,4 @@
-package com.aliyun.fastmodel.transform.starrocks.client.constraint;
+package com.aliyun.fastmodel.transform.api.extension.client.constraint;
import com.aliyun.fastmodel.transform.api.client.dto.constraint.ConstraintType;
import lombok.Getter;
@@ -10,7 +10,7 @@
* @date 2023/12/13
*/
@Getter
-public enum StarRocksConstraintType implements ConstraintType {
+public enum ClientConstraintType implements ConstraintType {
AGGREGATE_KEY("aggregate_key"),
@@ -24,10 +24,6 @@ public enum StarRocksConstraintType implements ConstraintType {
*/
PRIMARY_KEY(com.aliyun.fastmodel.core.tree.statement.constants.ConstraintType.PRIMARY_KEY.getCode()),
- /**
- * index
- */
- INDEX(com.aliyun.fastmodel.core.tree.statement.constants.ConstraintType.INDEX.getCode()),
/**
* order by
*/
@@ -40,15 +36,15 @@ public enum StarRocksConstraintType implements ConstraintType {
private final String code;
- StarRocksConstraintType(String code) {this.code = code;}
+ ClientConstraintType(String code) {this.code = code;}
@Override
public String getCode() {
return code;
}
- public static StarRocksConstraintType getByValue(String value) {
- for (StarRocksConstraintType starRocksConstraintType : StarRocksConstraintType.values()) {
+ public static ClientConstraintType getByValue(String value) {
+ for (ClientConstraintType starRocksConstraintType : ClientConstraintType.values()) {
if (starRocksConstraintType.code.equalsIgnoreCase(value)) {
return starRocksConstraintType;
}
diff --git a/fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/client/constraint/StarRocksDistributeConstraint.java b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/client/constraint/DistributeClientConstraint.java
similarity index 62%
rename from fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/client/constraint/StarRocksDistributeConstraint.java
rename to fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/client/constraint/DistributeClientConstraint.java
index 8c84afc..39a8cb4 100644
--- a/fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/client/constraint/StarRocksDistributeConstraint.java
+++ b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/client/constraint/DistributeClientConstraint.java
@@ -1,4 +1,4 @@
-package com.aliyun.fastmodel.transform.starrocks.client.constraint;
+package com.aliyun.fastmodel.transform.api.extension.client.constraint;
import com.aliyun.fastmodel.transform.api.client.dto.constraint.Constraint;
import lombok.Data;
@@ -12,7 +12,7 @@
*/
@EqualsAndHashCode(callSuper = true)
@Data
-public class StarRocksDistributeConstraint extends Constraint {
+public class DistributeClientConstraint extends Constraint {
/**
* 是否random
*/
@@ -23,7 +23,7 @@ public class StarRocksDistributeConstraint extends Constraint {
*/
private Integer bucket;
- public StarRocksDistributeConstraint() {
- this.setType(StarRocksConstraintType.DISTRIBUTE);
+ public DistributeClientConstraint() {
+ this.setType(ClientConstraintType.DISTRIBUTE);
}
}
diff --git a/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/client/constraint/UniqueKeyExprClientConstraint.java b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/client/constraint/UniqueKeyExprClientConstraint.java
new file mode 100644
index 0000000..3bd0b06
--- /dev/null
+++ b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/client/constraint/UniqueKeyExprClientConstraint.java
@@ -0,0 +1,22 @@
+package com.aliyun.fastmodel.transform.api.extension.client.constraint;
+
+import java.util.List;
+
+import com.aliyun.fastmodel.transform.api.client.dto.constraint.Constraint;
+import lombok.Data;
+
+/**
+ * unique key expr constraint
+ *
+ * @author panguanjing
+ * @date 2024/2/19
+ */
+@Data
+public class UniqueKeyExprClientConstraint extends Constraint {
+
+ private List expression;
+
+ public UniqueKeyExprClientConstraint() {
+ this.setType(ClientConstraintType.UNIQUE_KEY);
+ }
+}
diff --git a/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/client/converter/ExtensionClientConverter.java b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/client/converter/ExtensionClientConverter.java
new file mode 100644
index 0000000..cd5d587
--- /dev/null
+++ b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/client/converter/ExtensionClientConverter.java
@@ -0,0 +1,684 @@
+package com.aliyun.fastmodel.transform.api.extension.client.converter;
+
+import java.util.ArrayList;
+import java.util.Comparator;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Optional;
+import java.util.stream.Collectors;
+
+import com.aliyun.fastmodel.core.tree.Node;
+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.IDataTypeName;
+import com.aliyun.fastmodel.core.tree.datatype.IDataTypeName.Dimension;
+import com.aliyun.fastmodel.core.tree.expr.BaseExpression;
+import com.aliyun.fastmodel.core.tree.expr.Identifier;
+import com.aliyun.fastmodel.core.tree.expr.atom.FunctionCall;
+import com.aliyun.fastmodel.core.tree.expr.enums.DateTimeEnum;
+import com.aliyun.fastmodel.core.tree.expr.literal.IntervalLiteral;
+import com.aliyun.fastmodel.core.tree.expr.literal.ListStringLiteral;
+import com.aliyun.fastmodel.core.tree.expr.literal.LongLiteral;
+import com.aliyun.fastmodel.core.tree.expr.literal.StringLiteral;
+import com.aliyun.fastmodel.core.tree.statement.table.ColumnDefinition;
+import com.aliyun.fastmodel.core.tree.statement.table.CreateTable;
+import com.aliyun.fastmodel.core.tree.statement.table.PartitionedBy;
+import com.aliyun.fastmodel.core.tree.statement.table.constraint.BaseConstraint;
+import com.aliyun.fastmodel.core.tree.util.IdentifierUtil;
+import com.aliyun.fastmodel.core.tree.util.StringLiteralUtil;
+import com.aliyun.fastmodel.transform.api.client.converter.BaseClientConverter;
+import com.aliyun.fastmodel.transform.api.client.dto.constraint.Constraint;
+import com.aliyun.fastmodel.transform.api.client.dto.constraint.ConstraintType;
+import com.aliyun.fastmodel.transform.api.client.dto.property.BaseClientProperty;
+import com.aliyun.fastmodel.transform.api.client.dto.property.StringProperty;
+import com.aliyun.fastmodel.transform.api.client.dto.table.Column;
+import com.aliyun.fastmodel.transform.api.client.dto.table.Table;
+import com.aliyun.fastmodel.transform.api.context.ReverseContext;
+import com.aliyun.fastmodel.transform.api.context.TransformContext;
+import com.aliyun.fastmodel.transform.api.datatype.simple.ISimpleDataTypeName;
+import com.aliyun.fastmodel.transform.api.datatype.simple.SimpleDataTypeName;
+import com.aliyun.fastmodel.transform.api.extension.client.constraint.ClientConstraintType;
+import com.aliyun.fastmodel.transform.api.extension.client.constraint.DistributeClientConstraint;
+import com.aliyun.fastmodel.transform.api.extension.client.property.table.ColumnExpressionPartitionProperty;
+import com.aliyun.fastmodel.transform.api.extension.client.property.table.ListPartitionProperty;
+import com.aliyun.fastmodel.transform.api.extension.client.property.table.MultiRangePartitionProperty;
+import com.aliyun.fastmodel.transform.api.extension.client.property.table.SingleRangePartitionProperty;
+import com.aliyun.fastmodel.transform.api.extension.client.property.table.TablePartitionRaw;
+import com.aliyun.fastmodel.transform.api.extension.client.property.table.TimeExpressionPartitionProperty;
+import com.aliyun.fastmodel.transform.api.extension.client.property.table.partition.ArrayClientPartitionKey;
+import com.aliyun.fastmodel.transform.api.extension.client.property.table.partition.BaseClientPartitionKey;
+import com.aliyun.fastmodel.transform.api.extension.client.property.table.partition.ColumnExpressionClientPartition;
+import com.aliyun.fastmodel.transform.api.extension.client.property.table.partition.LessThanClientPartitionKey;
+import com.aliyun.fastmodel.transform.api.extension.client.property.table.partition.ListClientPartition;
+import com.aliyun.fastmodel.transform.api.extension.client.property.table.partition.MultiRangeClientPartition;
+import com.aliyun.fastmodel.transform.api.extension.client.property.table.partition.PartitionClientValue;
+import com.aliyun.fastmodel.transform.api.extension.client.property.table.partition.SingleRangeClientPartition;
+import com.aliyun.fastmodel.transform.api.extension.client.property.table.partition.TimeExpressionClientPartition;
+import com.aliyun.fastmodel.transform.api.extension.tree.constraint.AggregateKeyConstraint;
+import com.aliyun.fastmodel.transform.api.extension.tree.constraint.DuplicateKeyConstraint;
+import com.aliyun.fastmodel.transform.api.extension.tree.constraint.desc.DistributeConstraint;
+import com.aliyun.fastmodel.transform.api.extension.tree.constraint.desc.OrderByConstraint;
+import com.aliyun.fastmodel.transform.api.extension.tree.partition.ExpressionPartitionBy;
+import com.aliyun.fastmodel.transform.api.extension.tree.partition.ListPartitionedBy;
+import com.aliyun.fastmodel.transform.api.extension.tree.partition.RangePartitionedBy;
+import com.aliyun.fastmodel.transform.api.extension.tree.partition.desc.MultiItemListPartition;
+import com.aliyun.fastmodel.transform.api.extension.tree.partition.desc.MultiRangePartition;
+import com.aliyun.fastmodel.transform.api.extension.tree.partition.desc.PartitionDesc;
+import com.aliyun.fastmodel.transform.api.extension.tree.partition.desc.SingleItemListPartition;
+import com.aliyun.fastmodel.transform.api.extension.tree.partition.desc.SingleRangePartition;
+import com.aliyun.fastmodel.transform.api.extension.tree.partition.keyvalue.ArrayPartitionKey;
+import com.aliyun.fastmodel.transform.api.extension.tree.partition.keyvalue.LessThanPartitionKey;
+import com.aliyun.fastmodel.transform.api.extension.tree.partition.keyvalue.ListPartitionValue;
+import com.aliyun.fastmodel.transform.api.extension.tree.partition.keyvalue.PartitionKey;
+import com.aliyun.fastmodel.transform.api.extension.tree.partition.keyvalue.PartitionValue;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.lang3.BooleanUtils;
+import org.apache.commons.lang3.StringUtils;
+
+import static com.aliyun.fastmodel.transform.api.extension.client.property.ExtensionPropertyKey.TABLE_EXPRESSION_PARTITION;
+import static com.aliyun.fastmodel.transform.api.extension.client.property.ExtensionPropertyKey.TABLE_LIST_PARTITION;
+import static com.aliyun.fastmodel.transform.api.extension.client.property.ExtensionPropertyKey.TABLE_PARTITION_RAW;
+import static com.aliyun.fastmodel.transform.api.extension.client.property.ExtensionPropertyKey.TABLE_RANGE_PARTITION;
+
+/**
+ * ExtensionClientConverter
+ *
+ * @author panguanjing
+ * @date 2024/1/21
+ */
+public abstract class ExtensionClientConverter extends BaseClientConverter {
+
+ public static final String UUID = "uuid";
+ public static final String UUID_NUMERIC = "uuid_numeric";
+ public static final String SUFFIX = "()";
+
+ /**
+ * 根据dataTypeName返回类型定义
+ *
+ * @param dataTypeName
+ * @return
+ */
+ public abstract IDataTypeName getDataTypeName(String dataTypeName);
+
+ /**
+ * 根据节点返回文本信息
+ *
+ * @param node
+ * @return
+ */
+ public abstract String getRaw(Node node);
+
+ @Override
+ public List toBaseClientProperty(CreateTable createTable) {
+ List propertyList = Lists.newArrayList();
+ if (!createTable.isPropertyEmpty()) {
+ List properties = createTable.getProperties();
+ for (Property property : properties) {
+ BaseClientProperty baseClientProperty = getPropertyConverter().create(property.getName(), property.getValue());
+ propertyList.add(baseClientProperty);
+ }
+ }
+ PartitionedBy partitionedBy = createTable.getPartitionedBy();
+ if (partitionedBy instanceof RangePartitionedBy) {
+ processRangePartition((RangePartitionedBy)partitionedBy, propertyList);
+ }
+
+ if (partitionedBy instanceof ListPartitionedBy) {
+ processListPartition((ListPartitionedBy)partitionedBy, propertyList);
+ }
+
+ if (partitionedBy instanceof ExpressionPartitionBy) {
+ processExpressionPartition((ExpressionPartitionBy)partitionedBy, propertyList);
+ }
+
+ return propertyList;
+ }
+
+ private void processRangePartition(RangePartitionedBy rangePartitionedBy, List propertyList) {
+ List rangePartitions = rangePartitionedBy.getRangePartitions();
+ List list = Lists.newArrayList();
+ //结构化的返回
+ if (rangePartitions != null) {
+ for (PartitionDesc partitionDesc : rangePartitions) {
+ BaseClientProperty baseClientProperty = parseRangePartition(partitionDesc);
+ if (baseClientProperty != null) {
+ list.add(baseClientProperty);
+ }
+ }
+ }
+ //如果解析不了,那么使用visitor的方式进行解析
+ if (list.isEmpty()) {
+ TablePartitionRaw baseClientProperty = new TablePartitionRaw();
+ baseClientProperty.setKey(TABLE_PARTITION_RAW.getValue());
+ String raw = getRaw(rangePartitionedBy);
+ baseClientProperty.setValueString(raw);
+ propertyList.add(baseClientProperty);
+ } else {
+ propertyList.addAll(list);
+ }
+ }
+
+ private void processListPartition(ListPartitionedBy listPartitionedBy, List propertyList) {
+ List listPartitions = listPartitionedBy.getListPartitions();
+ //结构化的返回
+ List list = Lists.newArrayList();
+ if (listPartitions != null) {
+ for (PartitionDesc partitionDesc : listPartitions) {
+ BaseClientProperty baseClientProperty = parseListPartition(partitionDesc);
+ if (baseClientProperty != null) {
+ list.add(baseClientProperty);
+ }
+ }
+ }
+
+ //如果解析不了,那么使用visitor的方式进行解析
+ if (list.isEmpty()) {
+ String raw = getRaw(listPartitionedBy);
+ StringProperty baseClientProperty = new StringProperty();
+ baseClientProperty.setKey(TABLE_PARTITION_RAW.getValue());
+ baseClientProperty.setValueString(raw);
+ propertyList.add(baseClientProperty);
+ } else {
+ propertyList.addAll(list);
+ }
+ }
+
+ private void processExpressionPartition(ExpressionPartitionBy expressionPartitionBy,
+ List propertyList) {
+ FunctionCall functionCall = expressionPartitionBy.getFunctionCall();
+ if (functionCall == null) {
+ // 列表达式
+ ColumnExpressionClientPartition partition = new ColumnExpressionClientPartition();
+ List columnNameList = expressionPartitionBy.getColumnDefinitions().stream()
+ .map(columnDefinition -> columnDefinition.getColName().getValue())
+ .collect(Collectors.toList());
+ partition.setColumnNameList(columnNameList);
+
+ ColumnExpressionPartitionProperty columnExpressionPartitionProperty = new ColumnExpressionPartitionProperty();
+ columnExpressionPartitionProperty.setValue(partition);
+ propertyList.add(columnExpressionPartitionProperty);
+ } else {
+ // 时间函数表达式
+ TimeExpressionClientPartition timeExpressionClientPartition = new TimeExpressionClientPartition();
+ timeExpressionClientPartition.setFuncName(functionCall.getFuncName().getFirst());
+ if (expressionPartitionBy.getTimeUnitArg() != null) {
+ timeExpressionClientPartition.setTimeUnit(StringLiteralUtil.strip(expressionPartitionBy.getTimeUnitArg().getOrigin()));
+ }
+ if (expressionPartitionBy.getIntervalLiteralArg() != null) {
+ timeExpressionClientPartition.setInterval(expressionPartitionBy.getIntervalLiteralArg());
+ }
+
+ //property
+ TimeExpressionPartitionProperty timeExpressionPartitionProperty = new TimeExpressionPartitionProperty();
+ timeExpressionPartitionProperty.setValue(timeExpressionClientPartition);
+ propertyList.add(timeExpressionPartitionProperty);
+ }
+ }
+
+ /**
+ * 将partition desc转为 baseClientProperty
+ *
+ * @param partitionDesc
+ */
+ private BaseClientProperty parseRangePartition(PartitionDesc partitionDesc) {
+ if (partitionDesc instanceof SingleRangePartition) {
+ SingleRangePartition singleRangePartition = (SingleRangePartition)partitionDesc;
+ SingleRangeClientPartition rangePartitionValue = new SingleRangeClientPartition();
+ rangePartitionValue.setName(singleRangePartition.getName().getValue());
+ rangePartitionValue.setIfNotExists(singleRangePartition.isIfNotExists());
+ List propertyList = singleRangePartition.getPropertyList();
+ if (propertyList != null && !propertyList.isEmpty()) {
+ LinkedHashMap linkedHashMap = Maps.newLinkedHashMap();
+ for (Property p : propertyList) {
+ linkedHashMap.put(p.getName(), p.getValue());
+ }
+ rangePartitionValue.setProperties(linkedHashMap);
+ }
+ BaseClientPartitionKey partitionKey = toClientPartitionKey(singleRangePartition.getPartitionKey());
+ rangePartitionValue.setPartitionKey(partitionKey);
+
+ //property
+ SingleRangePartitionProperty singleRangePartitionProperty = new SingleRangePartitionProperty();
+ singleRangePartitionProperty.setValue(rangePartitionValue);
+ return singleRangePartitionProperty;
+
+ } else if (partitionDesc instanceof MultiRangePartition) {
+ MultiRangePartition multiRangePartition = (MultiRangePartition)partitionDesc;
+ MultiRangeClientPartition multiRangePartitionValue = new MultiRangeClientPartition();
+ ListPartitionValue start = multiRangePartition.getStart();
+ String startRaw = getRaw(start);
+ multiRangePartitionValue.setStart(StringLiteralUtil.strip(startRaw));
+ ListPartitionValue end = multiRangePartition.getEnd();
+ String endRaw = getRaw(end);
+ multiRangePartitionValue.setEnd(StringLiteralUtil.strip(endRaw));
+ if (multiRangePartition.getLongLiteral() != null) {
+ LongLiteral longLiteral = multiRangePartition.getLongLiteral();
+ multiRangePartitionValue.setInterval(longLiteral.getValue());
+ }
+ IntervalLiteral intervalLiteral = multiRangePartition.getIntervalLiteral();
+ if (intervalLiteral != null) {
+ DateTimeEnum fromDateTime = intervalLiteral.getFromDateTime();
+ multiRangePartitionValue.setDateTimeEnum(fromDateTime);
+ LongLiteral value = (LongLiteral)intervalLiteral.getValue();
+ multiRangePartitionValue.setInterval(value.getValue());
+ }
+ //property
+ MultiRangePartitionProperty multiRangePartitionProperty = new MultiRangePartitionProperty();
+ multiRangePartitionProperty.setValue(multiRangePartitionValue);
+ return multiRangePartitionProperty;
+ }
+ return null;
+ }
+
+ private BaseClientProperty parseListPartition(PartitionDesc partitionDesc) {
+ if (partitionDesc instanceof SingleItemListPartition) {
+ SingleItemListPartition singleListPartition = (SingleItemListPartition)partitionDesc;
+ ListClientPartition listPartitionValue = new ListClientPartition();
+ listPartitionValue.setName(singleListPartition.getName().getOrigin());
+ List> partitionValue = singleListPartition.getListStringLiteral()
+ .getStringLiteralList().stream()
+ .map(stringLiteral -> {
+ PartitionClientValue partitionClientValue = PartitionClientValue.builder()
+ .value(StringLiteralUtil.strip(stringLiteral.getValue())).build();
+ return Lists.newArrayList(partitionClientValue);
+ }).collect(Collectors.toList());
+ ArrayClientPartitionKey arrayClientPartitionKey = ArrayClientPartitionKey.builder()
+ .partitionValue(partitionValue).build();
+ listPartitionValue.setPartitionKey(arrayClientPartitionKey);
+
+ //property
+ ListPartitionProperty listPartitionProperty = new ListPartitionProperty();
+ listPartitionProperty.setValue(listPartitionValue);
+ return listPartitionProperty;
+ } else if (partitionDesc instanceof MultiItemListPartition) {
+ MultiItemListPartition multiItemListPartition = (MultiItemListPartition)partitionDesc;
+ ListClientPartition listPartitionValue = new ListClientPartition();
+ listPartitionValue.setName(multiItemListPartition.getName().getOrigin());
+ List> partitionValue = multiItemListPartition.getListStringLiterals().stream()
+ .map(listStringLiteral -> listStringLiteral.getStringLiteralList().stream()
+ .map(stringLiteral -> PartitionClientValue.builder()
+ .value(StringLiteralUtil.strip(stringLiteral.getValue())).build())
+ .collect(Collectors.toList())).collect(Collectors.toList());
+ ArrayClientPartitionKey arrayClientPartitionKey = ArrayClientPartitionKey.builder()
+ .partitionValue(partitionValue).build();
+ listPartitionValue.setPartitionKey(arrayClientPartitionKey);
+
+ //property
+ ListPartitionProperty listPartitionProperty = new ListPartitionProperty();
+ listPartitionProperty.setValue(listPartitionValue);
+ return listPartitionProperty;
+ }
+ return null;
+ }
+
+ public BaseClientPartitionKey toClientPartitionKey(PartitionKey partitionKey) {
+ if (partitionKey instanceof ArrayPartitionKey) {
+ ArrayPartitionKey arrayPartitionKey = (ArrayPartitionKey)partitionKey;
+ List partitionValues1 = arrayPartitionKey.getPartitionValues();
+ ArrayClientPartitionKey arrayClientPartitionKey = new ArrayClientPartitionKey();
+ List> partitionValues = partitionValues1.stream().map(x -> {
+ List partitionValueList = x.getPartitionValueList();
+ return partitionValueList.stream().map(p -> {
+ PartitionClientValue partitionClientValue = new PartitionClientValue();
+ partitionClientValue.setMaxValue(p.isMaxValue());
+ if (p.getStringLiteral() != null) {
+ StringLiteral stringLiteral = (StringLiteral)p.getStringLiteral();
+ partitionClientValue.setValue(stringLiteral.getValue());
+ }
+ return partitionClientValue;
+ }).collect(Collectors.toList());
+ }).collect(Collectors.toList());
+ arrayClientPartitionKey.setPartitionValue(partitionValues);
+ return arrayClientPartitionKey;
+ } else if (partitionKey instanceof LessThanPartitionKey) {
+ LessThanPartitionKey lessThanPartitionKey = (LessThanPartitionKey)partitionKey;
+ LessThanClientPartitionKey lessThanClientPartitionKey = new LessThanClientPartitionKey();
+ if (BooleanUtils.isTrue(lessThanPartitionKey.isMaxValue())) {
+ lessThanClientPartitionKey.setMaxValue(lessThanPartitionKey.isMaxValue());
+ } else {
+ List list = getPartitionClientValues(lessThanPartitionKey);
+ lessThanClientPartitionKey.setPartitionValueList(list);
+ }
+ return lessThanClientPartitionKey;
+ }
+ return null;
+ }
+
+ private List getPartitionClientValues(LessThanPartitionKey lessThanPartitionKey) {
+ ListPartitionValue partitionValues = lessThanPartitionKey.getPartitionValues();
+ List list = partitionValues.getPartitionValueList().stream().map(
+ x -> {
+ PartitionClientValue partitionClientValue = new PartitionClientValue();
+ partitionClientValue.setMaxValue(x.isMaxValue());
+ if (x.getStringLiteral() != null) {
+ String raw = getRaw(x.getStringLiteral());
+ partitionClientValue.setValue(StringLiteralUtil.strip(raw));
+ }
+ return partitionClientValue;
+ }
+ ).collect(Collectors.toList());
+ return list;
+ }
+
+ @Override
+ protected PartitionedBy toPartitionedBy(Table table, List columns) {
+ List properties = table.getProperties();
+ List list = columns.stream()
+ .filter(Column::isPartitionKey)
+ .sorted(Comparator.comparing(Column::getPartitionKeyIndex))
+ .map(x -> {
+ List clientProperties = x.getProperties();
+ return ColumnDefinition.builder().colName(new Identifier(x.getName()))
+ .properties(toProperty(table, clientProperties))
+ .build();
+ })
+ .collect(Collectors.toList());
+ return toPartition(list, properties);
+ }
+
+ private PartitionedBy toPartition(List columnDefinitionList, List properties) {
+ if (properties == null || properties.isEmpty()) {
+ return null;
+ }
+
+ // range partition
+ List rangePartitionProperties = properties.stream().filter(property ->
+ StringUtils.equalsIgnoreCase(property.getKey(), TABLE_RANGE_PARTITION.getValue()))
+ .collect(Collectors.toList());
+ if (CollectionUtils.isNotEmpty(rangePartitionProperties)) {
+ List list = Lists.newArrayList();
+ rangePartitionProperties.forEach(property -> toRangePartition(list, property));
+ return new RangePartitionedBy(columnDefinitionList, list);
+ }
+
+ // list partition
+ List listPartitionProperties = properties.stream().filter(property ->
+ StringUtils.equalsIgnoreCase(property.getKey(), TABLE_LIST_PARTITION.getValue()))
+ .collect(Collectors.toList());
+ if (CollectionUtils.isNotEmpty(listPartitionProperties)) {
+ List list = Lists.newArrayList();
+ listPartitionProperties.forEach(property -> toListPartition(list, columnDefinitionList, property));
+ return new ListPartitionedBy(columnDefinitionList, list);
+ }
+
+ // expression partition
+ List expressionPartitionProperties = properties.stream().filter(property ->
+ StringUtils.equalsIgnoreCase(property.getKey(), TABLE_EXPRESSION_PARTITION.getValue()))
+ .collect(Collectors.toList());
+ if (CollectionUtils.isNotEmpty(expressionPartitionProperties)) {
+ FunctionCall functionCall = buildFunctionCall(expressionPartitionProperties.get(0));
+ return new ExpressionPartitionBy(columnDefinitionList, functionCall, null);
+ }
+
+ return null;
+ }
+
+ private void toRangePartition(List list, BaseClientProperty baseClientProperty) {
+ if (baseClientProperty instanceof SingleRangePartitionProperty) {
+ SingleRangePartitionProperty baseClientProperty1 = (SingleRangePartitionProperty)baseClientProperty;
+ PartitionDesc rangePartition = getPartitionDesc(baseClientProperty1.getValue());
+ list.add(rangePartition);
+ } else if (baseClientProperty instanceof MultiRangePartitionProperty) {
+ MultiRangePartitionProperty multiRangePartitionProperty = (MultiRangePartitionProperty)baseClientProperty;
+ MultiRangeClientPartition value = multiRangePartitionProperty.getValue();
+ LongLiteral longLiteral = new LongLiteral(String.valueOf(value.getInterval()));
+ PartitionDesc rangePartition = new MultiRangePartition(
+ new StringLiteral(value.getStart()),
+ new StringLiteral(value.getEnd()),
+ value.getDateTimeEnum() != null ? new IntervalLiteral(longLiteral, value.getDateTimeEnum()) : null,
+ value.getDateTimeEnum() == null ? longLiteral : null
+ );
+ list.add(rangePartition);
+ }
+ }
+
+ public PartitionDesc getPartitionDesc(SingleRangeClientPartition rangePartitionValue) {
+ BaseClientPartitionKey partitionKeyValue = rangePartitionValue.getPartitionKey();
+ PartitionKey partitionKey = null;
+ if (partitionKeyValue instanceof LessThanClientPartitionKey) {
+ LessThanClientPartitionKey lessThanClientPartitionKey = (LessThanClientPartitionKey)partitionKeyValue;
+ List partitionValueList = Optional.ofNullable(lessThanClientPartitionKey.getPartitionValueList()).orElse(
+ Lists.newArrayList());
+ List collect = partitionValueList
+ .stream().map(x -> {
+ return getPartitionValue(x);
+ })
+ .collect(Collectors.toList());
+ partitionKey = new LessThanPartitionKey(
+ lessThanClientPartitionKey.isMaxValue(),
+ new ListPartitionValue(collect)
+ );
+ } else if (partitionKeyValue instanceof ArrayClientPartitionKey) {
+ ArrayClientPartitionKey arrayClientPartitionKey = (ArrayClientPartitionKey)partitionKeyValue;
+ List collect = arrayClientPartitionKey.getPartitionValue().stream().map(
+ x -> {
+ List partitionValueList = Lists.newArrayList();
+ for (PartitionClientValue partitionClientValue : x) {
+ PartitionValue partitionValue = getPartitionValue(partitionClientValue);
+ partitionValueList.add(partitionValue);
+ }
+ return new ListPartitionValue(partitionValueList);
+ }
+ ).collect(Collectors.toList());
+ partitionKey = new ArrayPartitionKey(collect);
+ }
+ return new SingleRangePartition(
+ new Identifier(rangePartitionValue.getName()),
+ rangePartitionValue.isIfNotExists(),
+ partitionKey,
+ null
+ );
+ }
+
+ protected PartitionValue getPartitionValue(PartitionClientValue partitionClientValue) {
+ StringLiteral stringLiteral = null;
+ if (partitionClientValue.getValue() != null) {
+ stringLiteral = new StringLiteral(partitionClientValue.getValue());
+ }
+ PartitionValue partitionValue = new PartitionValue(partitionClientValue.isMaxValue(), stringLiteral);
+ return partitionValue;
+ }
+
+ private void toListPartition(List list, List columnDefinitionList,
+ BaseClientProperty baseClientProperty) {
+ if (!(baseClientProperty instanceof ListPartitionProperty)) {
+ return;
+ }
+ boolean multiPartition = columnDefinitionList.size() > 1;
+ ListPartitionProperty listPartitionProperty = (ListPartitionProperty)baseClientProperty;
+ ListClientPartition listClientPartition = listPartitionProperty.getValue();
+ BaseClientPartitionKey partitionKeyValue = listClientPartition.getPartitionKey();
+ if (!(partitionKeyValue instanceof ArrayClientPartitionKey)) {
+ return;
+ }
+ ArrayClientPartitionKey arrayClientPartitionKey = (ArrayClientPartitionKey)partitionKeyValue;
+ if (multiPartition) {
+ List collect = arrayClientPartitionKey.getPartitionValue().stream().map(
+ x -> {
+ List partitionValueList = Lists.newArrayList();
+ for (PartitionClientValue partitionClientValue : x) {
+ partitionValueList.add(new StringLiteral(partitionClientValue.getValue()));
+ }
+ return new ListStringLiteral(partitionValueList);
+ }
+ ).collect(Collectors.toList());
+ MultiItemListPartition listPartition = new MultiItemListPartition(
+ new Identifier(listClientPartition.getName()),
+ false,
+ collect,
+ null
+ );
+ list.add(listPartition);
+ } else {
+ List collect = arrayClientPartitionKey.getPartitionValue().stream().map(
+ x -> {
+ PartitionClientValue partitionClientValue = x.get(0);
+ return new StringLiteral(partitionClientValue.getValue());
+ }
+ ).collect(Collectors.toList());
+ ListStringLiteral partitionKey = new ListStringLiteral(collect);
+ SingleItemListPartition listPartition = new SingleItemListPartition(
+ new Identifier(listClientPartition.getName()),
+ false,
+ partitionKey,
+ null
+ );
+ list.add(listPartition);
+ }
+ }
+
+ private FunctionCall buildFunctionCall(BaseClientProperty baseClientProperty) {
+ if (!(baseClientProperty instanceof TimeExpressionPartitionProperty)) {
+ return null;
+ }
+ TimeExpressionPartitionProperty timeExpressionPartitionProperty = (TimeExpressionPartitionProperty)baseClientProperty;
+ TimeExpressionClientPartition timeExpressionClientPartition = timeExpressionPartitionProperty.getValue();
+ List arguments = new ArrayList<>();
+ if (StringUtils.isNotBlank(timeExpressionClientPartition.getTimeUnit())) {
+ arguments.add(new StringLiteral(timeExpressionClientPartition.getTimeUnit()));
+ }
+ if (timeExpressionClientPartition.getInterval() != null) {
+ arguments.add(timeExpressionClientPartition.getInterval());
+ }
+ return new FunctionCall(QualifiedName.of(timeExpressionClientPartition.getFuncName()),
+ false, arguments);
+
+ }
+
+ @Override
+ public BaseDataType getDataType(Column column) {
+ String dataTypeName = column.getDataType();
+ if (StringUtils.isBlank(dataTypeName)) {
+ throw new IllegalArgumentException("dataType name can't be null:" + column.getName());
+ }
+ IDataTypeName byValue = getDataTypeName(dataTypeName);
+ Dimension dimension = byValue.getDimension();
+ ReverseContext context = ReverseContext.builder().build();
+ if (dimension == null || dimension == Dimension.ZERO) {
+ return getLanguageParser().parseDataType(dataTypeName, context);
+ }
+ if (dimension == Dimension.ONE) {
+ boolean isValidLength = column.getLength() != null && column.getLength() > 0;
+ if (isValidLength) {
+ String dt = String.format(ONE_DIMENSION, dataTypeName, column.getLength());
+ return getLanguageParser().parseDataType(dt, context);
+ }
+ }
+ if (dimension == Dimension.TWO) {
+ if (column.getPrecision() != null) {
+ if (column.getScale() == null) {
+ return getLanguageParser().parseDataType(String.format(ONE_DIMENSION, dataTypeName, column.getPrecision()), context);
+ }
+ return getLanguageParser().parseDataType(String.format(TWO_DIMENSION, dataTypeName, column.getPrecision(), column.getScale()),
+ context);
+ }
+ }
+ return getLanguageParser().parseDataType(dataTypeName, context);
+ }
+
+ @Override
+ protected List toConstraint(List columns, List constraints) {
+ List baseConstraints = super.toConstraint(columns, constraints);
+ if (constraints == null) {
+ return baseConstraints;
+ }
+ for (Constraint constraint : constraints) {
+ ConstraintType type = constraint.getType();
+ if (type == ClientConstraintType.DISTRIBUTE) {
+ DistributeConstraint distributeConstraint = toDistributeConstraint(constraint);
+ if (distributeConstraint == null) {
+ continue;
+ }
+ baseConstraints.add(distributeConstraint);
+ }
+ if (type == ClientConstraintType.ORDER_BY) {
+ OrderByConstraint orderByConstraint = toOrderByConstraint(constraint);
+ baseConstraints.add(orderByConstraint);
+ }
+
+ if (type == ClientConstraintType.DUPLICATE_KEY) {
+ DuplicateKeyConstraint duplicateKeyConstraint = toDuplicateKeyConstraint(constraint);
+ baseConstraints.add(duplicateKeyConstraint);
+ }
+
+ if (type == ClientConstraintType.AGGREGATE_KEY) {
+ AggregateKeyConstraint aggregateKeyConstraint = toAggregateKeyConstraint(constraint);
+ baseConstraints.add(aggregateKeyConstraint);
+ }
+ }
+ return baseConstraints;
+ }
+
+ protected BaseExpression toDefaultValueExpression(BaseDataType baseDataType, String defaultValue) {
+ if (defaultValue == null) {
+ return null;
+ }
+ IDataTypeName typeName = baseDataType.getTypeName();
+ if (StringUtils.equalsIgnoreCase(defaultValue, UUID + SUFFIX)) {
+ return new FunctionCall(QualifiedName.of(UUID), false, Lists.newArrayList());
+ }
+ if (StringUtils.equalsIgnoreCase(defaultValue, UUID_NUMERIC + SUFFIX)) {
+ return new FunctionCall(QualifiedName.of(UUID_NUMERIC), false, Lists.newArrayList());
+ }
+ if (typeName instanceof ISimpleDataTypeName) {
+ //starRocks 数字也是用字符标识
+ ISimpleDataTypeName simpleDataTypeName = (ISimpleDataTypeName)typeName;
+ if (simpleDataTypeName.getSimpleDataTypeName() == SimpleDataTypeName.NUMBER) {
+ return new StringLiteral(defaultValue);
+ }
+ }
+ return super.toDefaultValueExpression(baseDataType, defaultValue);
+ }
+
+ private AggregateKeyConstraint toAggregateKeyConstraint(Constraint constraint) {
+ return new AggregateKeyConstraint(
+ IdentifierUtil.sysIdentifier(),
+ constraint.getColumns().stream().map(Identifier::new).collect(Collectors.toList())
+ );
+ }
+
+ private DuplicateKeyConstraint toDuplicateKeyConstraint(Constraint constraint) {
+ return new DuplicateKeyConstraint(
+ IdentifierUtil.sysIdentifier(),
+ constraint.getColumns().stream().map(Identifier::new).collect(Collectors.toList()),
+ true
+ );
+ }
+
+ private OrderByConstraint toOrderByConstraint(Constraint constraint) {
+ String name = constraint.getName();
+ Identifier nameIdentifier = null;
+ if (StringUtils.isBlank(name)) {
+ nameIdentifier = IdentifierUtil.sysIdentifier();
+ } else {
+ nameIdentifier = new Identifier(name);
+ }
+ List collect = constraint.getColumns().stream().map(Identifier::new).collect(Collectors.toList());
+ return new OrderByConstraint(nameIdentifier, collect);
+ }
+
+ private DistributeConstraint toDistributeConstraint(Constraint constraint) {
+ if (constraint instanceof DistributeClientConstraint) {
+ DistributeClientConstraint clientConstraint = (DistributeClientConstraint)constraint;
+ List list = null;
+ if (CollectionUtils.isNotEmpty(constraint.getColumns())) {
+ list = constraint.getColumns().stream().map(Identifier::new).collect(Collectors.toList());
+ return new DistributeConstraint(list, clientConstraint.getBucket());
+ } else {
+ if (BooleanUtils.isTrue(clientConstraint.getRandom())) {
+ return new DistributeConstraint(clientConstraint.getRandom(), clientConstraint.getBucket());
+ }
+ }
+ }
+ List list = null;
+ if (CollectionUtils.isNotEmpty(constraint.getColumns())) {
+ list = constraint.getColumns().stream().map(Identifier::new).collect(Collectors.toList());
+ return new DistributeConstraint(list, null);
+ }
+ return null;
+ }
+
+}
diff --git a/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/client/property/ExtensionPropertyKey.java b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/client/property/ExtensionPropertyKey.java
new file mode 100644
index 0000000..6cb06fb
--- /dev/null
+++ b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/client/property/ExtensionPropertyKey.java
@@ -0,0 +1,112 @@
+package com.aliyun.fastmodel.transform.api.extension.client.property;
+
+import com.aliyun.fastmodel.transform.api.format.PropertyKey;
+import org.apache.commons.lang3.StringUtils;
+
+/**
+ * Desc:
+ *
+ * @author panguanjing
+ * @date 2024/1/22
+ */
+public enum ExtensionPropertyKey implements PropertyKey {
+
+ /**
+ * engine
+ */
+ TABLE_ENGINE("engine"),
+
+ /**
+ * distribute hash
+ */
+ TABLE_DISTRIBUTED_HASH("distributed_hash"),
+
+ /**
+ * distribute buckets
+ */
+ TABLE_DISTRIBUTED_BUCKETS("distributed_buckets"),
+
+ COLUMN_KEY("column_key"),
+
+ /**
+ * 自增列信息
+ */
+ COLUMN_AUTO_INCREMENT("column_auto_increment"),
+
+ /**
+ * column agg desc
+ */
+ COLUMN_AGG_DESC("column_agg_desc"),
+
+ /**
+ * index type
+ */
+ TABLE_INDEX_TYPE("index_type"),
+ /**
+ * index comment
+ */
+ TABLE_INDEX_COMMENT("index_comment"),
+
+ /**
+ * range partition
+ */
+ TABLE_RANGE_PARTITION("range_partition"),
+
+ /**
+ * table range partition raw
+ */
+ TABLE_PARTITION_RAW("range_partition_raw"),
+
+ /**
+ * list partition
+ */
+ TABLE_LIST_PARTITION("list_partition"),
+
+ /**
+ * expression partition
+ */
+ TABLE_EXPRESSION_PARTITION("expression_partition"),
+
+ /**
+ * REPLICATION_NUM
+ */
+ TABLE_REPLICATION_NUM("replication_num", true),
+
+ /**
+ * 保留最近多少数量的分区
+ */
+ PARTITION_LIVE_NUMBER("partition_live_number", true);
+
+ private final String value;
+
+ private final boolean supportPrint;
+
+ ExtensionPropertyKey(String value) {
+ this(value, false);
+ }
+
+ ExtensionPropertyKey(String value, boolean supportPrint) {
+ this.value = value;
+ this.supportPrint = supportPrint;
+ }
+
+ @Override
+ public String getValue() {
+ return value;
+ }
+
+ @Override
+ public boolean isSupportPrint() {
+ return supportPrint;
+ }
+
+ public static ExtensionPropertyKey getByValue(String value) {
+ ExtensionPropertyKey[] extensionPropertyKeys = ExtensionPropertyKey.values();
+ for (ExtensionPropertyKey e : extensionPropertyKeys) {
+ if (StringUtils.equalsIgnoreCase(e.getValue(), value)) {
+ return e;
+ }
+ }
+ return null;
+ }
+}
diff --git a/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/client/property/column/AggrColumnProperty.java b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/client/property/column/AggrColumnProperty.java
new file mode 100644
index 0000000..f038660
--- /dev/null
+++ b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/client/property/column/AggrColumnProperty.java
@@ -0,0 +1,31 @@
+package com.aliyun.fastmodel.transform.api.extension.client.property.column;
+
+import java.util.Locale;
+
+import com.aliyun.fastmodel.transform.api.client.dto.property.BaseClientProperty;
+import com.aliyun.fastmodel.transform.api.extension.tree.column.AggregateDesc;
+
+import static com.aliyun.fastmodel.transform.api.extension.client.property.ExtensionPropertyKey.COLUMN_AGG_DESC;
+
+/**
+ * aggr column property
+ *
+ * @author panguanjing
+ * @date 2023/9/17
+ */
+public class AggrColumnProperty extends BaseClientProperty {
+
+ public AggrColumnProperty() {
+ this.setKey(COLUMN_AGG_DESC.getValue());
+ }
+
+ @Override
+ public String valueString() {
+ return value.name();
+ }
+
+ @Override
+ public void setValueString(String value) {
+ this.value = AggregateDesc.valueOf(value.toUpperCase(Locale.ROOT));
+ }
+}
diff --git a/fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/client/property/index/IndexCommentProperty.java b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/client/property/index/IndexCommentProperty.java
similarity index 65%
rename from fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/client/property/index/IndexCommentProperty.java
rename to fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/client/property/index/IndexCommentProperty.java
index 75ae7b5..81c89af 100644
--- a/fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/client/property/index/IndexCommentProperty.java
+++ b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/client/property/index/IndexCommentProperty.java
@@ -1,7 +1,8 @@
-package com.aliyun.fastmodel.transform.starrocks.client.property.index;
+package com.aliyun.fastmodel.transform.api.extension.client.property.index;
import com.aliyun.fastmodel.transform.api.client.dto.property.BaseClientProperty;
-import com.aliyun.fastmodel.transform.starrocks.format.StarRocksProperty;
+
+import static com.aliyun.fastmodel.transform.api.extension.client.property.ExtensionPropertyKey.TABLE_INDEX_COMMENT;
/**
* 索引描述信息属性
@@ -12,7 +13,7 @@
public class IndexCommentProperty extends BaseClientProperty {
public IndexCommentProperty() {
- setKey(StarRocksProperty.TABLE_INDEX_COMMENT.getValue());
+ setKey(TABLE_INDEX_COMMENT.getValue());
}
@Override
diff --git a/fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/client/property/index/IndexTypeProperty.java b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/client/property/index/IndexTypeProperty.java
similarity index 65%
rename from fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/client/property/index/IndexTypeProperty.java
rename to fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/client/property/index/IndexTypeProperty.java
index a91184c..6398d4d 100644
--- a/fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/client/property/index/IndexTypeProperty.java
+++ b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/client/property/index/IndexTypeProperty.java
@@ -1,7 +1,8 @@
-package com.aliyun.fastmodel.transform.starrocks.client.property.index;
+package com.aliyun.fastmodel.transform.api.extension.client.property.index;
import com.aliyun.fastmodel.transform.api.client.dto.property.BaseClientProperty;
-import com.aliyun.fastmodel.transform.starrocks.format.StarRocksProperty;
+
+import static com.aliyun.fastmodel.transform.api.extension.client.property.ExtensionPropertyKey.TABLE_INDEX_TYPE;
/**
* 索引描述信息属性
@@ -12,7 +13,7 @@
public class IndexTypeProperty extends BaseClientProperty {
public IndexTypeProperty() {
- setKey(StarRocksProperty.TABLE_INDEX_TYPE.getValue());
+ setKey(TABLE_INDEX_TYPE.getValue());
}
@Override
diff --git a/fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/client/property/table/ColumnExpressionPartitionProperty.java b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/client/property/table/ColumnExpressionPartitionProperty.java
similarity index 64%
rename from fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/client/property/table/ColumnExpressionPartitionProperty.java
rename to fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/client/property/table/ColumnExpressionPartitionProperty.java
index ea8ebd6..e3ac46a 100644
--- a/fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/client/property/table/ColumnExpressionPartitionProperty.java
+++ b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/client/property/table/ColumnExpressionPartitionProperty.java
@@ -1,18 +1,20 @@
-package com.aliyun.fastmodel.transform.starrocks.client.property.table;
+package com.aliyun.fastmodel.transform.api.extension.client.property.table;
import com.alibaba.fastjson.JSON;
+
import com.aliyun.fastmodel.transform.api.client.dto.property.BaseClientProperty;
-import com.aliyun.fastmodel.transform.starrocks.client.property.table.partition.ColumnExpressionClientPartition;
-import com.aliyun.fastmodel.transform.starrocks.format.StarRocksProperty;
+import com.aliyun.fastmodel.transform.api.extension.client.property.table.partition.ColumnExpressionClientPartition;
import org.apache.commons.lang3.StringUtils;
+import static com.aliyun.fastmodel.transform.api.extension.client.property.ExtensionPropertyKey.TABLE_EXPRESSION_PARTITION;
+
/**
* @author 子梁
* @date 2023/12/26
*/
public class ColumnExpressionPartitionProperty extends BaseClientProperty {
public ColumnExpressionPartitionProperty() {
- this.setKey(StarRocksProperty.TABLE_EXPRESSION_PARTITION.getValue());
+ this.setKey(TABLE_EXPRESSION_PARTITION.getValue());
}
@Override
diff --git a/fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/client/property/table/DistributeBucketsNum.java b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/client/property/table/DistributeBucketsNum.java
similarity index 70%
rename from fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/client/property/table/DistributeBucketsNum.java
rename to fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/client/property/table/DistributeBucketsNum.java
index ea09eb5..b914646 100644
--- a/fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/client/property/table/DistributeBucketsNum.java
+++ b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/client/property/table/DistributeBucketsNum.java
@@ -1,9 +1,10 @@
-package com.aliyun.fastmodel.transform.starrocks.client.property.table;
+package com.aliyun.fastmodel.transform.api.extension.client.property.table;
import com.aliyun.fastmodel.transform.api.client.dto.property.BaseClientProperty;
-import com.aliyun.fastmodel.transform.starrocks.format.StarRocksProperty;
import org.apache.commons.lang3.StringUtils;
+import static com.aliyun.fastmodel.transform.api.extension.client.property.ExtensionPropertyKey.TABLE_DISTRIBUTED_BUCKETS;
+
/**
* 分桶列的个数
*
@@ -12,7 +13,7 @@
*/
public class DistributeBucketsNum extends BaseClientProperty {
public DistributeBucketsNum() {
- setKey(StarRocksProperty.TABLE_DISTRIBUTED_BUCKETS.getValue());
+ setKey(TABLE_DISTRIBUTED_BUCKETS.getValue());
}
@Override
diff --git a/fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/client/property/table/DistributeHash.java b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/client/property/table/DistributeHash.java
similarity index 65%
rename from fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/client/property/table/DistributeHash.java
rename to fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/client/property/table/DistributeHash.java
index 524a6e9..20fb88f 100644
--- a/fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/client/property/table/DistributeHash.java
+++ b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/client/property/table/DistributeHash.java
@@ -1,12 +1,13 @@
-package com.aliyun.fastmodel.transform.starrocks.client.property.table;
+package com.aliyun.fastmodel.transform.api.extension.client.property.table;
import java.util.List;
import com.aliyun.fastmodel.transform.api.client.dto.property.BaseClientProperty;
-import com.aliyun.fastmodel.transform.starrocks.format.StarRocksProperty;
import com.google.common.collect.Lists;
import org.apache.commons.lang3.StringUtils;
+import static com.aliyun.fastmodel.transform.api.extension.client.property.ExtensionPropertyKey.TABLE_DISTRIBUTED_HASH;
+
/**
* 分桶列的个数
*
@@ -16,7 +17,7 @@
public class DistributeHash extends BaseClientProperty> {
public DistributeHash() {
- setKey(StarRocksProperty.TABLE_DISTRIBUTED_HASH.getValue());
+ setKey(TABLE_DISTRIBUTED_HASH.getValue());
}
@Override
@@ -29,6 +30,6 @@ public void setValueString(String value) {
if (StringUtils.isBlank(value)) {
return;
}
- this.value = Lists.newArrayList(StringUtils.split(value, ","));
+ this.value = Lists.newArrayList(StringUtils.split(value, ","));
}
}
diff --git a/fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/client/property/table/MultiRangePartitionProperty.java b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/client/property/table/MultiRangePartitionProperty.java
similarity index 66%
rename from fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/client/property/table/MultiRangePartitionProperty.java
rename to fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/client/property/table/MultiRangePartitionProperty.java
index 00c7024..a467d42 100644
--- a/fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/client/property/table/MultiRangePartitionProperty.java
+++ b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/client/property/table/MultiRangePartitionProperty.java
@@ -1,12 +1,13 @@
-package com.aliyun.fastmodel.transform.starrocks.client.property.table;
+package com.aliyun.fastmodel.transform.api.extension.client.property.table;
import com.alibaba.fastjson.JSON;
import com.aliyun.fastmodel.transform.api.client.dto.property.BaseClientProperty;
-import com.aliyun.fastmodel.transform.starrocks.client.property.table.partition.MultiRangeClientPartition;
-import com.aliyun.fastmodel.transform.starrocks.format.StarRocksProperty;
+import com.aliyun.fastmodel.transform.api.extension.client.property.table.partition.MultiRangeClientPartition;
import org.apache.commons.lang3.StringUtils;
+import static com.aliyun.fastmodel.transform.api.extension.client.property.ExtensionPropertyKey.TABLE_RANGE_PARTITION;
+
/**
* multi range partition
*
@@ -16,7 +17,7 @@
public class MultiRangePartitionProperty extends BaseClientProperty {
public MultiRangePartitionProperty() {
- this.setKey(StarRocksProperty.TABLE_RANGE_PARTITION.getValue());
+ this.setKey(TABLE_RANGE_PARTITION.getValue());
}
@Override
diff --git a/fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/client/property/table/PartitionLiveNumberProperty.java b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/client/property/table/PartitionLiveNumberProperty.java
similarity index 70%
rename from fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/client/property/table/PartitionLiveNumberProperty.java
rename to fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/client/property/table/PartitionLiveNumberProperty.java
index a856056..2f01f8f 100644
--- a/fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/client/property/table/PartitionLiveNumberProperty.java
+++ b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/client/property/table/PartitionLiveNumberProperty.java
@@ -1,9 +1,10 @@
-package com.aliyun.fastmodel.transform.starrocks.client.property.table;
+package com.aliyun.fastmodel.transform.api.extension.client.property.table;
import com.aliyun.fastmodel.transform.api.client.dto.property.BaseClientProperty;
-import com.aliyun.fastmodel.transform.starrocks.format.StarRocksProperty;
import org.apache.commons.lang3.StringUtils;
+import static com.aliyun.fastmodel.transform.api.extension.client.property.ExtensionPropertyKey.PARTITION_LIVE_NUMBER;
+
/**
* @author 子梁
* @date 2024/1/5
@@ -11,7 +12,7 @@
public class PartitionLiveNumberProperty extends BaseClientProperty {
public PartitionLiveNumberProperty() {
- setKey(StarRocksProperty.PARTITION_LIVE_NUMBER.getValue());
+ setKey(PARTITION_LIVE_NUMBER.getValue());
}
@Override
diff --git a/fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/client/property/table/ReplicationNum.java b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/client/property/table/ReplicationNum.java
similarity index 70%
rename from fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/client/property/table/ReplicationNum.java
rename to fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/client/property/table/ReplicationNum.java
index 8e2f4f0..84cebfc 100644
--- a/fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/client/property/table/ReplicationNum.java
+++ b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/client/property/table/ReplicationNum.java
@@ -1,9 +1,10 @@
-package com.aliyun.fastmodel.transform.starrocks.client.property.table;
+package com.aliyun.fastmodel.transform.api.extension.client.property.table;
import com.aliyun.fastmodel.transform.api.client.dto.property.BaseClientProperty;
-import com.aliyun.fastmodel.transform.starrocks.format.StarRocksProperty;
import org.apache.commons.lang3.StringUtils;
+import static com.aliyun.fastmodel.transform.api.extension.client.property.ExtensionPropertyKey.TABLE_REPLICATION_NUM;
+
/**
* ReplicationNum
*
@@ -12,7 +13,7 @@
*/
public class ReplicationNum extends BaseClientProperty {
public ReplicationNum() {
- setKey(StarRocksProperty.TABLE_REPLICATION_NUM.getValue());
+ setKey(TABLE_REPLICATION_NUM.getValue());
}
@Override
diff --git a/fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/client/property/table/SingleRangePartitionProperty.java b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/client/property/table/SingleRangePartitionProperty.java
similarity index 66%
rename from fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/client/property/table/SingleRangePartitionProperty.java
rename to fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/client/property/table/SingleRangePartitionProperty.java
index 891e8c0..cf09638 100644
--- a/fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/client/property/table/SingleRangePartitionProperty.java
+++ b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/client/property/table/SingleRangePartitionProperty.java
@@ -1,12 +1,13 @@
-package com.aliyun.fastmodel.transform.starrocks.client.property.table;
+package com.aliyun.fastmodel.transform.api.extension.client.property.table;
import com.alibaba.fastjson.JSON;
import com.aliyun.fastmodel.transform.api.client.dto.property.BaseClientProperty;
-import com.aliyun.fastmodel.transform.starrocks.client.property.table.partition.SingleRangeClientPartition;
-import com.aliyun.fastmodel.transform.starrocks.format.StarRocksProperty;
+import com.aliyun.fastmodel.transform.api.extension.client.property.table.partition.SingleRangeClientPartition;
import org.apache.commons.lang3.StringUtils;
+import static com.aliyun.fastmodel.transform.api.extension.client.property.ExtensionPropertyKey.TABLE_RANGE_PARTITION;
+
/**
* single range partition
*
@@ -16,7 +17,7 @@
public class SingleRangePartitionProperty extends BaseClientProperty {
public SingleRangePartitionProperty() {
- this.setKey(StarRocksProperty.TABLE_RANGE_PARTITION.getValue());
+ this.setKey(TABLE_RANGE_PARTITION.getValue());
}
@Override
diff --git a/fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/client/property/table/TablePartitionRaw.java b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/client/property/table/TablePartitionRaw.java
similarity index 65%
rename from fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/client/property/table/TablePartitionRaw.java
rename to fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/client/property/table/TablePartitionRaw.java
index 311ad7d..d3c6ec8 100644
--- a/fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/client/property/table/TablePartitionRaw.java
+++ b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/client/property/table/TablePartitionRaw.java
@@ -1,7 +1,8 @@
-package com.aliyun.fastmodel.transform.starrocks.client.property.table;
+package com.aliyun.fastmodel.transform.api.extension.client.property.table;
import com.aliyun.fastmodel.transform.api.client.dto.property.BaseClientProperty;
-import com.aliyun.fastmodel.transform.starrocks.format.StarRocksProperty;
+
+import static com.aliyun.fastmodel.transform.api.extension.client.property.ExtensionPropertyKey.TABLE_PARTITION_RAW;
/**
* 分区定义的文本化描述
@@ -12,7 +13,7 @@
public class TablePartitionRaw extends BaseClientProperty {
public TablePartitionRaw() {
- this.setKey(StarRocksProperty.TABLE_PARTITION_RAW.getValue());
+ this.setKey(TABLE_PARTITION_RAW.getValue());
}
@Override
diff --git a/fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/client/property/table/TimeExpressionPartitionProperty.java b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/client/property/table/TimeExpressionPartitionProperty.java
similarity index 64%
rename from fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/client/property/table/TimeExpressionPartitionProperty.java
rename to fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/client/property/table/TimeExpressionPartitionProperty.java
index 62af158..bc45a9c 100644
--- a/fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/client/property/table/TimeExpressionPartitionProperty.java
+++ b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/client/property/table/TimeExpressionPartitionProperty.java
@@ -1,11 +1,13 @@
-package com.aliyun.fastmodel.transform.starrocks.client.property.table;
+package com.aliyun.fastmodel.transform.api.extension.client.property.table;
import com.alibaba.fastjson.JSON;
+
import com.aliyun.fastmodel.transform.api.client.dto.property.BaseClientProperty;
-import com.aliyun.fastmodel.transform.starrocks.client.property.table.partition.TimeExpressionClientPartition;
-import com.aliyun.fastmodel.transform.starrocks.format.StarRocksProperty;
+import com.aliyun.fastmodel.transform.api.extension.client.property.table.partition.TimeExpressionClientPartition;
import org.apache.commons.lang3.StringUtils;
+import static com.aliyun.fastmodel.transform.api.extension.client.property.ExtensionPropertyKey.TABLE_EXPRESSION_PARTITION;
+
/**
* @author 子梁
* @date 2023/12/26
@@ -13,7 +15,7 @@
public class TimeExpressionPartitionProperty extends BaseClientProperty {
public TimeExpressionPartitionProperty() {
- this.setKey(StarRocksProperty.TABLE_EXPRESSION_PARTITION.getValue());
+ this.setKey(TABLE_EXPRESSION_PARTITION.getValue());
}
@Override
diff --git a/fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/client/property/table/partition/ArrayClientPartitionKey.java b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/client/property/table/partition/ArrayClientPartitionKey.java
similarity index 84%
rename from fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/client/property/table/partition/ArrayClientPartitionKey.java
rename to fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/client/property/table/partition/ArrayClientPartitionKey.java
index e8e758b..e0a1696 100644
--- a/fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/client/property/table/partition/ArrayClientPartitionKey.java
+++ b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/client/property/table/partition/ArrayClientPartitionKey.java
@@ -1,4 +1,4 @@
-package com.aliyun.fastmodel.transform.starrocks.client.property.table.partition;
+package com.aliyun.fastmodel.transform.api.extension.client.property.table.partition;
import java.util.List;
diff --git a/fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/client/property/table/partition/BaseClientPartitionKey.java b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/client/property/table/partition/BaseClientPartitionKey.java
similarity index 58%
rename from fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/client/property/table/partition/BaseClientPartitionKey.java
rename to fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/client/property/table/partition/BaseClientPartitionKey.java
index c18f729..9cb993c 100644
--- a/fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/client/property/table/partition/BaseClientPartitionKey.java
+++ b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/client/property/table/partition/BaseClientPartitionKey.java
@@ -1,4 +1,4 @@
-package com.aliyun.fastmodel.transform.starrocks.client.property.table.partition;
+package com.aliyun.fastmodel.transform.api.extension.client.property.table.partition;
/**
* partition key
diff --git a/fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/client/property/table/partition/ColumnExpressionClientPartition.java b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/client/property/table/partition/ColumnExpressionClientPartition.java
similarity index 80%
rename from fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/client/property/table/partition/ColumnExpressionClientPartition.java
rename to fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/client/property/table/partition/ColumnExpressionClientPartition.java
index 0dd98e0..d9067c0 100644
--- a/fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/client/property/table/partition/ColumnExpressionClientPartition.java
+++ b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/client/property/table/partition/ColumnExpressionClientPartition.java
@@ -1,12 +1,12 @@
-package com.aliyun.fastmodel.transform.starrocks.client.property.table.partition;
+package com.aliyun.fastmodel.transform.api.extension.client.property.table.partition;
+
+import java.util.List;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
-import java.util.List;
-
/**
* @author 子梁
* @date 2023/12/26
diff --git a/fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/client/property/table/partition/LessThanClientPartitionKey.java b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/client/property/table/partition/LessThanClientPartitionKey.java
similarity index 83%
rename from fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/client/property/table/partition/LessThanClientPartitionKey.java
rename to fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/client/property/table/partition/LessThanClientPartitionKey.java
index bf69170..911478b 100644
--- a/fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/client/property/table/partition/LessThanClientPartitionKey.java
+++ b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/client/property/table/partition/LessThanClientPartitionKey.java
@@ -1,4 +1,4 @@
-package com.aliyun.fastmodel.transform.starrocks.client.property.table.partition;
+package com.aliyun.fastmodel.transform.api.extension.client.property.table.partition;
import java.util.List;
@@ -19,7 +19,7 @@
@Builder
@NoArgsConstructor
@AllArgsConstructor
-public class LessThanClientPartitionKey extends BaseClientPartitionKey{
+public class LessThanClientPartitionKey extends BaseClientPartitionKey {
private boolean maxValue;
diff --git a/fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/client/property/table/partition/ListClientPartition.java b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/client/property/table/partition/ListClientPartition.java
similarity index 83%
rename from fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/client/property/table/partition/ListClientPartition.java
rename to fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/client/property/table/partition/ListClientPartition.java
index 899c48a..0b85421 100644
--- a/fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/client/property/table/partition/ListClientPartition.java
+++ b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/client/property/table/partition/ListClientPartition.java
@@ -1,4 +1,4 @@
-package com.aliyun.fastmodel.transform.starrocks.client.property.table.partition;
+package com.aliyun.fastmodel.transform.api.extension.client.property.table.partition;
import lombok.AllArgsConstructor;
import lombok.Builder;
diff --git a/fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/client/property/table/partition/MultiRangeClientPartition.java b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/client/property/table/partition/MultiRangeClientPartition.java
similarity index 86%
rename from fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/client/property/table/partition/MultiRangeClientPartition.java
rename to fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/client/property/table/partition/MultiRangeClientPartition.java
index 016f616..61a8ffd 100644
--- a/fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/client/property/table/partition/MultiRangeClientPartition.java
+++ b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/client/property/table/partition/MultiRangeClientPartition.java
@@ -1,4 +1,4 @@
-package com.aliyun.fastmodel.transform.starrocks.client.property.table.partition;
+package com.aliyun.fastmodel.transform.api.extension.client.property.table.partition;
import com.aliyun.fastmodel.core.tree.expr.enums.DateTimeEnum;
import lombok.AllArgsConstructor;
diff --git a/fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/client/property/table/partition/PartitionClientValue.java b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/client/property/table/partition/PartitionClientValue.java
similarity index 81%
rename from fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/client/property/table/partition/PartitionClientValue.java
rename to fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/client/property/table/partition/PartitionClientValue.java
index 85b3d50..ffe10b5 100644
--- a/fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/client/property/table/partition/PartitionClientValue.java
+++ b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/client/property/table/partition/PartitionClientValue.java
@@ -1,4 +1,4 @@
-package com.aliyun.fastmodel.transform.starrocks.client.property.table.partition;
+package com.aliyun.fastmodel.transform.api.extension.client.property.table.partition;
import lombok.AllArgsConstructor;
import lombok.Builder;
diff --git a/fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/client/property/table/partition/SingleRangeClientPartition.java b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/client/property/table/partition/SingleRangeClientPartition.java
similarity index 87%
rename from fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/client/property/table/partition/SingleRangeClientPartition.java
rename to fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/client/property/table/partition/SingleRangeClientPartition.java
index c8e4315..d46e7ea 100644
--- a/fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/client/property/table/partition/SingleRangeClientPartition.java
+++ b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/client/property/table/partition/SingleRangeClientPartition.java
@@ -1,4 +1,4 @@
-package com.aliyun.fastmodel.transform.starrocks.client.property.table.partition;
+package com.aliyun.fastmodel.transform.api.extension.client.property.table.partition;
import java.util.LinkedHashMap;
@@ -34,6 +34,4 @@ public class SingleRangeClientPartition {
*/
private LinkedHashMap properties;
-
-
}
diff --git a/fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/client/property/table/partition/TimeExpressionClientPartition.java b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/client/property/table/partition/TimeExpressionClientPartition.java
similarity index 86%
rename from fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/client/property/table/partition/TimeExpressionClientPartition.java
rename to fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/client/property/table/partition/TimeExpressionClientPartition.java
index 92e3e4e..890ebb8 100644
--- a/fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/client/property/table/partition/TimeExpressionClientPartition.java
+++ b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/client/property/table/partition/TimeExpressionClientPartition.java
@@ -1,4 +1,4 @@
-package com.aliyun.fastmodel.transform.starrocks.client.property.table.partition;
+package com.aliyun.fastmodel.transform.api.extension.client.property.table.partition;
import com.aliyun.fastmodel.core.tree.expr.literal.IntervalLiteral;
import lombok.AllArgsConstructor;
diff --git a/fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/parser/tree/AggDesc.java b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/tree/column/AggregateDesc.java
similarity index 83%
rename from fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/parser/tree/AggDesc.java
rename to fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/tree/column/AggregateDesc.java
index aee2cab..d221418 100644
--- a/fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/parser/tree/AggDesc.java
+++ b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/tree/column/AggregateDesc.java
@@ -1,4 +1,4 @@
-package com.aliyun.fastmodel.transform.starrocks.parser.tree;
+package com.aliyun.fastmodel.transform.api.extension.tree.column;
/**
* column agg desc
@@ -6,7 +6,7 @@
* @author panguanjing
* @date 2023/9/16
*/
-public enum AggDesc {
+public enum AggregateDesc {
/**
* sum
*/
diff --git a/fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/parser/tree/constraint/AggregateKeyConstraint.java b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/tree/constraint/AggregateKeyConstraint.java
similarity index 76%
rename from fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/parser/tree/constraint/AggregateKeyConstraint.java
rename to fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/tree/constraint/AggregateKeyConstraint.java
index 57298aa..d7b5394 100644
--- a/fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/parser/tree/constraint/AggregateKeyConstraint.java
+++ b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/tree/constraint/AggregateKeyConstraint.java
@@ -1,4 +1,4 @@
-package com.aliyun.fastmodel.transform.starrocks.parser.tree.constraint;
+package com.aliyun.fastmodel.transform.api.extension.tree.constraint;
import java.util.List;
@@ -6,7 +6,7 @@
import com.aliyun.fastmodel.core.tree.Node;
import com.aliyun.fastmodel.core.tree.expr.Identifier;
import com.aliyun.fastmodel.core.tree.statement.table.constraint.CustomConstraint;
-import com.aliyun.fastmodel.transform.starrocks.parser.visitor.StarRocksAstVisitor;
+import com.aliyun.fastmodel.transform.api.extension.visitor.ExtensionAstVisitor;
import lombok.Getter;
/**
@@ -33,8 +33,8 @@ public AggregateKeyConstraint(Identifier constraintName, List column
@Override
public R accept(AstVisitor visitor, C context) {
- StarRocksAstVisitor starRocksAstVisitor = (StarRocksAstVisitor)visitor;
- return starRocksAstVisitor.visitAggregateConstraint(this, context);
+ ExtensionAstVisitor extensionVisitor = (ExtensionAstVisitor)visitor;
+ return extensionVisitor.visitAggregateConstraint(this, context);
}
@Override
diff --git a/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/tree/constraint/Algorithm.java b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/tree/constraint/Algorithm.java
new file mode 100644
index 0000000..9a86e91
--- /dev/null
+++ b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/tree/constraint/Algorithm.java
@@ -0,0 +1,12 @@
+package com.aliyun.fastmodel.transform.api.extension.tree.constraint;
+
+/**
+ * Desc:
+ *
+ * @author panguanjing
+ * @date 2024/2/19
+ */
+public enum Algorithm {
+ BTREE,
+ HASH
+}
diff --git a/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/tree/constraint/CheckExpressionConstraint.java b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/tree/constraint/CheckExpressionConstraint.java
new file mode 100644
index 0000000..681e803
--- /dev/null
+++ b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/tree/constraint/CheckExpressionConstraint.java
@@ -0,0 +1,40 @@
+package com.aliyun.fastmodel.transform.api.extension.tree.constraint;
+
+import com.aliyun.fastmodel.core.tree.AstVisitor;
+import com.aliyun.fastmodel.core.tree.expr.BaseExpression;
+import com.aliyun.fastmodel.core.tree.expr.Identifier;
+import com.aliyun.fastmodel.core.tree.statement.table.constraint.CustomConstraint;
+import com.aliyun.fastmodel.transform.api.extension.visitor.ExtensionAstVisitor;
+import lombok.Getter;
+
+/**
+ * check expression constraint
+ *
+ * @author panguanjing
+ * @date 2024/2/17
+ */
+@Getter
+public class CheckExpressionConstraint extends CustomConstraint {
+
+ public static final String CHECK = "CHECK";
+
+ private final BaseExpression expression;
+
+ private final Boolean enforced;
+
+ public CheckExpressionConstraint(Identifier constraintName, Boolean enable, String customType, BaseExpression expression, Boolean enforced) {
+ super(constraintName, enable, customType);
+ this.expression = expression;
+ this.enforced = enforced;
+ }
+
+ public CheckExpressionConstraint(Identifier constraintName, BaseExpression expression, Boolean enforced) {
+ this(constraintName, true, CHECK, expression, enforced);
+ }
+
+ @Override
+ public R accept(AstVisitor visitor, C context) {
+ ExtensionAstVisitor extensionVisitor = (ExtensionAstVisitor)visitor;
+ return extensionVisitor.visitCheckExpressionConstraint(this, context);
+ }
+}
diff --git a/fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/parser/tree/constraint/DuplicateKeyConstraint.java b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/tree/constraint/DuplicateKeyConstraint.java
similarity index 76%
rename from fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/parser/tree/constraint/DuplicateKeyConstraint.java
rename to fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/tree/constraint/DuplicateKeyConstraint.java
index a8269a8..9246a93 100644
--- a/fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/parser/tree/constraint/DuplicateKeyConstraint.java
+++ b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/tree/constraint/DuplicateKeyConstraint.java
@@ -1,4 +1,4 @@
-package com.aliyun.fastmodel.transform.starrocks.parser.tree.constraint;
+package com.aliyun.fastmodel.transform.api.extension.tree.constraint;
import java.util.List;
@@ -6,7 +6,7 @@
import com.aliyun.fastmodel.core.tree.Node;
import com.aliyun.fastmodel.core.tree.expr.Identifier;
import com.aliyun.fastmodel.core.tree.statement.table.constraint.CustomConstraint;
-import com.aliyun.fastmodel.transform.starrocks.parser.visitor.StarRocksAstVisitor;
+import com.aliyun.fastmodel.transform.api.extension.visitor.ExtensionAstVisitor;
import lombok.Getter;
/**
@@ -33,8 +33,8 @@ public DuplicateKeyConstraint(Identifier constraintName, List column
@Override
public R accept(IAstVisitor visitor, C context) {
- StarRocksAstVisitor starRocksAstVisitor = (StarRocksAstVisitor)visitor;
- return starRocksAstVisitor.visitDuplicateConstraint(this, context);
+ ExtensionAstVisitor extensionVisitor = (ExtensionAstVisitor)visitor;
+ return extensionVisitor.visitDuplicateConstraint(this, context);
}
@Override
diff --git a/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/tree/constraint/ForeignKeyConstraint.java b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/tree/constraint/ForeignKeyConstraint.java
new file mode 100644
index 0000000..1b54616
--- /dev/null
+++ b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/tree/constraint/ForeignKeyConstraint.java
@@ -0,0 +1,74 @@
+package com.aliyun.fastmodel.transform.api.extension.tree.constraint;
+
+import java.util.List;
+
+import com.aliyun.fastmodel.core.tree.IAstVisitor;
+import com.aliyun.fastmodel.core.tree.QualifiedName;
+import com.aliyun.fastmodel.core.tree.expr.Identifier;
+import com.aliyun.fastmodel.core.tree.statement.table.constraint.CustomConstraint;
+import com.aliyun.fastmodel.transform.api.extension.visitor.ExtensionAstVisitor;
+import lombok.Getter;
+
+/**
+ * foreign key constraint
+ *
+ * @author panguanjing
+ * @date 2024/2/18
+ */
+@Getter
+public class ForeignKeyConstraint extends CustomConstraint {
+
+ public enum MatchAction {
+ SIMPLE,
+ FULL,
+ PARTIAL
+ }
+
+ public enum ReferenceAction {
+ RESTRICT("RESTRICT"),
+ CASCADE("CASCADE"),
+ SET_NULL("SET NULL"),
+ NO_ACTION("NO ACTION"),
+ SET_DEFAULT("SET DEFAULT");
+ @Getter
+ private final String value;
+
+ ReferenceAction(String value) {this.value = value;}
+ }
+
+ public enum ReferenceOperator {
+ DELETE,
+ UPDATE
+ }
+
+ private final Identifier indexName;
+ private final List colNames;
+
+ private final QualifiedName referenceTable;
+
+ private final List referenceColNames;
+
+ private final MatchAction matchAction;
+
+ private final ReferenceOperator referenceOperator;
+
+ private final ReferenceAction referenceAction;
+
+ public ForeignKeyConstraint(Identifier constraintName, Identifier indexName, List colNames, QualifiedName referenceTable,
+ List referenceColNames, MatchAction matchAction, ReferenceOperator referenceOperator, ReferenceAction referenceAction) {
+ super(constraintName, true, "FOREIGN_KEY");
+ this.indexName = indexName;
+ this.colNames = colNames;
+ this.referenceTable = referenceTable;
+ this.referenceColNames = referenceColNames;
+ this.matchAction = matchAction;
+ this.referenceOperator = referenceOperator;
+ this.referenceAction = referenceAction;
+ }
+
+ @Override
+ public R accept(IAstVisitor visitor, C context) {
+ ExtensionAstVisitor extensionVisitor = (ExtensionAstVisitor)visitor;
+ return extensionVisitor.visitForeignKeyConstraint(this, context);
+ }
+}
diff --git a/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/tree/constraint/UniqueKeyExprConstraint.java b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/tree/constraint/UniqueKeyExprConstraint.java
new file mode 100644
index 0000000..86ff9ec
--- /dev/null
+++ b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/tree/constraint/UniqueKeyExprConstraint.java
@@ -0,0 +1,39 @@
+package com.aliyun.fastmodel.transform.api.extension.tree.constraint;
+
+import java.util.List;
+
+import com.aliyun.fastmodel.core.tree.IAstVisitor;
+import com.aliyun.fastmodel.core.tree.expr.Identifier;
+import com.aliyun.fastmodel.core.tree.statement.table.constraint.CustomConstraint;
+import com.aliyun.fastmodel.core.tree.statement.table.index.IndexSortKey;
+import com.aliyun.fastmodel.transform.api.extension.visitor.ExtensionAstVisitor;
+import lombok.Getter;
+
+/**
+ * UniqueKeyExprConstraint
+ *
+ * @author panguanjing
+ * @date 2024/2/19
+ */
+@Getter
+public class UniqueKeyExprConstraint extends CustomConstraint {
+
+ private final List indexSortKeys;
+
+ private final Algorithm algorithm;
+
+ private final Identifier indexName;
+
+ public UniqueKeyExprConstraint(Identifier constraintName, Identifier indexName, List indexSortKeys, Algorithm algorithm) {
+ super(constraintName, true, "UniqueKeyExpr");
+ this.indexSortKeys = indexSortKeys;
+ this.algorithm = algorithm;
+ this.indexName = indexName;
+ }
+
+ @Override
+ public R accept(IAstVisitor visitor, C context) {
+ ExtensionAstVisitor extensionVisitor = (ExtensionAstVisitor)visitor;
+ return extensionVisitor.visitUniqueKeyExprConstraint(this, context);
+ }
+}
diff --git a/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/tree/constraint/desc/ClusterKeyConstraint.java b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/tree/constraint/desc/ClusterKeyConstraint.java
new file mode 100644
index 0000000..acb2987
--- /dev/null
+++ b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/tree/constraint/desc/ClusterKeyConstraint.java
@@ -0,0 +1,37 @@
+package com.aliyun.fastmodel.transform.api.extension.tree.constraint.desc;
+
+import java.util.List;
+
+import com.aliyun.fastmodel.core.tree.AstVisitor;
+import com.aliyun.fastmodel.core.tree.expr.Identifier;
+import com.aliyun.fastmodel.core.tree.util.IdentifierUtil;
+import com.aliyun.fastmodel.transform.api.extension.visitor.ExtensionAstVisitor;
+
+/**
+ * cluster by constraint
+ *
+ * @author panguanjing
+ * @date 2024/1/21
+ */
+public class ClusterKeyConstraint extends NonKeyConstraint {
+
+ public static final String TYPE = "Cluster";
+
+ private final List columns;
+
+ public ClusterKeyConstraint(Identifier constraintName, Boolean enable, List columns) {
+ super(constraintName, enable, TYPE);
+ this.columns = columns;
+ }
+
+ public ClusterKeyConstraint(List columns) {
+ super(IdentifierUtil.sysIdentifier(), true, TYPE);
+ this.columns = columns;
+ }
+
+ @Override
+ public R accept(AstVisitor visitor, C context) {
+ ExtensionAstVisitor extensionVisitor = (ExtensionAstVisitor)visitor;
+ return extensionVisitor.visitClusterKeyConstraint(this, context);
+ }
+}
diff --git a/fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/parser/tree/constraint/desc/DistributeConstraint.java b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/tree/constraint/desc/DistributeConstraint.java
similarity index 76%
rename from fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/parser/tree/constraint/desc/DistributeConstraint.java
rename to fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/tree/constraint/desc/DistributeConstraint.java
index 7c5b827..b29c439 100644
--- a/fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/parser/tree/constraint/desc/DistributeConstraint.java
+++ b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/tree/constraint/desc/DistributeConstraint.java
@@ -1,11 +1,11 @@
-package com.aliyun.fastmodel.transform.starrocks.parser.tree.constraint.desc;
+package com.aliyun.fastmodel.transform.api.extension.tree.constraint.desc;
import java.util.List;
import com.aliyun.fastmodel.core.tree.AstVisitor;
import com.aliyun.fastmodel.core.tree.expr.Identifier;
import com.aliyun.fastmodel.core.tree.util.IdentifierUtil;
-import com.aliyun.fastmodel.transform.starrocks.parser.visitor.StarRocksAstVisitor;
+import com.aliyun.fastmodel.transform.api.extension.visitor.ExtensionAstVisitor;
import lombok.Getter;
/**
@@ -42,7 +42,7 @@ public DistributeConstraint(boolean random, Integer bucket) {
@Override
public R accept(AstVisitor visitor, C context) {
- StarRocksAstVisitor starRocksAstVisitor = (StarRocksAstVisitor)visitor;
- return starRocksAstVisitor.visitDistributeKeyConstraint(this, context);
+ ExtensionAstVisitor extensionVisitor = (ExtensionAstVisitor)visitor;
+ return extensionVisitor.visitDistributeKeyConstraint(this, context);
}
}
diff --git a/fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/parser/tree/constraint/desc/NonKeyConstraint.java b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/tree/constraint/desc/NonKeyConstraint.java
similarity index 85%
rename from fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/parser/tree/constraint/desc/NonKeyConstraint.java
rename to fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/tree/constraint/desc/NonKeyConstraint.java
index 454fdee..592ff99 100644
--- a/fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/parser/tree/constraint/desc/NonKeyConstraint.java
+++ b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/tree/constraint/desc/NonKeyConstraint.java
@@ -1,4 +1,4 @@
-package com.aliyun.fastmodel.transform.starrocks.parser.tree.constraint.desc;
+package com.aliyun.fastmodel.transform.api.extension.tree.constraint.desc;
import com.aliyun.fastmodel.core.tree.expr.Identifier;
import com.aliyun.fastmodel.core.tree.statement.table.constraint.CustomConstraint;
diff --git a/fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/parser/tree/constraint/desc/OrderByConstraint.java b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/tree/constraint/desc/OrderByConstraint.java
similarity index 74%
rename from fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/parser/tree/constraint/desc/OrderByConstraint.java
rename to fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/tree/constraint/desc/OrderByConstraint.java
index efc1459..9006a33 100644
--- a/fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/parser/tree/constraint/desc/OrderByConstraint.java
+++ b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/tree/constraint/desc/OrderByConstraint.java
@@ -1,11 +1,11 @@
-package com.aliyun.fastmodel.transform.starrocks.parser.tree.constraint.desc;
+package com.aliyun.fastmodel.transform.api.extension.tree.constraint.desc;
import java.util.List;
import com.aliyun.fastmodel.core.tree.IAstVisitor;
import com.aliyun.fastmodel.core.tree.Node;
import com.aliyun.fastmodel.core.tree.expr.Identifier;
-import com.aliyun.fastmodel.transform.starrocks.parser.visitor.StarRocksAstVisitor;
+import com.aliyun.fastmodel.transform.api.extension.visitor.ExtensionAstVisitor;
import lombok.Getter;
/**
@@ -33,8 +33,8 @@ public OrderByConstraint(Identifier constraintName, List columns) {
@Override
public R accept(IAstVisitor visitor, C context) {
- StarRocksAstVisitor starRocksAstVisitor = (StarRocksAstVisitor)visitor;
- return starRocksAstVisitor.visitOrderByConstraint(this, context);
+ ExtensionAstVisitor extensionVisitor = (ExtensionAstVisitor)visitor;
+ return extensionVisitor.visitOrderByConstraint(this, context);
}
@Override
diff --git a/fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/parser/tree/constraint/desc/RollupConstraint.java b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/tree/constraint/desc/RollupConstraint.java
similarity index 77%
rename from fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/parser/tree/constraint/desc/RollupConstraint.java
rename to fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/tree/constraint/desc/RollupConstraint.java
index de937b1..47e2a28 100644
--- a/fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/parser/tree/constraint/desc/RollupConstraint.java
+++ b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/tree/constraint/desc/RollupConstraint.java
@@ -1,10 +1,10 @@
-package com.aliyun.fastmodel.transform.starrocks.parser.tree.constraint.desc;
+package com.aliyun.fastmodel.transform.api.extension.tree.constraint.desc;
import java.util.List;
import com.aliyun.fastmodel.core.tree.IAstVisitor;
import com.aliyun.fastmodel.core.tree.util.IdentifierUtil;
-import com.aliyun.fastmodel.transform.starrocks.parser.visitor.StarRocksAstVisitor;
+import com.aliyun.fastmodel.transform.api.extension.visitor.ExtensionAstVisitor;
import lombok.Getter;
/**
@@ -30,7 +30,7 @@ public RollupConstraint(List rollupItemList) {
@Override
public R accept(IAstVisitor visitor, C context) {
- StarRocksAstVisitor starRocksAstVisitor = (StarRocksAstVisitor)visitor;
+ ExtensionAstVisitor starRocksAstVisitor = (ExtensionAstVisitor)visitor;
return starRocksAstVisitor.visitRollupConstraint(this, context);
}
}
diff --git a/fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/parser/tree/constraint/desc/RollupItem.java b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/tree/constraint/desc/RollupItem.java
similarity index 84%
rename from fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/parser/tree/constraint/desc/RollupItem.java
rename to fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/tree/constraint/desc/RollupItem.java
index 9011f1b..f956fc6 100644
--- a/fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/parser/tree/constraint/desc/RollupItem.java
+++ b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/tree/constraint/desc/RollupItem.java
@@ -1,4 +1,4 @@
-package com.aliyun.fastmodel.transform.starrocks.parser.tree.constraint.desc;
+package com.aliyun.fastmodel.transform.api.extension.tree.constraint.desc;
import java.util.List;
@@ -7,7 +7,7 @@
import com.aliyun.fastmodel.core.tree.Node;
import com.aliyun.fastmodel.core.tree.Property;
import com.aliyun.fastmodel.core.tree.expr.Identifier;
-import com.aliyun.fastmodel.transform.starrocks.parser.visitor.StarRocksAstVisitor;
+import com.aliyun.fastmodel.transform.api.extension.visitor.ExtensionAstVisitor;
import com.google.common.collect.ImmutableList;
import lombok.Getter;
@@ -62,7 +62,7 @@ public List extends Node> getChildren() {
@Override
public R accept(IAstVisitor visitor, C context) {
- StarRocksAstVisitor starRocksAstVisitor = (StarRocksAstVisitor)visitor;
- return starRocksAstVisitor.visitRollupItem(this, context);
+ ExtensionAstVisitor extensionVisitor = (ExtensionAstVisitor)visitor;
+ return extensionVisitor.visitRollupItem(this, context);
}
}
diff --git a/fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/parser/tree/partition/ExpressionPartitionBy.java b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/tree/partition/ExpressionPartitionBy.java
similarity index 78%
rename from fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/parser/tree/partition/ExpressionPartitionBy.java
rename to fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/tree/partition/ExpressionPartitionBy.java
index 2d8449e..cf57931 100644
--- a/fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/parser/tree/partition/ExpressionPartitionBy.java
+++ b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/tree/partition/ExpressionPartitionBy.java
@@ -1,4 +1,6 @@
-package com.aliyun.fastmodel.transform.starrocks.parser.tree.partition;
+package com.aliyun.fastmodel.transform.api.extension.tree.partition;
+
+import java.util.List;
import com.aliyun.fastmodel.core.tree.IAstVisitor;
import com.aliyun.fastmodel.core.tree.expr.BaseExpression;
@@ -7,16 +9,16 @@
import com.aliyun.fastmodel.core.tree.expr.literal.StringLiteral;
import com.aliyun.fastmodel.core.tree.statement.table.ColumnDefinition;
import com.aliyun.fastmodel.core.tree.statement.table.PartitionedBy;
-import com.aliyun.fastmodel.transform.starrocks.parser.visitor.StarRocksAstVisitor;
+import com.aliyun.fastmodel.transform.api.extension.tree.partition.desc.PartitionDesc;
+import com.aliyun.fastmodel.transform.api.extension.visitor.ExtensionAstVisitor;
import lombok.Getter;
import org.apache.commons.collections.CollectionUtils;
-import java.util.List;
-
/**
- * StarRocksPartitionedBy
+ * ExpressionPartitionedBy
*
* @author 子梁
+ * @author panguanjing 为支持扩展移动到api
* @date 2023/12/26
*/
@Getter
@@ -33,8 +35,8 @@ public class ExpressionPartitionBy extends PartitionedBy {
private final List rangePartitions;
public ExpressionPartitionBy(List columnDefinitions,
- FunctionCall functionCall,
- List rangePartitions) {
+ FunctionCall functionCall,
+ List rangePartitions) {
super(columnDefinitions);
this.functionCall = functionCall;
this.rangePartitions = rangePartitions;
@@ -42,8 +44,8 @@ public ExpressionPartitionBy(List columnDefinitions,
@Override
public R accept(IAstVisitor visitor, C context) {
- StarRocksAstVisitor starRocksVisitor = (StarRocksAstVisitor)visitor;
- return starRocksVisitor.visitExpressionPartitionedBy(this, context);
+ ExtensionAstVisitor extensionVisitor = (ExtensionAstVisitor)visitor;
+ return extensionVisitor.visitExpressionPartitionedBy(this, context);
}
public StringLiteral getTimeUnitArg() {
diff --git a/fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/parser/tree/partition/ListPartitionedBy.java b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/tree/partition/ListPartitionedBy.java
similarity index 68%
rename from fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/parser/tree/partition/ListPartitionedBy.java
rename to fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/tree/partition/ListPartitionedBy.java
index 1f01bd4..03914be 100644
--- a/fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/parser/tree/partition/ListPartitionedBy.java
+++ b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/tree/partition/ListPartitionedBy.java
@@ -1,11 +1,12 @@
-package com.aliyun.fastmodel.transform.starrocks.parser.tree.partition;
+package com.aliyun.fastmodel.transform.api.extension.tree.partition;
import java.util.List;
import com.aliyun.fastmodel.core.tree.IAstVisitor;
import com.aliyun.fastmodel.core.tree.statement.table.ColumnDefinition;
import com.aliyun.fastmodel.core.tree.statement.table.PartitionedBy;
-import com.aliyun.fastmodel.transform.starrocks.parser.visitor.StarRocksAstVisitor;
+import com.aliyun.fastmodel.transform.api.extension.tree.partition.desc.PartitionDesc;
+import com.aliyun.fastmodel.transform.api.extension.visitor.ExtensionAstVisitor;
import lombok.Getter;
/**
@@ -30,7 +31,7 @@ public ListPartitionedBy(List columnDefinitions,
@Override
public R accept(IAstVisitor visitor, C context) {
- StarRocksAstVisitor starRocksVisitor = (StarRocksAstVisitor)visitor;
- return starRocksVisitor.visitListPartitionedBy(this, context);
+ ExtensionAstVisitor extensionVisitor = (ExtensionAstVisitor)visitor;
+ return extensionVisitor.visitListPartitionedBy(this, context);
}
}
diff --git a/fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/parser/tree/partition/RangePartitionedBy.java b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/tree/partition/RangePartitionedBy.java
similarity index 66%
rename from fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/parser/tree/partition/RangePartitionedBy.java
rename to fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/tree/partition/RangePartitionedBy.java
index ba175f4..97b9db4 100644
--- a/fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/parser/tree/partition/RangePartitionedBy.java
+++ b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/tree/partition/RangePartitionedBy.java
@@ -1,15 +1,16 @@
-package com.aliyun.fastmodel.transform.starrocks.parser.tree.partition;
+package com.aliyun.fastmodel.transform.api.extension.tree.partition;
import java.util.List;
import com.aliyun.fastmodel.core.tree.IAstVisitor;
import com.aliyun.fastmodel.core.tree.statement.table.ColumnDefinition;
import com.aliyun.fastmodel.core.tree.statement.table.PartitionedBy;
-import com.aliyun.fastmodel.transform.starrocks.parser.visitor.StarRocksAstVisitor;
+import com.aliyun.fastmodel.transform.api.extension.tree.partition.desc.PartitionDesc;
+import com.aliyun.fastmodel.transform.api.extension.visitor.ExtensionAstVisitor;
import lombok.Getter;
/**
- * StarRocksPartitionedBy
+ * RangePartitionedBy
*
* @author panguanjing
* @date 2023/9/13
@@ -30,7 +31,7 @@ public RangePartitionedBy(List columnDefinitions,
@Override
public R accept(IAstVisitor visitor, C context) {
- StarRocksAstVisitor starRocksVisitor = (StarRocksAstVisitor)visitor;
- return starRocksVisitor.visitRangePartitionedBy(this, context);
+ ExtensionAstVisitor extensionVisitor = (ExtensionAstVisitor)visitor;
+ return extensionVisitor.visitRangePartitionedBy(this, context);
}
}
diff --git a/fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/parser/tree/partition/MultiItemListPartition.java b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/tree/partition/desc/MultiItemListPartition.java
similarity index 85%
rename from fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/parser/tree/partition/MultiItemListPartition.java
rename to fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/tree/partition/desc/MultiItemListPartition.java
index 202b3b3..f1eaccf 100644
--- a/fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/parser/tree/partition/MultiItemListPartition.java
+++ b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/tree/partition/desc/MultiItemListPartition.java
@@ -1,4 +1,4 @@
-package com.aliyun.fastmodel.transform.starrocks.parser.tree.partition;
+package com.aliyun.fastmodel.transform.api.extension.tree.partition.desc;
import java.util.List;
@@ -7,7 +7,7 @@
import com.aliyun.fastmodel.core.tree.Property;
import com.aliyun.fastmodel.core.tree.expr.Identifier;
import com.aliyun.fastmodel.core.tree.expr.literal.ListStringLiteral;
-import com.aliyun.fastmodel.transform.starrocks.parser.visitor.StarRocksAstVisitor;
+import com.aliyun.fastmodel.transform.api.extension.visitor.ExtensionAstVisitor;
import com.google.common.collect.ImmutableList;
import lombok.Getter;
@@ -53,7 +53,7 @@ public List extends Node> getChildren() {
@Override
public R accept(IAstVisitor visitor, C context) {
- StarRocksAstVisitor starRocksVisitor = (StarRocksAstVisitor)visitor;
- return starRocksVisitor.visitMultiItemListPartition(this, context);
+ ExtensionAstVisitor extensionVisitor = (ExtensionAstVisitor)visitor;
+ return extensionVisitor.visitMultiItemListPartition(this, context);
}
}
diff --git a/fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/parser/tree/partition/MultiRangePartition.java b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/tree/partition/desc/MultiRangePartition.java
similarity index 59%
rename from fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/parser/tree/partition/MultiRangePartition.java
rename to fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/tree/partition/desc/MultiRangePartition.java
index a7cfc31..ecdd00b 100644
--- a/fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/parser/tree/partition/MultiRangePartition.java
+++ b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/tree/partition/desc/MultiRangePartition.java
@@ -1,4 +1,4 @@
-package com.aliyun.fastmodel.transform.starrocks.parser.tree.partition;
+package com.aliyun.fastmodel.transform.api.extension.tree.partition.desc;
import java.util.List;
@@ -7,8 +7,11 @@
import com.aliyun.fastmodel.core.tree.expr.literal.IntervalLiteral;
import com.aliyun.fastmodel.core.tree.expr.literal.LongLiteral;
import com.aliyun.fastmodel.core.tree.expr.literal.StringLiteral;
-import com.aliyun.fastmodel.transform.starrocks.parser.visitor.StarRocksAstVisitor;
+import com.aliyun.fastmodel.transform.api.extension.tree.partition.keyvalue.ListPartitionValue;
+import com.aliyun.fastmodel.transform.api.extension.tree.partition.keyvalue.PartitionValue;
+import com.aliyun.fastmodel.transform.api.extension.visitor.ExtensionAstVisitor;
import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Lists;
import lombok.Getter;
/**
@@ -19,12 +22,12 @@
*/
@Getter
public class MultiRangePartition extends PartitionDesc {
- private final StringLiteral start;
- private final StringLiteral end;
+ private final ListPartitionValue start;
+ private final ListPartitionValue end;
private final IntervalLiteral intervalLiteral;
private final LongLiteral longLiteral;
- public MultiRangePartition(StringLiteral start, StringLiteral end, IntervalLiteral intervalLiteral,
+ public MultiRangePartition(ListPartitionValue start, ListPartitionValue end, IntervalLiteral intervalLiteral,
LongLiteral longLiteral) {
this.start = start;
this.end = end;
@@ -32,6 +35,14 @@ public MultiRangePartition(StringLiteral start, StringLiteral end, IntervalLiter
this.longLiteral = longLiteral;
}
+ public MultiRangePartition(StringLiteral start, StringLiteral end, IntervalLiteral intervalLiteral,
+ LongLiteral longLiteral) {
+ this.start = new ListPartitionValue(Lists.newArrayList(new PartitionValue(start)));
+ this.end = new ListPartitionValue(Lists.newArrayList(new PartitionValue(end)));
+ this.intervalLiteral = intervalLiteral;
+ this.longLiteral = longLiteral;
+ }
+
@Override
public List extends Node> getChildren() {
ImmutableList.Builder builder = ImmutableList.builder();
@@ -52,7 +63,7 @@ public List extends Node> getChildren() {
@Override
public R accept(IAstVisitor visitor, C context) {
- StarRocksAstVisitor starRocksVisitor = (StarRocksAstVisitor)visitor;
- return starRocksVisitor.visitMultiRangePartition(this, context);
+ ExtensionAstVisitor extensionVisitor = (ExtensionAstVisitor)visitor;
+ return extensionVisitor.visitMultiRangePartition(this, context);
}
}
diff --git a/fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/parser/tree/partition/PartitionDesc.java b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/tree/partition/desc/PartitionDesc.java
similarity index 55%
rename from fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/parser/tree/partition/PartitionDesc.java
rename to fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/tree/partition/desc/PartitionDesc.java
index d1d5029..a83d126 100644
--- a/fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/parser/tree/partition/PartitionDesc.java
+++ b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/tree/partition/desc/PartitionDesc.java
@@ -1,8 +1,8 @@
-package com.aliyun.fastmodel.transform.starrocks.parser.tree.partition;
+package com.aliyun.fastmodel.transform.api.extension.tree.partition.desc;
import com.aliyun.fastmodel.core.tree.AbstractNode;
import com.aliyun.fastmodel.core.tree.IAstVisitor;
-import com.aliyun.fastmodel.transform.starrocks.parser.visitor.StarRocksAstVisitor;
+import com.aliyun.fastmodel.transform.api.extension.visitor.ExtensionAstVisitor;
/**
* RangePartition
@@ -14,7 +14,7 @@ public abstract class PartitionDesc extends AbstractNode {
@Override
public R accept(IAstVisitor visitor, C context) {
- StarRocksAstVisitor starRocksVisitor = (StarRocksAstVisitor)visitor;
- return starRocksVisitor.visitPartitionDesc(this, context);
+ ExtensionAstVisitor extensionVisitor = (ExtensionAstVisitor)visitor;
+ return extensionVisitor.visitPartitionDesc(this, context);
}
}
diff --git a/fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/parser/tree/partition/SingleItemListPartition.java b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/tree/partition/desc/SingleItemListPartition.java
similarity index 85%
rename from fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/parser/tree/partition/SingleItemListPartition.java
rename to fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/tree/partition/desc/SingleItemListPartition.java
index fa631ad..b5aa045 100644
--- a/fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/parser/tree/partition/SingleItemListPartition.java
+++ b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/tree/partition/desc/SingleItemListPartition.java
@@ -1,4 +1,4 @@
-package com.aliyun.fastmodel.transform.starrocks.parser.tree.partition;
+package com.aliyun.fastmodel.transform.api.extension.tree.partition.desc;
import java.util.List;
@@ -7,7 +7,7 @@
import com.aliyun.fastmodel.core.tree.Property;
import com.aliyun.fastmodel.core.tree.expr.Identifier;
import com.aliyun.fastmodel.core.tree.expr.literal.ListStringLiteral;
-import com.aliyun.fastmodel.transform.starrocks.parser.visitor.StarRocksAstVisitor;
+import com.aliyun.fastmodel.transform.api.extension.visitor.ExtensionAstVisitor;
import com.google.common.collect.ImmutableList;
import lombok.Getter;
@@ -35,8 +35,8 @@ public SingleItemListPartition(Identifier name, boolean ifNotExists,
@Override
public R accept(IAstVisitor visitor, C context) {
- StarRocksAstVisitor starRocksVisitor = (StarRocksAstVisitor)visitor;
- return starRocksVisitor.visitSingleItemListPartition(this, context);
+ ExtensionAstVisitor extensionVisitor = (ExtensionAstVisitor)visitor;
+ return extensionVisitor.visitSingleItemListPartition(this, context);
}
@Override
diff --git a/fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/parser/tree/partition/SingleRangePartition.java b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/tree/partition/desc/SingleRangePartition.java
similarity index 79%
rename from fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/parser/tree/partition/SingleRangePartition.java
rename to fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/tree/partition/desc/SingleRangePartition.java
index 7cde507..59145b2 100644
--- a/fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/parser/tree/partition/SingleRangePartition.java
+++ b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/tree/partition/desc/SingleRangePartition.java
@@ -1,4 +1,4 @@
-package com.aliyun.fastmodel.transform.starrocks.parser.tree.partition;
+package com.aliyun.fastmodel.transform.api.extension.tree.partition.desc;
import java.util.List;
@@ -6,7 +6,8 @@
import com.aliyun.fastmodel.core.tree.Node;
import com.aliyun.fastmodel.core.tree.Property;
import com.aliyun.fastmodel.core.tree.expr.Identifier;
-import com.aliyun.fastmodel.transform.starrocks.parser.visitor.StarRocksAstVisitor;
+import com.aliyun.fastmodel.transform.api.extension.tree.partition.keyvalue.PartitionKey;
+import com.aliyun.fastmodel.transform.api.extension.visitor.ExtensionAstVisitor;
import com.google.common.collect.ImmutableList;
import lombok.Getter;
@@ -47,7 +48,7 @@ public List extends Node> getChildren() {
@Override
public R accept(IAstVisitor visitor, C context) {
- StarRocksAstVisitor starRocksVisitor = (StarRocksAstVisitor)visitor;
- return starRocksVisitor.visitSingleRangePartition(this, context);
+ ExtensionAstVisitor extensionVisitor = (ExtensionAstVisitor)visitor;
+ return extensionVisitor.visitSingleRangePartition(this, context);
}
}
diff --git a/fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/parser/tree/partition/ArrayPartitionKey.java b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/tree/partition/keyvalue/ArrayPartitionKey.java
similarity index 70%
rename from fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/parser/tree/partition/ArrayPartitionKey.java
rename to fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/tree/partition/keyvalue/ArrayPartitionKey.java
index c34b8ed..e71bc73 100644
--- a/fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/parser/tree/partition/ArrayPartitionKey.java
+++ b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/tree/partition/keyvalue/ArrayPartitionKey.java
@@ -1,10 +1,10 @@
-package com.aliyun.fastmodel.transform.starrocks.parser.tree.partition;
+package com.aliyun.fastmodel.transform.api.extension.tree.partition.keyvalue;
import java.util.List;
import com.aliyun.fastmodel.core.tree.IAstVisitor;
import com.aliyun.fastmodel.core.tree.Node;
-import com.aliyun.fastmodel.transform.starrocks.parser.visitor.StarRocksAstVisitor;
+import com.aliyun.fastmodel.transform.api.extension.visitor.ExtensionAstVisitor;
import lombok.Getter;
/**
@@ -27,7 +27,7 @@ public List extends Node> getChildren() {
@Override
public R accept(IAstVisitor visitor, C context) {
- StarRocksAstVisitor starRocksVisitor = (StarRocksAstVisitor)visitor;
- return starRocksVisitor.visitArrayPartitionKey(this, context);
+ ExtensionAstVisitor extensionVisitor = (ExtensionAstVisitor)visitor;
+ return extensionVisitor.visitArrayPartitionKey(this, context);
}
}
diff --git a/fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/parser/tree/partition/LessThanPartitionKey.java b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/tree/partition/keyvalue/LessThanPartitionKey.java
similarity index 73%
rename from fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/parser/tree/partition/LessThanPartitionKey.java
rename to fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/tree/partition/keyvalue/LessThanPartitionKey.java
index 909f6b5..782d9d2 100644
--- a/fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/parser/tree/partition/LessThanPartitionKey.java
+++ b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/tree/partition/keyvalue/LessThanPartitionKey.java
@@ -1,11 +1,10 @@
-package com.aliyun.fastmodel.transform.starrocks.parser.tree.partition;
+package com.aliyun.fastmodel.transform.api.extension.tree.partition.keyvalue;
import java.util.List;
import com.aliyun.fastmodel.core.tree.IAstVisitor;
import com.aliyun.fastmodel.core.tree.Node;
-import com.aliyun.fastmodel.core.tree.expr.literal.StringLiteral;
-import com.aliyun.fastmodel.transform.starrocks.parser.visitor.StarRocksAstVisitor;
+import com.aliyun.fastmodel.transform.api.extension.visitor.ExtensionAstVisitor;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import lombok.Getter;
@@ -30,7 +29,7 @@ public LessThanPartitionKey(boolean maxValue, ListPartitionValue partitionValues
public LessThanPartitionKey(ListPartitionValue partitionValues) {
this.partitionValues = partitionValues;
- this.maxValue =false;
+ this.maxValue = false;
}
@Override
@@ -43,7 +42,7 @@ public List extends Node> getChildren() {
@Override
public R accept(IAstVisitor visitor, C context) {
- StarRocksAstVisitor starRocksVisitor = (StarRocksAstVisitor)visitor;
- return starRocksVisitor.visitLessThanPartitionKey(this, context);
+ ExtensionAstVisitor extensionVisitor = (ExtensionAstVisitor)visitor;
+ return extensionVisitor.visitLessThanPartitionKey(this, context);
}
}
diff --git a/fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/parser/tree/partition/ListPartitionValue.java b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/tree/partition/keyvalue/ListPartitionValue.java
similarity index 77%
rename from fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/parser/tree/partition/ListPartitionValue.java
rename to fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/tree/partition/keyvalue/ListPartitionValue.java
index ec9bbc7..77ab4ee 100644
--- a/fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/parser/tree/partition/ListPartitionValue.java
+++ b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/tree/partition/keyvalue/ListPartitionValue.java
@@ -1,4 +1,4 @@
-package com.aliyun.fastmodel.transform.starrocks.parser.tree.partition;
+package com.aliyun.fastmodel.transform.api.extension.tree.partition.keyvalue;
import java.util.List;
@@ -6,7 +6,7 @@
import com.aliyun.fastmodel.core.tree.IAstVisitor;
import com.aliyun.fastmodel.core.tree.Node;
import com.aliyun.fastmodel.core.tree.NodeLocation;
-import com.aliyun.fastmodel.transform.starrocks.parser.visitor.StarRocksAstVisitor;
+import com.aliyun.fastmodel.transform.api.extension.visitor.ExtensionAstVisitor;
import lombok.Getter;
/**
@@ -35,7 +35,7 @@ public List extends Node> getChildren() {
@Override
public R accept(IAstVisitor visitor, C context) {
- StarRocksAstVisitor starRocksVisitor = (StarRocksAstVisitor)visitor;
- return starRocksVisitor.visitListPartitionValue(this, context);
+ ExtensionAstVisitor extensionVisitor = (ExtensionAstVisitor)visitor;
+ return extensionVisitor.visitListPartitionValue(this, context);
}
}
diff --git a/fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/parser/tree/partition/PartitionKey.java b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/tree/partition/keyvalue/PartitionKey.java
similarity index 54%
rename from fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/parser/tree/partition/PartitionKey.java
rename to fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/tree/partition/keyvalue/PartitionKey.java
index e46ce38..255da59 100644
--- a/fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/parser/tree/partition/PartitionKey.java
+++ b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/tree/partition/keyvalue/PartitionKey.java
@@ -1,8 +1,8 @@
-package com.aliyun.fastmodel.transform.starrocks.parser.tree.partition;
+package com.aliyun.fastmodel.transform.api.extension.tree.partition.keyvalue;
import com.aliyun.fastmodel.core.tree.AbstractNode;
import com.aliyun.fastmodel.core.tree.IAstVisitor;
-import com.aliyun.fastmodel.transform.starrocks.parser.visitor.StarRocksAstVisitor;
+import com.aliyun.fastmodel.transform.api.extension.visitor.ExtensionAstVisitor;
/**
* partition key
@@ -14,7 +14,7 @@ public abstract class PartitionKey extends AbstractNode {
@Override
public R accept(IAstVisitor visitor, C context) {
- StarRocksAstVisitor starRocksVisitor = (StarRocksAstVisitor)visitor;
- return starRocksVisitor.visitPartitionKey(this, context);
+ ExtensionAstVisitor extensionVisitor = (ExtensionAstVisitor)visitor;
+ return extensionVisitor.visitPartitionKey(this, context);
}
}
diff --git a/fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/parser/tree/partition/PartitionValue.java b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/tree/partition/keyvalue/PartitionValue.java
similarity index 54%
rename from fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/parser/tree/partition/PartitionValue.java
rename to fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/tree/partition/keyvalue/PartitionValue.java
index 2516ce8..4d3b79e 100644
--- a/fastmodel-transform/fastmodel-transform-starrocks/src/main/java/com/aliyun/fastmodel/transform/starrocks/parser/tree/partition/PartitionValue.java
+++ b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/tree/partition/keyvalue/PartitionValue.java
@@ -1,12 +1,12 @@
-package com.aliyun.fastmodel.transform.starrocks.parser.tree.partition;
+package com.aliyun.fastmodel.transform.api.extension.tree.partition.keyvalue;
import java.util.List;
import com.aliyun.fastmodel.core.tree.AbstractNode;
import com.aliyun.fastmodel.core.tree.IAstVisitor;
import com.aliyun.fastmodel.core.tree.Node;
-import com.aliyun.fastmodel.core.tree.expr.literal.StringLiteral;
-import com.aliyun.fastmodel.transform.starrocks.parser.visitor.StarRocksAstVisitor;
+import com.aliyun.fastmodel.core.tree.expr.BaseExpression;
+import com.aliyun.fastmodel.transform.api.extension.visitor.ExtensionAstVisitor;
import com.google.common.collect.ImmutableList;
import lombok.Getter;
@@ -21,14 +21,13 @@ public class PartitionValue extends AbstractNode {
private final boolean maxValue;
- private final StringLiteral stringLiteral;
+ private final BaseExpression stringLiteral;
- public PartitionValue(StringLiteral stringLiteral) {
- this.stringLiteral = stringLiteral;
- this.maxValue = false;
+ public PartitionValue(BaseExpression stringLiteral) {
+ this(false, stringLiteral);
}
- public PartitionValue(boolean maxValue, StringLiteral stringLiteral) {
+ public PartitionValue(boolean maxValue, BaseExpression stringLiteral) {
this.maxValue = maxValue;
this.stringLiteral = stringLiteral;
}
@@ -40,7 +39,7 @@ public List extends Node> getChildren() {
@Override
public R accept(IAstVisitor visitor, C context) {
- StarRocksAstVisitor starRocksVisitor = (StarRocksAstVisitor)visitor;
- return starRocksVisitor.visitPartitionValue(this, context);
+ ExtensionAstVisitor extensionVisitor = (ExtensionAstVisitor)visitor;
+ return extensionVisitor.visitPartitionValue(this, context);
}
}
diff --git a/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/visitor/ExtensionAstVisitor.java b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/visitor/ExtensionAstVisitor.java
new file mode 100644
index 0000000..48e78e5
--- /dev/null
+++ b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/extension/visitor/ExtensionAstVisitor.java
@@ -0,0 +1,231 @@
+package com.aliyun.fastmodel.transform.api.extension.visitor;
+
+import com.aliyun.fastmodel.core.tree.IAstVisitor;
+import com.aliyun.fastmodel.transform.api.extension.tree.constraint.AggregateKeyConstraint;
+import com.aliyun.fastmodel.transform.api.extension.tree.constraint.CheckExpressionConstraint;
+import com.aliyun.fastmodel.transform.api.extension.tree.constraint.DuplicateKeyConstraint;
+import com.aliyun.fastmodel.transform.api.extension.tree.constraint.ForeignKeyConstraint;
+import com.aliyun.fastmodel.transform.api.extension.tree.constraint.UniqueKeyExprConstraint;
+import com.aliyun.fastmodel.transform.api.extension.tree.constraint.desc.ClusterKeyConstraint;
+import com.aliyun.fastmodel.transform.api.extension.tree.constraint.desc.DistributeConstraint;
+import com.aliyun.fastmodel.transform.api.extension.tree.constraint.desc.OrderByConstraint;
+import com.aliyun.fastmodel.transform.api.extension.tree.constraint.desc.RollupConstraint;
+import com.aliyun.fastmodel.transform.api.extension.tree.constraint.desc.RollupItem;
+import com.aliyun.fastmodel.transform.api.extension.tree.partition.ExpressionPartitionBy;
+import com.aliyun.fastmodel.transform.api.extension.tree.partition.ListPartitionedBy;
+import com.aliyun.fastmodel.transform.api.extension.tree.partition.RangePartitionedBy;
+import com.aliyun.fastmodel.transform.api.extension.tree.partition.desc.MultiItemListPartition;
+import com.aliyun.fastmodel.transform.api.extension.tree.partition.desc.MultiRangePartition;
+import com.aliyun.fastmodel.transform.api.extension.tree.partition.desc.PartitionDesc;
+import com.aliyun.fastmodel.transform.api.extension.tree.partition.desc.SingleItemListPartition;
+import com.aliyun.fastmodel.transform.api.extension.tree.partition.desc.SingleRangePartition;
+import com.aliyun.fastmodel.transform.api.extension.tree.partition.keyvalue.ArrayPartitionKey;
+import com.aliyun.fastmodel.transform.api.extension.tree.partition.keyvalue.LessThanPartitionKey;
+import com.aliyun.fastmodel.transform.api.extension.tree.partition.keyvalue.ListPartitionValue;
+import com.aliyun.fastmodel.transform.api.extension.tree.partition.keyvalue.PartitionKey;
+import com.aliyun.fastmodel.transform.api.extension.tree.partition.keyvalue.PartitionValue;
+
+/**
+ * 扩展的visitor
+ *
+ * @author panguanjing
+ * @date 2024/1/21
+ */
+public interface ExtensionAstVisitor extends IAstVisitor {
+ /**
+ * visit array partition key
+ *
+ * @param arrayPartitionKey arrayPartitionKey
+ * @param context context
+ * @return
+ */
+ default R visitArrayPartitionKey(ArrayPartitionKey arrayPartitionKey, C context) {
+ return visitPartitionKey(arrayPartitionKey, context);
+ }
+
+ /**
+ * visit partition key
+ *
+ * @param partitionKey
+ * @param context
+ * @return
+ */
+ default R visitPartitionKey(PartitionKey partitionKey, C context) {
+ return visitNode(partitionKey, context);
+ }
+
+ /**
+ * visitExpressionPartitionBy
+ *
+ * @param expressionPartitionedBy
+ * @param context
+ * @return
+ */
+ default R visitExpressionPartitionedBy(ExpressionPartitionBy expressionPartitionedBy, C context) {
+ return visitNode(expressionPartitionedBy, context);
+ }
+
+ /**
+ * single range partition
+ *
+ * @param singleRangePartition
+ * @param context
+ * @return
+ */
+ default R visitSingleRangePartition(SingleRangePartition singleRangePartition, C context) {
+ return visitNode(singleRangePartition, context);
+ }
+
+ /**
+ * multi range partition
+ *
+ * @param multiRangePartition
+ * @param context
+ * @return
+ */
+ default R visitMultiRangePartition(MultiRangePartition multiRangePartition, C context) {
+ return visitNode(multiRangePartition, context);
+ }
+
+ /**
+ * visit less than partition key
+ *
+ * @param lessThanPartitionKey
+ * @param context
+ * @return
+ */
+ default R visitLessThanPartitionKey(LessThanPartitionKey lessThanPartitionKey, C context) {
+ return visitPartitionKey(lessThanPartitionKey, context);
+ }
+
+ /**
+ * visit single item partition
+ *
+ * @param singleItemListPartition
+ * @param context
+ * @return
+ */
+ default R visitSingleItemListPartition(SingleItemListPartition singleItemListPartition, C context) {
+ return visitNode(singleItemListPartition, context);
+ }
+
+ /**
+ * visitListPartitionedBy
+ *
+ * @param listPartitionedBy
+ * @param context
+ * @return
+ */
+ default R visitListPartitionedBy(ListPartitionedBy listPartitionedBy, C context) {
+ return visitNode(listPartitionedBy, context);
+ }
+
+ /**
+ * visit list partition value
+ *
+ * @param listPartitionValue
+ * @param context
+ * @return
+ */
+ default R visitListPartitionValue(ListPartitionValue listPartitionValue, C context) {
+ return visitNode(listPartitionValue, context);
+ }
+
+ /**
+ * visit multiItemListPartition
+ *
+ * @param multiItemListPartition
+ * @param context
+ * @return
+ */
+ default R visitMultiItemListPartition(MultiItemListPartition multiItemListPartition, C context) {
+ return visitNode(multiItemListPartition, context);
+ }
+
+ /**
+ * visit partition desc
+ *
+ * @param partitionDesc
+ * @param context
+ * @return
+ */
+ default R visitPartitionDesc(PartitionDesc partitionDesc, C context) {
+ return visitNode(partitionDesc, context);
+ }
+
+ /**
+ * visit partition value
+ *
+ * @param partitionValue
+ * @param context
+ * @return
+ */
+ default R visitPartitionValue(PartitionValue partitionValue, C context) {
+ return visitNode(partitionValue, context);
+ }
+
+ /**
+ * visit starRocks partitioned by
+ *
+ * @param starRocksPartitionedBy
+ * @param context
+ * @return
+ */
+ default R visitRangePartitionedBy(RangePartitionedBy starRocksPartitionedBy, C context) {
+ return visitNode(starRocksPartitionedBy, context);
+ }
+
+ /**
+ * visitAggregateConstraint
+ *
+ * @param aggregateConstraint
+ * @param context
+ * @return
+ */
+ default R visitAggregateConstraint(AggregateKeyConstraint aggregateConstraint, C context) {
+ return visitNode(aggregateConstraint, context);
+ }
+
+ /**
+ * visit duplicate constraint
+ *
+ * @param duplicateConstraint
+ * @param context
+ * @return
+ */
+ default R visitDuplicateConstraint(DuplicateKeyConstraint duplicateConstraint, C context) {
+ return visitNode(duplicateConstraint, context);
+ }
+
+ default R visitOrderByConstraint(OrderByConstraint orderByConstraint, C context) {
+ return visitNode(orderByConstraint, context);
+ }
+
+ default R visitDistributeKeyConstraint(DistributeConstraint distributeKeyConstraint, C context) {
+ return visitNode(distributeKeyConstraint, context);
+ }
+
+ default R visitRollupItem(RollupItem rollupItem, C context) {
+ return visitNode(rollupItem, context);
+ }
+
+ default R visitRollupConstraint(RollupConstraint rollupConstraint, C context) {
+ return visitNode(rollupConstraint, context);
+ }
+
+ default R visitClusterKeyConstraint(ClusterKeyConstraint clusterKeyConstraint, C context) {
+ return visitNode(clusterKeyConstraint, context);
+ }
+
+ default R visitCheckExpressionConstraint(CheckExpressionConstraint checkExpressionConstraint, C context) {
+ return visitNode(checkExpressionConstraint, context);
+ }
+
+ default R visitForeignKeyConstraint(ForeignKeyConstraint foreignKeyConstraint, C context) {
+ return visitNode(foreignKeyConstraint, context);
+ }
+
+ default R visitUniqueKeyExprConstraint(UniqueKeyExprConstraint uniqueKeyExprConstraint, C context) {
+ return visitNode(uniqueKeyExprConstraint, context);
+ }
+}
diff --git a/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/format/PropertyValueType.java b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/format/PropertyValueType.java
new file mode 100644
index 0000000..1cfd90e
--- /dev/null
+++ b/fastmodel-transform/fastmodel-transform-api/src/main/java/com/aliyun/fastmodel/transform/api/format/PropertyValueType.java
@@ -0,0 +1,28 @@
+package com.aliyun.fastmodel.transform.api.format;
+
+/**
+ * OptionValueType
+ *
+ * @author panguanjing
+ * @date 2024/2/17
+ */
+public enum PropertyValueType {
+
+ /**
+ * EXPRESSION
+ */
+ EXPRESSION,
+ /**
+ * identifier
+ */
+ IDENTIFIER,
+ /**
+ * string literal
+ */
+ STRING_LITERAL,
+
+ /**
+ * number literal
+ */
+ NUMBER_LITERAL;
+}
diff --git a/fastmodel-transform/fastmodel-transform-api/src/test/java/com/aliyun/fastmodel/transform/api/dialect/DialectNameTest.java b/fastmodel-transform/fastmodel-transform-api/src/test/java/com/aliyun/fastmodel/transform/api/dialect/DialectNameTest.java
index c31f309..9b859ac 100644
--- a/fastmodel-transform/fastmodel-transform-api/src/test/java/com/aliyun/fastmodel/transform/api/dialect/DialectNameTest.java
+++ b/fastmodel-transform/fastmodel-transform-api/src/test/java/com/aliyun/fastmodel/transform/api/dialect/DialectNameTest.java
@@ -10,7 +10,7 @@
import org.junit.Test;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
/**
* DialectNameTest
@@ -28,4 +28,10 @@ public void getDialectName() {
maxcompute = DialectName.getByCode("Max_compute");
assertEquals(maxcompute, DialectName.MAXCOMPUTE);
}
+
+ @Test
+ public void testDoris() {
+ DialectName dialectName = DialectName.getByCode("doris");
+ assertEquals(dialectName, DialectName.DORIS);
+ }
}
\ No newline at end of file
diff --git a/fastmodel-transform/fastmodel-transform-doris/pom.xml b/fastmodel-transform/fastmodel-transform-doris/pom.xml
new file mode 100644
index 0000000..6f86471
--- /dev/null
+++ b/fastmodel-transform/fastmodel-transform-doris/pom.xml
@@ -0,0 +1,37 @@
+
+
+ 4.0.0
+
+ com.aliyun.fastmodel
+ fastmodel-transform
+ ${revision}
+
+
+ fastmodel-transform-doris
+
+
+ UTF-8
+
+
+
+
+ com.aliyun.fastmodel
+ fastmodel-transform-api
+ ${project.version}
+
+
+
+ com.aliyun.fastmodel
+ fastmodel-common
+ ${project.version}
+
+
+
+ commons-io
+ commons-io
+ test
+
+
+
\ No newline at end of file
diff --git a/fastmodel-transform/fastmodel-transform-doris/src/main/antlr4/com/aliyun/fastmodel/transform/doris/parser/DorisLexer.g4 b/fastmodel-transform/fastmodel-transform-doris/src/main/antlr4/com/aliyun/fastmodel/transform/doris/parser/DorisLexer.g4
new file mode 100644
index 0000000..488c8b8
--- /dev/null
+++ b/fastmodel-transform/fastmodel-transform-doris/src/main/antlr4/com/aliyun/fastmodel/transform/doris/parser/DorisLexer.g4
@@ -0,0 +1,671 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+// Copied from Apache Spark and modified for Apache Doris
+
+lexer grammar DorisLexer;
+
+@members {
+ /**
+ * When true, parser should throw ParseExcetion for unclosed bracketed comment.
+ */
+ public boolean has_unclosed_bracketed_comment = false;
+
+ /**
+ * Verify whether current token is a valid decimal token (which contains dot).
+ * Returns true if the character that follows the token is not a digit or letter or underscore.
+ *
+ * For example:
+ * For char stream "2.3", "2." is not a valid decimal token, because it is followed by digit '3'.
+ * For char stream "2.3_", "2.3" is not a valid decimal token, because it is followed by '_'.
+ * For char stream "2.3W", "2.3" is not a valid decimal token, because it is followed by 'W'.
+ * For char stream "12.0D 34.E2+0.12 " 12.0D is a valid decimal token because it is followed
+ * by a space. 34.E2 is a valid decimal token because it is followed by symbol '+'
+ * which is not a digit or letter or underscore.
+ */
+ public boolean isValidDecimal() {
+ int nextChar = _input.LA(1);
+ if (nextChar >= 'A' && nextChar <= 'Z' || nextChar >= '0' && nextChar <= '9' ||
+ nextChar == '_') {
+ return false;
+ } else {
+ return true;
+ }
+ }
+
+ /**
+ * This method will be called when we see '/*' and try to match it as a bracketed comment.
+ * If the next character is '+', it should be parsed as hint later, and we cannot match
+ * it as a bracketed comment.
+ *
+ * Returns true if the next character is '+'.
+ */
+ public boolean isHint() {
+ int nextChar = _input.LA(1);
+ if (nextChar == '+') {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ /**
+ * This method will be called when the character stream ends and try to find out the
+ * unclosed bracketed comment.
+ * If the method be called, it means the end of the entire character stream match,
+ * and we set the flag and fail later.
+ */
+ public void markUnclosedComment() {
+ has_unclosed_bracketed_comment = true;
+ }
+}
+
+SEMICOLON: ';';
+
+LEFT_PAREN: '(';
+RIGHT_PAREN: ')';
+COMMA: ',';
+DOT: '.';
+LEFT_BRACKET: '[';
+RIGHT_BRACKET: ']';
+LEFT_BRACE: '{';
+RIGHT_BRACE: '}';
+
+// TODO: add a doc to list reserved words
+
+//============================
+// Start of the keywords list
+//============================
+//--DORIS-KEYWORD-LIST-START
+ACCOUNT_LOCK: 'ACCOUNT_LOCK';
+ACCOUNT_UNLOCK: 'ACCOUNT_UNLOCK';
+ADD: 'ADD';
+ADDDATE:'ADDDATE';
+ADMIN: 'ADMIN';
+AFTER: 'AFTER';
+AGG_STATE: 'AGG_STATE';
+AGGREGATE: 'AGGREGATE';
+ALIAS: 'ALIAS';
+ALL: 'ALL';
+ALTER: 'ALTER';
+ANALYZE: 'ANALYZE';
+ANALYZED: 'ANALYZED';
+AND: 'AND';
+ANTI: 'ANTI';
+APPEND: 'APPEND';
+ARRAY: 'ARRAY';
+AS: 'AS';
+ASC: 'ASC';
+AT: 'AT';
+AUTHORS: 'AUTHORS';
+AUTO: 'AUTO';
+AUTO_INCREMENT: 'AUTO_INCREMENT';
+BACKEND: 'BACKEND';
+BACKENDS: 'BACKENDS';
+BACKUP: 'BACKUP';
+BEGIN: 'BEGIN';
+BETWEEN: 'BETWEEN';
+BIGINT: 'BIGINT';
+BIN: 'BIN';
+BINARY: 'BINARY';
+BINLOG: 'BINLOG';
+BITAND: 'BITAND';
+BITMAP: 'BITMAP';
+BITMAP_UNION: 'BITMAP_UNION';
+BITOR: 'BITOR';
+BITXOR: 'BITXOR';
+BLOB: 'BLOB';
+BOOLEAN: 'BOOLEAN';
+BRIEF: 'BRIEF';
+BROKER: 'BROKER';
+BUCKETS: 'BUCKETS';
+BUILD: 'BUILD';
+BUILTIN: 'BUILTIN';
+BY: 'BY';
+CACHED: 'CACHED';
+CALL: 'CALL';
+CANCEL: 'CANCEL';
+CASE: 'CASE';
+CAST: 'CAST';
+CATALOG: 'CATALOG';
+CATALOGS: 'CATALOGS';
+CHAIN: 'CHAIN';
+CHAR: 'CHAR' | 'CHARACTER';
+CHARSET: 'CHARSET';
+CHECK: 'CHECK';
+CLEAN: 'CLEAN';
+CLUSTER: 'CLUSTER';
+CLUSTERS: 'CLUSTERS';
+COLLATE: 'COLLATE';
+COLLATION: 'COLLATION';
+COLUMN: 'COLUMN';
+COLUMNS: 'COLUMNS';
+COMMENT: 'COMMENT';
+COMMIT: 'COMMIT';
+COMMITTED: 'COMMITTED';
+COMPACT: 'COMPACT';
+COMPLETE: 'COMPLETE';
+CONFIG: 'CONFIG';
+CONNECTION: 'CONNECTION';
+CONNECTION_ID: 'CONNECTION_ID';
+CONSISTENT: 'CONSISTENT';
+CONSTRAINT: 'CONSTRAINT';
+CONVERT: 'CONVERT';
+COPY: 'COPY';
+COUNT: 'COUNT';
+CREATE: 'CREATE';
+CREATION: 'CREATION';
+CRON: 'CRON';
+CROSS: 'CROSS';
+CUBE: 'CUBE';
+CURRENT: 'CURRENT';
+CURRENT_CATALOG: 'CURRENT_CATALOG';
+CURRENT_TIMESTAMP: 'CURRENT_TIMESTAMP';
+CURRENT_USER: 'CURRENT_USER';
+DATA: 'DATA';
+DATABASE: 'DATABASE';
+DATABASES: 'DATABASES';
+DATE: 'DATE';
+DATE_ADD: 'DATE_ADD';
+DATE_CEIL: 'DATE_CEIL';
+DATE_DIFF: 'DATE_DIFF';
+DATE_FLOOR: 'DATE_FLOOR';
+DATE_SUB: 'DATE_SUB';
+DATEADD: 'DATEADD';
+DATEDIFF: 'DATEDIFF';
+DATETIME: 'DATETIME';
+DATETIMEV2: 'DATETIMEV2';
+DATEV2: 'DATEV2';
+DATETIMEV1: 'DATETIMEV1';
+DATEV1: 'DATEV1';
+DAY: 'DAY';
+DAYS_ADD: 'DAYS_ADD';
+DAYS_SUB: 'DAYS_SUB';
+DECIMAL: 'DECIMAL';
+DECIMALV2: 'DECIMALV2';
+DECIMALV3: 'DECIMALV3';
+DECOMMISSION: 'DECOMMISSION';
+DEFAULT: 'DEFAULT';
+DEFERRED: 'DEFERRED';
+DELETE: 'DELETE';
+DEMAND: 'DEMAND';
+DESC: 'DESC';
+DESCRIBE: 'DESCRIBE';
+DIAGNOSE: 'DIAGNOSE';
+DISK: 'DISK';
+DISTINCT: 'DISTINCT';
+DISTINCTPC: 'DISTINCTPC';
+DISTINCTPCSA: 'DISTINCTPCSA';
+DISTRIBUTED: 'DISTRIBUTED';
+DISTRIBUTION: 'DISTRIBUTION';
+DIV: 'DIV';
+DO: 'DO';
+DORIS_INTERNAL_TABLE_ID: 'DORIS_INTERNAL_TABLE_ID';
+DOUBLE: 'DOUBLE';
+DROP: 'DROP';
+DROPP: 'DROPP';
+DUPLICATE: 'DUPLICATE';
+DYNAMIC: 'DYNAMIC';
+ELSE: 'ELSE';
+ENABLE: 'ENABLE';
+ENCRYPTKEY: 'ENCRYPTKEY';
+ENCRYPTKEYS: 'ENCRYPTKEYS';
+END: 'END';
+ENDS: 'ENDS';
+ENGINE: 'ENGINE';
+ENGINES: 'ENGINES';
+ENTER: 'ENTER';
+ERRORS: 'ERRORS';
+EVENTS: 'EVENTS';
+EVERY: 'EVERY';
+EXCEPT: 'EXCEPT';
+EXCLUDE: 'EXCLUDE';
+EXECUTE: 'EXECUTE';
+EXISTS: 'EXISTS';
+EXPIRED: 'EXPIRED';
+EXPLAIN: 'EXPLAIN';
+EXPORT: 'EXPORT';
+EXTENDED: 'EXTENDED';
+EXTERNAL: 'EXTERNAL';
+EXTRACT: 'EXTRACT';
+FAILED_LOGIN_ATTEMPTS: 'FAILED_LOGIN_ATTEMPTS';
+FALSE: 'FALSE';
+FAST: 'FAST';
+FEATURE: 'FEATURE';
+FIELDS: 'FIELDS';
+FILE: 'FILE';
+FILTER: 'FILTER';
+FIRST: 'FIRST';
+FLOAT: 'FLOAT';
+FOLLOWER: 'FOLLOWER';
+FOLLOWING: 'FOLLOWING';
+FOR: 'FOR';
+FOREIGN: 'FOREIGN';
+FORCE: 'FORCE';
+FORMAT: 'FORMAT';
+FREE: 'FREE';
+FROM: 'FROM';
+FRONTEND: 'FRONTEND';
+FRONTENDS: 'FRONTENDS';
+FULL: 'FULL';
+FUNCTION: 'FUNCTION';
+FUNCTIONS: 'FUNCTIONS';
+GLOBAL: 'GLOBAL';
+GRANT: 'GRANT';
+GRANTS: 'GRANTS';
+GRAPH: 'GRAPH';
+GROUP: 'GROUP';
+GROUPING: 'GROUPING';
+GROUPS: 'GROUPS';
+HASH: 'HASH';
+HAVING: 'HAVING';
+HDFS: 'HDFS';
+HELP: 'HELP';
+HISTOGRAM: 'HISTOGRAM';
+HLL: 'HLL';
+HLL_UNION: 'HLL_UNION';
+HOSTNAME: 'HOSTNAME';
+HOUR: 'HOUR';
+HUB: 'HUB';
+IDENTIFIED: 'IDENTIFIED';
+IF: 'IF';
+IGNORE: 'IGNORE';
+IMMEDIATE: 'IMMEDIATE';
+IN: 'IN';
+INCREMENTAL: 'INCREMENTAL';
+INDEX: 'INDEX';
+INDEXES: 'INDEXES';
+INFILE: 'INFILE';
+INNER: 'INNER';
+INSERT: 'INSERT';
+INSTALL: 'INSTALL';
+INT: 'INT';
+INTEGER: 'INTEGER';
+INTERMEDIATE: 'INTERMEDIATE';
+INTERSECT: 'INTERSECT';
+INTERVAL: 'INTERVAL';
+INTO: 'INTO';
+INVERTED: 'INVERTED';
+IPV4: 'IPV4';
+IPV6: 'IPV6';
+IS: 'IS';
+IS_NOT_NULL_PRED: 'IS_NOT_NULL_PRED';
+IS_NULL_PRED: 'IS_NULL_PRED';
+ISNULL: 'ISNULL';
+ISOLATION: 'ISOLATION';
+JOB: 'JOB';
+JOBS: 'JOBS';
+JOIN: 'JOIN';
+JSON: 'JSON';
+JSONB: 'JSONB';
+KEY: 'KEY';
+KEYS: 'KEYS';
+KILL: 'KILL';
+LABEL: 'LABEL';
+LARGEINT: 'LARGEINT';
+LAST: 'LAST';
+LATERAL: 'LATERAL';
+LDAP: 'LDAP';
+LDAP_ADMIN_PASSWORD: 'LDAP_ADMIN_PASSWORD';
+LEFT: 'LEFT';
+LESS: 'LESS';
+LEVEL: 'LEVEL';
+LIKE: 'LIKE';
+LIMIT: 'LIMIT';
+LINES: 'LINES';
+LINK: 'LINK';
+LIST: 'LIST';
+LOAD: 'LOAD';
+LOCAL: 'LOCAL';
+LOCATION: 'LOCATION';
+LOCK: 'LOCK';
+LOGICAL: 'LOGICAL';
+LOW_PRIORITY: 'LOW_PRIORITY';
+MANUAL: 'MANUAL';
+MAP: 'MAP';
+MATCH: 'MATCH';
+MATCH_ALL: 'MATCH_ALL';
+MATCH_ANY: 'MATCH_ANY';
+MATCH_ELEMENT_EQ: 'ELEMENT_EQ';
+MATCH_ELEMENT_GE: 'ELEMENT_GE';
+MATCH_ELEMENT_GT: 'ELEMENT_GT';
+MATCH_ELEMENT_LE: 'ELEMENT_LE';
+MATCH_ELEMENT_LT: 'ELEMENT_LT';
+MATCH_PHRASE: 'MATCH_PHRASE';
+MATCH_PHRASE_PREFIX: 'MATCH_PHRASE_PREFIX';
+MATCH_REGEXP: 'MATCH_REGEXP';
+MATERIALIZED: 'MATERIALIZED';
+MAX: 'MAX';
+MAXVALUE: 'MAXVALUE';
+MEMO:'MEMO';
+MERGE: 'MERGE';
+MIGRATE: 'MIGRATE';
+MIGRATIONS: 'MIGRATIONS';
+MIN: 'MIN';
+MINUS: 'MINUS';
+MINUTE: 'MINUTE';
+MODIFY: 'MODIFY';
+MONTH: 'MONTH';
+MTMV: 'MTMV';
+NAME: 'NAME';
+NAMES: 'NAMES';
+NATURAL: 'NATURAL';
+NEGATIVE: 'NEGATIVE';
+NEVER: 'NEVER';
+NEXT: 'NEXT';
+NGRAM_BF: 'NGRAM_BF';
+NO: 'NO';
+NON_NULLABLE: 'NON_NULLABLE';
+NOT: 'NOT';
+NULL: 'NULL';
+NULLS: 'NULLS';
+OBSERVER: 'OBSERVER';
+OF: 'OF';
+OFFSET: 'OFFSET';
+ON: 'ON';
+ONLY: 'ONLY';
+OPEN: 'OPEN';
+OPTIMIZED: 'OPTIMIZED';
+OR: 'OR';
+ORDER: 'ORDER';
+OUTER: 'OUTER';
+OUTFILE: 'OUTFILE';
+OVER: 'OVER';
+OVERWRITE: 'OVERWRITE';
+PARAMETER: 'PARAMETER';
+PARSED: 'PARSED';
+PARTITION: 'PARTITION';
+PARTITIONS: 'PARTITIONS';
+PASSWORD: 'PASSWORD';
+PASSWORD_EXPIRE: 'PASSWORD_EXPIRE';
+PASSWORD_HISTORY: 'PASSWORD_HISTORY';
+PASSWORD_LOCK_TIME: 'PASSWORD_LOCK_TIME';
+PASSWORD_REUSE: 'PASSWORD_REUSE';
+PATH: 'PATH';
+PAUSE: 'PAUSE';
+PERCENT: 'PERCENT';
+PERIOD: 'PERIOD';
+PERMISSIVE: 'PERMISSIVE';
+PHYSICAL: 'PHYSICAL';
+PLAN: 'PLAN';
+PLUGIN: 'PLUGIN';
+PLUGINS: 'PLUGINS';
+POLICY: 'POLICY';
+PRECEDING: 'PRECEDING';
+PREPARE: 'PREPARE';
+PRIMARY: 'PRIMARY';
+PROC: 'PROC';
+PROCEDURE: 'PROCEDURE';
+PROCESSLIST: 'PROCESSLIST';
+PROFILE: 'PROFILE';
+PROPERTIES: 'PROPERTIES';
+PROPERTY: 'PROPERTY';
+QUANTILE_STATE: 'QUANTILE_STATE';
+QUANTILE_UNION: 'QUANTILE_UNION';
+QUERY: 'QUERY';
+QUOTA: 'QUOTA';
+RANDOM: 'RANDOM';
+RANGE: 'RANGE';
+READ: 'READ';
+REAL: 'REAL';
+REBALANCE: 'REBALANCE';
+RECOVER: 'RECOVER';
+RECYCLE: 'RECYCLE';
+REFRESH: 'REFRESH';
+REFERENCES: 'REFERENCES';
+REGEXP: 'REGEXP';
+RELEASE: 'RELEASE';
+RENAME: 'RENAME';
+REPAIR: 'REPAIR';
+REPEATABLE: 'REPEATABLE';
+REPLACE: 'REPLACE';
+REPLACE_IF_NOT_NULL: 'REPLACE_IF_NOT_NULL';
+REPLICA: 'REPLICA';
+REPOSITORIES: 'REPOSITORIES';
+REPOSITORY: 'REPOSITORY';
+RESOURCE: 'RESOURCE';
+RESOURCES: 'RESOURCES';
+RESTORE: 'RESTORE';
+RESTRICTIVE: 'RESTRICTIVE';
+RESUME: 'RESUME';
+RETURNS: 'RETURNS';
+REVOKE: 'REVOKE';
+REWRITTEN: 'REWRITTEN';
+RIGHT: 'RIGHT';
+RLIKE: 'RLIKE';
+ROLE: 'ROLE';
+ROLES: 'ROLES';
+ROLLBACK: 'ROLLBACK';
+ROLLUP: 'ROLLUP';
+ROUTINE: 'ROUTINE';
+ROW: 'ROW';
+ROWS: 'ROWS';
+S3: 'S3';
+SAMPLE: 'SAMPLE';
+SCHEDULE: 'SCHEDULE';
+SCHEDULER: 'SCHEDULER';
+SCHEMA: 'SCHEMA';
+SCHEMAS: 'SCHEMAS';
+SECOND: 'SECOND';
+SELECT: 'SELECT';
+SEMI: 'SEMI';
+SERIALIZABLE: 'SERIALIZABLE';
+SESSION: 'SESSION';
+SET: 'SET';
+SETS: 'SETS';
+SHAPE: 'SHAPE';
+SHOW: 'SHOW';
+SIGNED: 'SIGNED';
+SKEW: 'SKEW';
+SMALLINT: 'SMALLINT';
+SNAPSHOT: 'SNAPSHOT';
+SONAME: 'SONAME';
+SPLIT: 'SPLIT';
+SQL_BLOCK_RULE: 'SQL_BLOCK_RULE';
+START: 'START';
+STARTS: 'STARTS';
+STATS: 'STATS';
+STATUS: 'STATUS';
+STOP: 'STOP';
+STORAGE: 'STORAGE';
+STREAM: 'STREAM';
+STREAMING: 'STREAMING';
+STRING: 'STRING';
+STRUCT: 'STRUCT';
+SUBDATE: 'SUBDATE';
+SUM: 'SUM';
+SUPERUSER: 'SUPERUSER';
+SWITCH: 'SWITCH';
+SYNC: 'SYNC';
+SYSTEM: 'SYSTEM';
+TABLE: 'TABLE';
+TABLES: 'TABLES';
+TABLESAMPLE: 'TABLESAMPLE';
+TABLET: 'TABLET';
+TABLETS: 'TABLETS';
+TASK: 'TASK';
+TASKS: 'TASKS';
+TEMPORARY: 'TEMPORARY';
+TERMINATED: 'TERMINATED';
+TEXT: 'TEXT';
+THAN: 'THAN';
+THEN: 'THEN';
+TIME: 'TIME';
+TIMESTAMP: 'TIMESTAMP';
+TIMESTAMPADD: 'TIMESTAMPADD';
+TIMESTAMPDIFF: 'TIMESTAMPDIFF';
+TINYINT: 'TINYINT';
+TO: 'TO';
+TRANSACTION: 'TRANSACTION';
+TRASH: 'TRASH';
+TREE: 'TREE';
+TRIGGERS: 'TRIGGERS';
+TRIM: 'TRIM';
+TRUE: 'TRUE';
+TRUNCATE: 'TRUNCATE';
+TYPE: 'TYPE';
+TYPECAST: 'TYPE_CAST';
+TYPES: 'TYPES';
+UNBOUNDED: 'UNBOUNDED';
+UNCOMMITTED: 'UNCOMMITTED';
+UNINSTALL: 'UNINSTALL';
+UNION: 'UNION';
+UNIQUE: 'UNIQUE';
+UNLOCK: 'UNLOCK';
+UNSIGNED: 'UNSIGNED';
+UPDATE: 'UPDATE';
+USE: 'USE';
+USER: 'USER';
+USING: 'USING';
+VALUE: 'VALUE';
+VALUES: 'VALUES';
+VARCHAR: 'VARCHAR';
+VARIABLES: 'VARIABLES';
+VERBOSE: 'VERBOSE';
+VERSION: 'VERSION';
+VIEW: 'VIEW';
+WARNINGS: 'WARNINGS';
+WEEK: 'WEEK';
+WHEN: 'WHEN';
+WHERE: 'WHERE';
+WHITELIST: 'WHITELIST';
+WITH: 'WITH';
+WORK: 'WORK';
+WORKLOAD: 'WORKLOAD';
+WRITE: 'WRITE';
+YEAR: 'YEAR';
+//--DORIS-KEYWORD-LIST-END
+//============================
+// End of the keywords list
+//============================
+
+EQ : '=' | '==';
+NSEQ: '<=>';
+NEQ : '<>' | '!=';
+LT : '<';
+LTE : '<=' | '!>';
+GT : '>';
+GTE : '>=' | '!<';
+
+PLUS: '+';
+SUBTRACT: '-';
+ASTERISK: '*';
+SLASH: '/';
+MOD: '%';
+TILDE: '~';
+AMPERSAND: '&';
+LOGICALAND: '&&';
+LOGICALNOT: '!';
+PIPE: '|';
+DOUBLEPIPES: '||';
+HAT: '^';
+COLON: ':';
+ARROW: '->';
+HINT_START: '/*+';
+HINT_END: '*/';
+ATSIGN: '@';
+DOUBLEATSIGN: '@@';
+
+STRING_LITERAL
+ : '\'' ('\\'. | '\'\'' | ~('\'' | '\\'))* '\''
+ | '"' ( '\\'. | '""' | ~('"'| '\\') )* '"'
+ | 'R\'' (~'\'')* '\''
+ | 'R"'(~'"')* '"'
+ ;
+
+LEADING_STRING
+ : LEFT_BRACE
+ | RIGHT_BRACE
+ | LEFT_BRACKET
+ | RIGHT_BRACKET
+ ;
+
+BIGINT_LITERAL
+ : DIGIT+ 'L'
+ ;
+
+SMALLINT_LITERAL
+ : DIGIT+ 'S'
+ ;
+
+TINYINT_LITERAL
+ : DIGIT+ 'Y'
+ ;
+
+INTEGER_VALUE
+ : DIGIT+
+ ;
+
+EXPONENT_VALUE
+ : DIGIT+ EXPONENT
+ | DECIMAL_DIGITS EXPONENT {isValidDecimal()}?
+ ;
+
+DECIMAL_VALUE
+ : DECIMAL_DIGITS {isValidDecimal()}?
+ ;
+
+BIGDECIMAL_LITERAL
+ : DIGIT+ EXPONENT? 'BD'
+ | DECIMAL_DIGITS EXPONENT? 'BD' {isValidDecimal()}?
+ ;
+
+IDENTIFIER
+ : (LETTER | DIGIT | '_')+
+ ;
+
+BACKQUOTED_IDENTIFIER
+ : '`' ( ~'`' | '``' )* '`'
+ ;
+
+fragment DECIMAL_DIGITS
+ : DIGIT+ '.' DIGIT*
+ | '.' DIGIT+
+ ;
+
+fragment EXPONENT
+ : 'E' [+-]? DIGIT+
+ ;
+
+fragment DIGIT
+ : [0-9]
+ ;
+
+fragment LETTER
+ : [a-zA-Z$_] // these are the "java letters" below 0x7F
+ | ~[\u0000-\u007F\uD800-\uDBFF] // covers all characters above 0x7F which are not a surrogate
+ | [\uD800-\uDBFF] [\uDC00-\uDFFF] // covers UTF-16 surrogate pairs encodings for U+10000 to U+10FFFF
+ ;
+
+SIMPLE_COMMENT
+ : '--' ('\\\n' | ~[\r\n])* '\r'? '\n'? -> channel(HIDDEN)
+ ;
+
+BRACKETED_COMMENT
+ : '/*' {!isHint()}? ( BRACKETED_COMMENT | . )*? ('*/' | {markUnclosedComment();} EOF) -> channel(HIDDEN)
+ ;
+
+WS
+ : [ \r\n\t]+ -> channel(HIDDEN)
+ ;
+
+// Catch-all for anything we can't recognize.
+// We use this to be able to ignore and recover all the text
+// when splitting statements with DelimiterLexer
+UNRECOGNIZED
+ : .
+ ;
diff --git a/fastmodel-transform/fastmodel-transform-doris/src/main/antlr4/com/aliyun/fastmodel/transform/doris/parser/DorisParser.g4 b/fastmodel-transform/fastmodel-transform-doris/src/main/antlr4/com/aliyun/fastmodel/transform/doris/parser/DorisParser.g4
new file mode 100644
index 0000000..7159350
--- /dev/null
+++ b/fastmodel-transform/fastmodel-transform-doris/src/main/antlr4/com/aliyun/fastmodel/transform/doris/parser/DorisParser.g4
@@ -0,0 +1,1167 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+// Copied from Apache Spark and modified for Apache Doris
+
+parser grammar DorisParser;
+
+options { tokenVocab = DorisLexer; }
+
+@members {
+ public boolean doris_legacy_SQL_syntax = true;
+}
+
+multiStatements
+ : (statement SEMICOLON*)+ EOF
+ ;
+
+singleStatement
+ : statement SEMICOLON* EOF
+ ;
+
+statement
+ : explain? query outFileClause? #statementDefault
+ | CREATE ROW POLICY (IF NOT EXISTS)? name=identifier
+ ON table=multipartIdentifier
+ AS type=(RESTRICTIVE | PERMISSIVE)
+ TO (user=userIdentify | ROLE roleName=identifier)
+ USING LEFT_PAREN booleanExpression RIGHT_PAREN #createRowPolicy
+ | CREATE (EXTERNAL)? TABLE (IF NOT EXISTS)? name=multipartIdentifier
+ ((ctasCols=identifierList)? | (LEFT_PAREN columnDefs (COMMA indexDefs)? COMMA? RIGHT_PAREN))
+ (ENGINE EQ engine=identifier)?
+ ((AGGREGATE | UNIQUE | DUPLICATE) KEY keys=identifierList (CLUSTER BY clusterKeys=identifierList)?)?
+ (COMMENT STRING_LITERAL)?
+ ((autoPartition=AUTO)? PARTITION BY (RANGE | LIST) (partitionKeys=identifierList | partitionExpr=functionCallExpression)
+ LEFT_PAREN (partitions=partitionsDef)? RIGHT_PAREN)?
+ (DISTRIBUTED BY (HASH hashKeys=identifierList | RANDOM) (BUCKETS (INTEGER_VALUE | autoBucket=AUTO))?)?
+ (ROLLUP LEFT_PAREN rollupDefs RIGHT_PAREN)?
+ properties=propertyClause?
+ (BROKER extProperties=propertyClause)?
+ (AS query)? #createTable
+ | explain? INSERT (INTO | OVERWRITE TABLE)
+ (tableName=multipartIdentifier | DORIS_INTERNAL_TABLE_ID LEFT_PAREN tableId=INTEGER_VALUE RIGHT_PAREN)
+ partitionSpec? // partition define
+ (WITH LABEL labelName=identifier)? cols=identifierList? // label and columns define
+ (LEFT_BRACKET hints=identifierSeq RIGHT_BRACKET)? // hint define
+ query #insertTable
+ | explain? cte? UPDATE tableName=multipartIdentifier tableAlias
+ SET updateAssignmentSeq
+ fromClause?
+ whereClause #update
+ | explain? cte? DELETE FROM tableName=multipartIdentifier
+ partitionSpec? tableAlias
+ (USING relation (COMMA relation)*)?
+ whereClause #delete
+ | LOAD LABEL lableName=identifier
+ LEFT_PAREN dataDescs+=dataDesc (COMMA dataDescs+=dataDesc)* RIGHT_PAREN
+ (withRemoteStorageSystem)?
+ (PROPERTIES LEFT_PAREN properties=propertyItemList RIGHT_PAREN)?
+ (commentSpec)? #load
+ | LOAD mysqlDataDesc
+ (PROPERTIES LEFT_PAREN properties=propertyItemList RIGHT_PAREN)?
+ (commentSpec)? #mysqlLoad
+ | EXPORT TABLE tableName=multipartIdentifier
+ (PARTITION partition=identifierList)?
+ (whereClause)?
+ TO filePath=STRING_LITERAL
+ (propertyClause)?
+ (withRemoteStorageSystem)? #export
+ | CREATE MATERIALIZED VIEW (IF NOT EXISTS)? mvName=multipartIdentifier
+ (LEFT_PAREN cols=simpleColumnDefs RIGHT_PAREN)? buildMode?
+ (REFRESH refreshMethod? refreshTrigger?)?
+ (KEY keys=identifierList)?
+ (COMMENT STRING_LITERAL)?
+ (PARTITION BY LEFT_PAREN partitionKey = identifier RIGHT_PAREN)?
+ (DISTRIBUTED BY (HASH hashKeys=identifierList | RANDOM) (BUCKETS (INTEGER_VALUE | AUTO))?)?
+ propertyClause?
+ AS query #createMTMV
+ | REFRESH MATERIALIZED VIEW mvName=multipartIdentifier (partitionSpec | COMPLETE)? #refreshMTMV
+ | ALTER MATERIALIZED VIEW mvName=multipartIdentifier ((RENAME newName=identifier)
+ | (REFRESH (refreshMethod | refreshTrigger | refreshMethod refreshTrigger))
+ | (SET LEFT_PAREN fileProperties=propertyItemList RIGHT_PAREN)) #alterMTMV
+ | DROP MATERIALIZED VIEW (IF EXISTS)? mvName=multipartIdentifier #dropMTMV
+ | PAUSE MATERIALIZED VIEW JOB ON mvName=multipartIdentifier #pauseMTMV
+ | RESUME MATERIALIZED VIEW JOB ON mvName=multipartIdentifier #resumeMTMV
+ | CANCEL MATERIALIZED VIEW TASK taskId=INTEGER_VALUE ON mvName=multipartIdentifier #cancelMTMVTask
+ | ALTER TABLE table=relation
+ ADD CONSTRAINT constraintName=errorCapturingIdentifier
+ constraint #addConstraint
+ | ALTER TABLE table=relation
+ DROP CONSTRAINT constraintName=errorCapturingIdentifier #dropConstraint
+ | CALL functionName=identifier LEFT_PAREN (expression (COMMA expression)*)? RIGHT_PAREN #callProcedure
+ ;
+
+constraint
+ : PRIMARY KEY slots=identifierList
+ | UNIQUE slots=identifierList
+ | FOREIGN KEY slots=identifierList
+ REFERENCES referenceTable=multipartIdentifier
+ referencedSlots=identifierList
+ ;
+
+partitionSpec
+ : TEMPORARY? (PARTITION | PARTITIONS) partitions=identifierList
+ | TEMPORARY? PARTITION partition=errorCapturingIdentifier
+ // TODO: support analyze external table partition spec https://github.com/apache/doris/pull/24154
+ // | PARTITIONS LEFT_PAREN ASTERISK RIGHT_PAREN
+ // | PARTITIONS WITH RECENT
+ ;
+
+dataDesc
+ : ((WITH)? mergeType)? DATA INFILE LEFT_PAREN filePaths+=STRING_LITERAL (COMMA filePath+=STRING_LITERAL)* RIGHT_PAREN
+ INTO TABLE tableName=multipartIdentifier
+ (PARTITION partition=identifierList)?
+ (COLUMNS TERMINATED BY comma=STRING_LITERAL)?
+ (LINES TERMINATED BY separator=STRING_LITERAL)?
+ (FORMAT AS format=identifierOrStringLiteral)?
+ (columns=identifierList)?
+ (columnsFromPath=colFromPath)?
+ (columnMapping=colMappingList)?
+ (preFilter=preFilterClause)?
+ (where=whereClause)?
+ (deleteOn=deleteOnClause)?
+ (sequenceColumn=sequenceColClause)?
+ (propertyClause)?
+ | ((WITH)? mergeType)? DATA FROM TABLE tableName=multipartIdentifier
+ INTO TABLE tableName=multipartIdentifier
+ (PARTITION partition=identifierList)?
+ (columnMapping=colMappingList)?
+ (where=whereClause)?
+ (deleteOn=deleteOnClause)?
+ (propertyClause)?
+ ;
+
+// -----------------Command accessories-----------------
+buildMode
+ : BUILD (IMMEDIATE | DEFERRED)
+ ;
+
+refreshTrigger
+ : ON MANUAL
+ | ON SCHEDULE refreshSchedule
+ ;
+
+refreshSchedule
+ : EVERY INTEGER_VALUE refreshUnit = identifier (STARTS STRING_LITERAL)?
+ ;
+
+refreshMethod
+ : COMPLETE | AUTO
+ ;
+
+identifierOrStringLiteral
+ : identifier
+ | STRING_LITERAL
+ ;
+
+identifierOrText
+ : errorCapturingIdentifier
+ | STRING_LITERAL
+ | LEADING_STRING
+ ;
+
+userIdentify
+ : user=identifierOrText (AT (host=identifierOrText | LEFT_PAREN host=identifierOrText RIGHT_PAREN))?
+ ;
+
+
+explain
+ : (EXPLAIN planType? | DESC | DESCRIBE)
+ level=(VERBOSE | TREE | GRAPH | PLAN)?
+ ;
+
+planType
+ : PARSED
+ | ANALYZED
+ | REWRITTEN | LOGICAL // same type
+ | OPTIMIZED | PHYSICAL // same type
+ | SHAPE
+ | MEMO
+ | ALL // default type
+ ;
+
+mergeType
+ : APPEND
+ | DELETE
+ | MERGE
+ ;
+
+preFilterClause
+ : PRECEDING FILTER expression
+ ;
+
+deleteOnClause
+ : DELETE ON expression
+ ;
+
+sequenceColClause
+ : ORDER BY identifier
+ ;
+
+colFromPath
+ : COLUMNS FROM PATH AS identifierList
+ ;
+
+colMappingList
+ : SET LEFT_PAREN mappingSet+=mappingExpr (COMMA mappingSet+=mappingExpr)* RIGHT_PAREN
+ ;
+
+mappingExpr
+ : (mappingCol=identifier EQ expression)
+ ;
+
+withRemoteStorageSystem
+ : resourceDesc
+ | WITH S3 LEFT_PAREN
+ brokerProperties=propertyItemList
+ RIGHT_PAREN
+ | WITH HDFS LEFT_PAREN
+ brokerProperties=propertyItemList
+ RIGHT_PAREN
+ | WITH LOCAL LEFT_PAREN
+ brokerProperties=propertyItemList
+ RIGHT_PAREN
+ | WITH BROKER brokerName=identifierOrText
+ (LEFT_PAREN
+ brokerProperties=propertyItemList
+ RIGHT_PAREN)?
+ ;
+
+resourceDesc
+ : WITH RESOURCE resourceName=identifierOrText (LEFT_PAREN propertyItemList RIGHT_PAREN)?
+ ;
+
+mysqlDataDesc
+ : DATA (LOCAL booleanValue)?
+ INFILE filePath=STRING_LITERAL
+ INTO TABLE tableName=multipartIdentifier
+ (PARTITION partition=identifierList)?
+ (COLUMNS TERMINATED BY comma=STRING_LITERAL)?
+ (LINES TERMINATED BY separator=STRING_LITERAL)?
+ (skipLines)?
+ (columns=identifierList)?
+ (colMappingList)?
+ (propertyClause)?
+ ;
+
+skipLines : IGNORE lines=INTEGER_VALUE LINES | IGNORE lines=INTEGER_VALUE ROWS ;
+
+// -----------------Query-----------------
+// add queryOrganization for parse (q1) union (q2) union (q3) order by keys, otherwise 'order' will be recognized to be
+// identifier.
+
+outFileClause
+ : INTO OUTFILE filePath=constant
+ (FORMAT AS format=identifier)?
+ (propertyClause)?
+ ;
+
+query
+ : cte? queryTerm queryOrganization
+ ;
+
+queryTerm
+ : queryPrimary #queryTermDefault
+ | left=queryTerm operator=(UNION | EXCEPT | INTERSECT)
+ setQuantifier? right=queryTerm #setOperation
+ ;
+
+setQuantifier
+ : DISTINCT
+ | ALL
+ ;
+
+queryPrimary
+ : querySpecification #queryPrimaryDefault
+ | LEFT_PAREN query RIGHT_PAREN #subquery
+ | inlineTable #valuesTable
+ ;
+
+querySpecification
+ : selectClause
+ fromClause?
+ whereClause?
+ aggClause?
+ havingClause?
+ {doris_legacy_SQL_syntax}? queryOrganization #regularQuerySpecification
+ ;
+
+cte
+ : WITH aliasQuery (COMMA aliasQuery)*
+ ;
+
+aliasQuery
+ : identifier columnAliases? AS LEFT_PAREN query RIGHT_PAREN
+ ;
+
+columnAliases
+ : LEFT_PAREN identifier (COMMA identifier)* RIGHT_PAREN
+ ;
+
+selectClause
+ : SELECT selectHint? DISTINCT? selectColumnClause
+ ;
+
+selectColumnClause
+ : namedExpressionSeq
+ | ASTERISK EXCEPT LEFT_PAREN namedExpressionSeq RIGHT_PAREN
+ ;
+
+whereClause
+ : WHERE booleanExpression
+ ;
+
+fromClause
+ : FROM relation (COMMA relation)*
+ ;
+
+relation
+ : relationPrimary joinRelation*
+ ;
+
+joinRelation
+ : (joinType) JOIN distributeType? right=relationPrimary joinCriteria?
+ ;
+
+// Just like `opt_plan_hints` in legacy CUP parser.
+distributeType
+ : LEFT_BRACKET identifier RIGHT_BRACKET #bracketDistributeType
+ | HINT_START identifier HINT_END #commentDistributeType
+ ;
+
+relationHint
+ : LEFT_BRACKET identifier (COMMA identifier)* RIGHT_BRACKET #bracketRelationHint
+ | HINT_START identifier (COMMA identifier)* HINT_END #commentRelationHint
+ ;
+
+aggClause
+ : GROUP BY groupingElement?
+ ;
+
+groupingElement
+ : ROLLUP LEFT_PAREN (expression (COMMA expression)*)? RIGHT_PAREN
+ | CUBE LEFT_PAREN (expression (COMMA expression)*)? RIGHT_PAREN
+ | GROUPING SETS LEFT_PAREN groupingSet (COMMA groupingSet)* RIGHT_PAREN
+ | expression (COMMA expression)*
+ ;
+
+groupingSet
+ : LEFT_PAREN (expression (COMMA expression)*)? RIGHT_PAREN
+ ;
+
+havingClause
+ : HAVING booleanExpression
+ ;
+
+selectHint: HINT_START hintStatements+=hintStatement (COMMA? hintStatements+=hintStatement)* HINT_END;
+
+hintStatement
+ : hintName=identifier (LEFT_PAREN parameters+=hintAssignment (COMMA? parameters+=hintAssignment)* RIGHT_PAREN)?
+ ;
+
+hintAssignment
+ : key=identifierOrText (EQ (constantValue=constant | identifierValue=identifier))?
+ ;
+
+updateAssignment
+ : col=multipartIdentifier EQ (expression | DEFAULT)
+ ;
+
+updateAssignmentSeq
+ : assignments+=updateAssignment (COMMA assignments+=updateAssignment)*
+ ;
+
+lateralView
+ : LATERAL VIEW functionName=identifier LEFT_PAREN (expression (COMMA expression)*)? RIGHT_PAREN
+ tableName=identifier AS columnName=identifier
+ ;
+
+queryOrganization
+ : sortClause? limitClause?
+ ;
+
+sortClause
+ : ORDER BY sortItem (COMMA sortItem)*
+ ;
+
+sortItem
+ : expression ordering = (ASC | DESC)? (NULLS (FIRST | LAST))?
+ ;
+
+limitClause
+ : (LIMIT limit=INTEGER_VALUE)
+ | (LIMIT limit=INTEGER_VALUE OFFSET offset=INTEGER_VALUE)
+ | (LIMIT offset=INTEGER_VALUE COMMA limit=INTEGER_VALUE)
+ ;
+
+partitionClause
+ : PARTITION BY expression (COMMA expression)*
+ ;
+
+joinType
+ : INNER?
+ | CROSS
+ | LEFT OUTER?
+ | RIGHT OUTER?
+ | FULL OUTER?
+ | LEFT SEMI
+ | RIGHT SEMI
+ | LEFT ANTI
+ | RIGHT ANTI
+ ;
+
+joinCriteria
+ : ON booleanExpression
+ | USING identifierList
+ ;
+
+identifierList
+ : LEFT_PAREN identifierSeq RIGHT_PAREN
+ ;
+
+identifierSeq
+ : ident+=errorCapturingIdentifier (COMMA ident+=errorCapturingIdentifier)*
+ ;
+
+relationPrimary
+ : multipartIdentifier specifiedPartition?
+ tabletList? tableAlias sample? relationHint? lateralView* #tableName
+ | LEFT_PAREN query RIGHT_PAREN tableAlias lateralView* #aliasedQuery
+ | tvfName=identifier LEFT_PAREN
+ (properties=propertyItemList)?
+ RIGHT_PAREN tableAlias #tableValuedFunction
+ ;
+
+propertyClause
+ : PROPERTIES LEFT_PAREN fileProperties=propertyItemList RIGHT_PAREN
+ ;
+
+propertyItemList
+ : properties+=propertyItem (COMMA properties+=propertyItem)*
+ ;
+
+propertyItem
+ : key=propertyKey EQ value=propertyValue
+ ;
+
+propertyKey : identifier | constant ;
+
+propertyValue : identifier | constant ;
+
+tableAlias
+ : (AS? strictIdentifier identifierList?)?
+ ;
+
+multipartIdentifier
+ : parts+=errorCapturingIdentifier (DOT parts+=errorCapturingIdentifier)*
+ ;
+
+// ----------------Create Table Fields----------
+simpleColumnDefs
+ : cols+=simpleColumnDef (COMMA cols+=simpleColumnDef)*
+ ;
+
+simpleColumnDef
+ : colName=identifier (COMMENT comment=STRING_LITERAL)?
+ ;
+
+columnDefs
+ : cols+=columnDef (COMMA cols+=columnDef)*
+ ;
+
+columnDef
+ : colName=identifier type=dataType
+ KEY? (aggType=aggTypeDef)? ((NOT NULL) | NULL)? (AUTO_INCREMENT)?
+ (DEFAULT (nullValue=NULL | INTEGER_VALUE | stringValue=STRING_LITERAL
+ | CURRENT_TIMESTAMP (LEFT_PAREN defaultValuePrecision=number RIGHT_PAREN)?))?
+ (ON UPDATE CURRENT_TIMESTAMP (LEFT_PAREN onUpdateValuePrecision=number RIGHT_PAREN)?)?
+ (COMMENT comment=STRING_LITERAL)?
+ ;
+
+indexDefs
+ : indexes+=indexDef (COMMA indexes+=indexDef)*
+ ;
+
+indexDef
+ : INDEX indexName=identifier cols=identifierList (USING indexType=(BITMAP | INVERTED | NGRAM_BF))? (PROPERTIES LEFT_PAREN properties=propertyItemList RIGHT_PAREN)? (COMMENT comment=STRING_LITERAL)?
+ ;
+
+partitionsDef
+ : partitions+=partitionDef (COMMA partitions+=partitionDef)*
+ ;
+
+partitionDef
+ : (lessThanPartitionDef | fixedPartitionDef | stepPartitionDef | inPartitionDef) (LEFT_PAREN partitionProperties=propertyItemList RIGHT_PAREN)?
+ ;
+
+lessThanPartitionDef
+ : PARTITION (IF NOT EXISTS)? partitionName=identifier VALUES LESS THAN (MAXVALUE | constantSeq)
+ ;
+
+fixedPartitionDef
+ : PARTITION (IF NOT EXISTS)? partitionName=identifier VALUES LEFT_BRACKET lower=constantSeq COMMA upper=constantSeq RIGHT_PAREN
+ ;
+
+stepPartitionDef
+ : FROM from=constantSeq TO to=constantSeq INTERVAL unitsAmount=INTEGER_VALUE unit=datetimeUnit?
+ ;
+
+inPartitionDef
+ : PARTITION (IF NOT EXISTS)? partitionName=identifier (VALUES IN ((LEFT_PAREN constantSeqs+=constantSeq
+ (COMMA constantSeqs+=constantSeq)* RIGHT_PAREN) | constants=constantSeq))?
+ ;
+
+constantSeq
+ : LEFT_PAREN values+=partitionValueDef (COMMA values+=partitionValueDef)* RIGHT_PAREN
+ ;
+
+partitionValueDef
+ : INTEGER_VALUE | STRING_LITERAL | MAXVALUE
+ ;
+
+rollupDefs
+ : rollups+=rollupDef (COMMA rollups+=rollupDef)*
+ ;
+
+rollupDef
+ : rollupName=identifier rollupCols=identifierList (DUPLICATE KEY dupKeys=identifierList)? properties=propertyClause?
+ ;
+
+aggTypeDef
+ : MAX | MIN | SUM | REPLACE | REPLACE_IF_NOT_NULL | HLL_UNION | BITMAP_UNION | QUANTILE_UNION
+ ;
+
+tabletList
+ : TABLET LEFT_PAREN tabletIdList+=INTEGER_VALUE (COMMA tabletIdList+=INTEGER_VALUE)* RIGHT_PAREN
+ ;
+
+
+inlineTable
+ : VALUES rowConstructor (COMMA rowConstructor)*
+ ;
+
+// -----------------Expression-----------------
+namedExpression
+ : expression (AS? (identifierOrText))?
+ ;
+
+namedExpressionSeq
+ : namedExpression (COMMA namedExpression)*
+ ;
+
+expression
+ : booleanExpression
+ | lambdaExpression
+ ;
+
+lambdaExpression
+ : args+=errorCapturingIdentifier ARROW body=booleanExpression
+ | LEFT_PAREN
+ args+=errorCapturingIdentifier (COMMA args+=errorCapturingIdentifier)+
+ RIGHT_PAREN
+ ARROW body=booleanExpression
+ ;
+
+booleanExpression
+ : (LOGICALNOT | NOT) booleanExpression #logicalNot
+ | EXISTS LEFT_PAREN query RIGHT_PAREN #exist
+ | (ISNULL | IS_NULL_PRED) LEFT_PAREN valueExpression RIGHT_PAREN #isnull
+ | IS_NOT_NULL_PRED LEFT_PAREN valueExpression RIGHT_PAREN #is_not_null_pred
+ | valueExpression predicate? #predicated
+ | left=booleanExpression operator=(AND | LOGICALAND) right=booleanExpression #logicalBinary
+ | left=booleanExpression operator=OR right=booleanExpression #logicalBinary
+ | left=booleanExpression operator=DOUBLEPIPES right=booleanExpression #doublePipes
+ ;
+
+rowConstructor
+ : LEFT_PAREN (rowConstructorItem (COMMA rowConstructorItem)*)? RIGHT_PAREN
+ ;
+
+rowConstructorItem
+ : namedExpression | DEFAULT
+ ;
+
+predicate
+ : NOT? kind=BETWEEN lower=valueExpression AND upper=valueExpression
+ | NOT? kind=(LIKE | REGEXP | RLIKE) pattern=valueExpression
+ | NOT? kind=(MATCH | MATCH_ANY | MATCH_ALL | MATCH_PHRASE | MATCH_PHRASE_PREFIX | MATCH_REGEXP) pattern=valueExpression
+ | NOT? kind=IN LEFT_PAREN query RIGHT_PAREN
+ | NOT? kind=IN LEFT_PAREN expression (COMMA expression)* RIGHT_PAREN
+ | IS NOT? kind=NULL
+ ;
+
+valueExpression
+ : primaryExpression #valueExpressionDefault
+ | operator=(SUBTRACT | PLUS | TILDE) valueExpression #arithmeticUnary
+ | left=valueExpression operator=(ASTERISK | SLASH | MOD) right=valueExpression #arithmeticBinary
+ | left=valueExpression operator=(PLUS | SUBTRACT | DIV | HAT | PIPE | AMPERSAND)
+ right=valueExpression #arithmeticBinary
+ | left=valueExpression comparisonOperator right=valueExpression #comparison
+ | operator=(BITAND | BITOR | BITXOR) LEFT_PAREN left = valueExpression
+ COMMA right = valueExpression RIGHT_PAREN #bitOperation
+ ;
+
+datetimeUnit
+ : YEAR | MONTH
+ | WEEK | DAY
+ | HOUR | MINUTE | SECOND
+ ;
+
+primaryExpression
+ : name=(TIMESTAMPDIFF | DATEDIFF)
+ LEFT_PAREN
+ unit=datetimeUnit COMMA
+ startTimestamp=valueExpression COMMA
+ endTimestamp=valueExpression
+ RIGHT_PAREN #timestampdiff
+ | name=(TIMESTAMPADD | DATEADD)
+ LEFT_PAREN
+ unit=datetimeUnit COMMA
+ startTimestamp=valueExpression COMMA
+ endTimestamp=valueExpression
+ RIGHT_PAREN #timestampadd
+ | name =(ADDDATE | DAYS_ADD | DATE_ADD)
+ LEFT_PAREN
+ timestamp=valueExpression COMMA
+ (INTERVAL unitsAmount=valueExpression unit=datetimeUnit
+ | unitsAmount=valueExpression)
+ RIGHT_PAREN #date_add
+ | name=(SUBDATE | DAYS_SUB | DATE_SUB)
+ LEFT_PAREN
+ timestamp=valueExpression COMMA
+ (INTERVAL unitsAmount=valueExpression unit=datetimeUnit
+ | unitsAmount=valueExpression)
+ RIGHT_PAREN #date_sub
+ | name=DATE_FLOOR
+ LEFT_PAREN
+ timestamp=valueExpression COMMA
+ (INTERVAL unitsAmount=valueExpression unit=datetimeUnit
+ | unitsAmount=valueExpression)
+ RIGHT_PAREN #dateFloor
+ | name=DATE_CEIL
+ LEFT_PAREN
+ timestamp=valueExpression COMMA
+ (INTERVAL unitsAmount=valueExpression unit=datetimeUnit
+ | unitsAmount=valueExpression)
+ RIGHT_PAREN #dateCeil
+ | CASE whenClause+ (ELSE elseExpression=expression)? END #searchedCase
+ | CASE value=expression whenClause+ (ELSE elseExpression=expression)? END #simpleCase
+ | name=CAST LEFT_PAREN expression AS dataType RIGHT_PAREN #cast
+ | constant #constantDefault
+ | interval #intervalLiteral
+ | ASTERISK #star
+ | qualifiedName DOT ASTERISK #star
+ | CHAR LEFT_PAREN
+ arguments+=expression (COMMA arguments+=expression)*
+ (USING charSet=identifierOrText)?
+ RIGHT_PAREN #charFunction
+ | CONVERT LEFT_PAREN argument=expression USING charSet=identifierOrText RIGHT_PAREN #convertCharSet
+ | CONVERT LEFT_PAREN argument=expression COMMA type=dataType RIGHT_PAREN #convertType
+ | functionCallExpression #functionCall
+ | value=primaryExpression LEFT_BRACKET index=valueExpression RIGHT_BRACKET #elementAt
+ | value=primaryExpression LEFT_BRACKET begin=valueExpression
+ COLON (end=valueExpression)? RIGHT_BRACKET #arraySlice
+ | LEFT_PAREN query RIGHT_PAREN #subqueryExpression
+ | ATSIGN identifierOrText #userVariable
+ | DOUBLEATSIGN (kind=(GLOBAL | SESSION) DOT)? identifier #systemVariable
+ | BINARY? identifier #columnReference
+ | base=primaryExpression DOT fieldName=identifier #dereference
+ | LEFT_PAREN expression RIGHT_PAREN #parenthesizedExpression
+ | KEY (dbName=identifier DOT)? keyName=identifier #encryptKey
+ | EXTRACT LEFT_PAREN field=identifier FROM (DATE | TIMESTAMP)?
+ source=valueExpression RIGHT_PAREN #extract
+ | primaryExpression COLLATE (identifier | STRING_LITERAL | DEFAULT) #collate
+ ;
+
+functionCallExpression
+ : functionIdentifier
+ LEFT_PAREN (
+ (DISTINCT|ALL)?
+ arguments+=expression (COMMA arguments+=expression)*
+ (ORDER BY sortItem (COMMA sortItem)*)?
+ )? RIGHT_PAREN
+ (OVER windowSpec)?
+ ;
+
+functionIdentifier
+ : (dbName=identifier DOT)? functionNameIdentifier
+ ;
+
+functionNameIdentifier
+ : identifier
+ | ADD
+ | CONNECTION_ID
+ | CURRENT_CATALOG
+ | CURRENT_USER
+ | DATABASE
+ | IF
+ | LEFT
+ | LIKE
+ | PASSWORD
+ | REGEXP
+ | RIGHT
+ | SCHEMA
+ | TRIM
+ | USER
+ ;
+
+windowSpec
+ // todo: name for windowRef; we haven't support it
+ // : name=identifier
+ // | LEFT_PAREN name=identifier RIGHT_PAREN
+ : LEFT_PAREN
+ partitionClause?
+ sortClause?
+ windowFrame?
+ RIGHT_PAREN
+ ;
+
+windowFrame
+ : frameUnits start=frameBoundary
+ | frameUnits BETWEEN start=frameBoundary AND end=frameBoundary
+ ;
+
+frameUnits
+ : ROWS
+ | RANGE
+ ;
+
+frameBoundary
+ : UNBOUNDED boundType=(PRECEDING | FOLLOWING)
+ | boundType=CURRENT ROW
+ | expression boundType=(PRECEDING | FOLLOWING)
+ ;
+
+qualifiedName
+ : identifier (DOT identifier)*
+ ;
+
+specifiedPartition
+ : TEMPORARY? PARTITION (identifier | identifierList)
+ | TEMPORARY? PARTITIONS identifierList
+ ;
+
+constant
+ : NULL #nullLiteral
+ | type=(DATE | DATEV1 | DATEV2 | TIMESTAMP) STRING_LITERAL #typeConstructor
+ | number #numericLiteral
+ | booleanValue #booleanLiteral
+ | BINARY? STRING_LITERAL #stringLiteral
+ | LEFT_BRACKET (items+=constant)? (COMMA items+=constant)* RIGHT_BRACKET #arrayLiteral
+ | LEFT_BRACE (items+=constant COLON items+=constant)?
+ (COMMA items+=constant COLON items+=constant)* RIGHT_BRACE #mapLiteral
+ | LEFT_BRACE items+=constant (COMMA items+=constant)* RIGHT_BRACE #structLiteral
+ ;
+
+comparisonOperator
+ : EQ | NEQ | LT | LTE | GT | GTE | NSEQ
+ ;
+
+booleanValue
+ : TRUE | FALSE
+ ;
+
+whenClause
+ : WHEN condition=expression THEN result=expression
+ ;
+
+interval
+ : INTERVAL value=expression unit=unitIdentifier
+ ;
+
+unitIdentifier
+ : YEAR | MONTH | WEEK | DAY | HOUR | MINUTE | SECOND
+ ;
+
+dataType
+ : complex=ARRAY LT dataType GT #complexDataType
+ | complex=MAP LT dataType COMMA dataType GT #complexDataType
+ | complex=STRUCT LT complexColTypeList GT #complexDataType
+ | primitiveColType (LEFT_PAREN (INTEGER_VALUE | ASTERISK)
+ (COMMA INTEGER_VALUE)* RIGHT_PAREN)? #primitiveDataType
+ ;
+
+primitiveColType:
+ | type=TINYINT
+ | type=SMALLINT
+ | (SIGNED | UNSIGNED)? type=(INT | INTEGER)
+ | type=BIGINT
+ | type=LARGEINT
+ | type=BOOLEAN
+ | type=FLOAT
+ | type=DOUBLE
+ | type=DATE
+ | type=DATETIME
+ | type=TIME
+ | type=DATEV2
+ | type=DATETIMEV2
+ | type=DATEV1
+ | type=DATETIMEV1
+ | type=BITMAP
+ | type=QUANTILE_STATE
+ | type=HLL
+ | type=AGG_STATE
+ | type=STRING
+ | type=JSON
+ | type=JSONB
+ | type=TEXT
+ | type=VARCHAR
+ | type=CHAR
+ | type=DECIMAL
+ | type=DECIMALV2
+ | type=DECIMALV3
+ | type=IPV4
+ | type=IPV6
+ | type=ALL
+ ;
+
+complexColTypeList
+ : complexColType (COMMA complexColType)*
+ ;
+
+complexColType
+ : identifier COLON dataType commentSpec?
+ ;
+
+commentSpec
+ : COMMENT STRING_LITERAL
+ ;
+
+sample
+ : TABLESAMPLE LEFT_PAREN sampleMethod? RIGHT_PAREN (REPEATABLE seed=INTEGER_VALUE)?
+ ;
+
+sampleMethod
+ : percentage=INTEGER_VALUE PERCENT #sampleByPercentile
+ | INTEGER_VALUE ROWS #sampleByRows
+ ;
+
+// this rule is used for explicitly capturing wrong identifiers such as test-table, which should actually be `test-table`
+// replace identifier with errorCapturingIdentifier where the immediate follow symbol is not an expression, otherwise
+// valid expressions such as "a-b" can be recognized as an identifier
+errorCapturingIdentifier
+ : identifier errorCapturingIdentifierExtra
+ ;
+
+// extra left-factoring grammar
+errorCapturingIdentifierExtra
+ : (SUBTRACT identifier)+ #errorIdent
+ | #realIdent
+ ;
+
+identifier
+ : strictIdentifier
+ ;
+
+strictIdentifier
+ : IDENTIFIER #unquotedIdentifier
+ | quotedIdentifier #quotedIdentifierAlternative
+ | nonReserved #unquotedIdentifier
+ ;
+
+quotedIdentifier
+ : BACKQUOTED_IDENTIFIER
+ ;
+
+number
+ : SUBTRACT? INTEGER_VALUE #integerLiteral
+ | SUBTRACT? (EXPONENT_VALUE | DECIMAL_VALUE) #decimalLiteral
+ ;
+
+// there are 1 kinds of keywords in Doris.
+// - Non-reserved keywords:
+// normal version of non-reserved keywords.
+// The non-reserved keywords are listed in `nonReserved`.
+// TODO: need to stay consistent with the legacy
+nonReserved
+//--DEFAULT-NON-RESERVED-START
+ : ADDDATE
+ | AFTER
+ | AGG_STATE
+ | AGGREGATE
+ | ALIAS
+ | ANALYZED
+ | ARRAY
+ | AT
+ | AUTHORS
+ | AUTO_INCREMENT
+ | BACKENDS
+ | BACKUP
+ | BEGIN
+ | BIN
+ | BITAND
+ | BITMAP
+ | BITMAP_UNION
+ | BITOR
+ | BITXOR
+ | BLOB
+ | BOOLEAN
+ | BRIEF
+ | BROKER
+ | BUCKETS
+ | BUILD
+ | BUILTIN
+ | CACHED
+ | CALL
+ | CATALOG
+ | CATALOGS
+ | CHAIN
+ | CHAR
+ | CHARSET
+ | CHECK
+ | CLUSTER
+ | CLUSTERS
+ | COLLATION
+ | COLUMNS
+ | COMMENT
+ | COMMIT
+ | COMMITTED
+ | COMPACT
+ | COMPLETE
+ | CONFIG
+ | CONNECTION
+ | CONNECTION_ID
+ | CONSISTENT
+ | CONVERT
+ | COPY
+ | COUNT
+ | CREATION
+ | CRON
+ | CURRENT_CATALOG
+ | CURRENT_TIMESTAMP
+ | DATA
+ | DATE
+ | DATE_ADD
+ | DATE_CEIL
+ | DATE_DIFF
+ | DATE_FLOOR
+ | DATE_SUB
+ | DATEADD
+ | DATEDIFF
+ | DATETIME
+ | DATETIMEV2
+ | DATEV2
+ | DATETIMEV1
+ | DATEV1
+ | DAY
+ | DAYS_ADD
+ | DAYS_SUB
+ | DECIMAL
+ | DECIMALV2
+ | DECIMALV3
+ | DEFERRED
+ | DEMAND
+ | DIAGNOSE
+ | DISTINCTPC
+ | DISTINCTPCSA
+ | DO
+ | DORIS_INTERNAL_TABLE_ID
+ | DYNAMIC
+ | ENABLE
+ | ENCRYPTKEY
+ | ENCRYPTKEYS
+ | END
+ | ENDS
+ | ENGINE
+ | ENGINES
+ | ERRORS
+ | EVENTS
+ | EVERY
+ | EXCLUDE
+ | EXPIRED
+ | EXTERNAL
+ | FAILED_LOGIN_ATTEMPTS
+ | FAST
+ | FEATURE
+ | FIELDS
+ | FILE
+ | FILTER
+ | FIRST
+ | FORMAT
+ | FREE
+ | FRONTENDS
+ | FUNCTION
+ | GLOBAL
+ | GRAPH
+ | GROUPING
+ | GROUPS
+ | HASH
+ | HDFS
+ | HELP
+ | HISTOGRAM
+ | HLL_UNION
+ | HOSTNAME
+ | HOUR
+ | HUB
+ | IDENTIFIED
+ | IGNORE
+ | IMMEDIATE
+ | INCREMENTAL
+ | INDEXES
+ | INVERTED
+ | IS_NOT_NULL_PRED
+ | IS_NULL_PRED
+ | ISNULL
+ | ISOLATION
+ | JOB
+ | JOBS
+ | JSON
+ | JSONB
+ | LABEL
+ | LAST
+ | LDAP
+ | LDAP_ADMIN_PASSWORD
+ | LEFT_BRACE
+ | LESS
+ | LEVEL
+ | LINES
+ | LINK
+ | LOCAL
+ | LOCATION
+ | LOCK
+ | LOGICAL
+ | MANUAL
+ | MAP
+ | MATERIALIZED
+ | MAX
+ | MEMO
+ | MERGE
+ | MIGRATE
+ | MIGRATIONS
+ | MIN
+ | MINUTE
+ | MODIFY
+ | MONTH
+ | MTMV
+ | NAME
+ | NAMES
+ | NEGATIVE
+ | NEVER
+ | NEXT
+ | NGRAM_BF
+ | NO
+ | NON_NULLABLE
+ | NULLS
+ | OF
+ | OFFSET
+ | ONLY
+ | OPEN
+ | OPTIMIZED
+ | PARAMETER
+ | PARSED
+ | PASSWORD
+ | PASSWORD_EXPIRE
+ | PASSWORD_HISTORY
+ | PASSWORD_LOCK_TIME
+ | PASSWORD_REUSE
+ | PARTITIONS
+ | PATH
+ | PAUSE
+ | PERCENT
+ | PERIOD
+ | PERMISSIVE
+ | PHYSICAL
+ | PLAN
+ | PLUGIN
+ | PLUGINS
+ | POLICY
+ | PROC
+ | PROCESSLIST
+ | PROFILE
+ | PROPERTIES
+ | PROPERTY
+ | QUANTILE_STATE
+ | QUANTILE_UNION
+ | QUERY
+ | QUOTA
+ | RANDOM
+ | RECOVER
+ | RECYCLE
+ | REFRESH
+ | REPEATABLE
+ | REPLACE
+ | REPLACE_IF_NOT_NULL
+ | REPOSITORIES
+ | REPOSITORY
+ | RESOURCE
+ | RESOURCES
+ | RESTORE
+ | RESTRICTIVE
+ | RESUME
+ | RETURNS
+ | REWRITTEN
+ | RIGHT_BRACE
+ | RLIKE
+ | ROLLBACK
+ | ROLLUP
+ | ROUTINE
+ | S3
+ | SAMPLE
+ | SCHEDULE
+ | SCHEDULER
+ | SCHEMA
+ | SECOND
+ | SERIALIZABLE
+ | SESSION
+ | SHAPE
+ | SKEW
+ | SNAPSHOT
+ | SONAME
+ | SPLIT
+ | START
+ | STARTS
+ | STATS
+ | STATUS
+ | STOP
+ | STORAGE
+ | STREAM
+ | STREAMING
+ | STRING
+ | STRUCT
+ | SUBDATE
+ | SUM
+ | TABLES
+ | TASK
+ | TASKS
+ | TEMPORARY
+ | TEXT
+ | THAN
+ | TIME
+ | TIMESTAMP
+ | TIMESTAMPADD
+ | TIMESTAMPDIFF
+ | TRANSACTION
+ | TREE
+ | TRIGGERS
+ | TRUNCATE
+ | TYPE
+ | TYPES
+ | UNCOMMITTED
+ | UNLOCK
+ | USER
+ | VALUE
+ | VARCHAR
+ | VARIABLES
+ | VERBOSE
+ | VERSION
+ | VIEW
+ | WARNINGS
+ | WEEK
+ | WORK
+ | YEAR
+//--DEFAULT-NON-RESERVED-END
+ ;
diff --git a/fastmodel-transform/fastmodel-transform-doris/src/main/java/com/aliyun/fastmodel/transform/doris/DorisTransformer.java b/fastmodel-transform/fastmodel-transform-doris/src/main/java/com/aliyun/fastmodel/transform/doris/DorisTransformer.java
new file mode 100644
index 0000000..f7b79e1
--- /dev/null
+++ b/fastmodel-transform/fastmodel-transform-doris/src/main/java/com/aliyun/fastmodel/transform/doris/DorisTransformer.java
@@ -0,0 +1,69 @@
+package com.aliyun.fastmodel.transform.doris;
+
+import com.aliyun.fastmodel.core.tree.BaseStatement;
+import com.aliyun.fastmodel.core.tree.Node;
+import com.aliyun.fastmodel.transform.api.Transformer;
+import com.aliyun.fastmodel.transform.api.builder.BuilderFactory;
+import com.aliyun.fastmodel.transform.api.builder.StatementBuilder;
+import com.aliyun.fastmodel.transform.api.client.dto.property.BaseClientProperty;
+import com.aliyun.fastmodel.transform.api.client.dto.table.Table;
+import com.aliyun.fastmodel.transform.api.client.dto.table.TableConfig;
+import com.aliyun.fastmodel.transform.api.context.ReverseContext;
+import com.aliyun.fastmodel.transform.api.context.TransformContext;
+import com.aliyun.fastmodel.transform.api.dialect.Dialect;
+import com.aliyun.fastmodel.transform.api.dialect.DialectMeta;
+import com.aliyun.fastmodel.transform.api.dialect.DialectName;
+import com.aliyun.fastmodel.transform.api.dialect.DialectName.Constants;
+import com.aliyun.fastmodel.transform.api.dialect.DialectNode;
+import com.aliyun.fastmodel.transform.api.dialect.IVersion;
+import com.aliyun.fastmodel.transform.doris.client.DorisClientConverter;
+import com.aliyun.fastmodel.transform.doris.context.DorisContext;
+import com.aliyun.fastmodel.transform.doris.parser.DorisLanguageParser;
+import com.google.auto.service.AutoService;
+
+/**
+ * doris transformer
+ *
+ * @author panguanjing
+ * @date 2024/1/20
+ */
+@AutoService(Transformer.class)
+@Dialect(value = Constants.DORIS)
+public class DorisTransformer implements Transformer {
+
+ private final DorisLanguageParser dorisLanguageParser = new DorisLanguageParser();
+
+ private final DorisClientConverter dorisClientConverter = new DorisClientConverter();
+
+ @Override
+ public BaseStatement reverse(DialectNode dialectNode, ReverseContext context) {
+ return (BaseStatement)dorisLanguageParser.parseNode(dialectNode.getNode(), context);
+ }
+
+ @Override
+ public DialectNode transform(BaseStatement source, TransformContext context) {
+ DialectMeta dialectMeta = new DialectMeta(DialectName.DORIS, IVersion.getDefault());
+ DorisContext starRocksContext = new DorisContext(context);
+ StatementBuilder builder = BuilderFactory.getInstance().getBuilder(source, dialectMeta, starRocksContext);
+ if (builder == null) {
+ throw new UnsupportedOperationException(
+ "UnSupported statement transform with target Dialect, source: " + source.getClass());
+ }
+ return builder.build(source, starRocksContext);
+ }
+
+ @Override
+ public Node reverseTable(Table table, ReverseContext context) {
+ return dorisClientConverter.covertToNode(table, TableConfig.builder().build());
+ }
+
+ @Override
+ public Table transformTable(Node table, TransformContext context) {
+ return dorisClientConverter.convertToTable(table, new DorisContext(context));
+ }
+
+ @Override
+ public BaseClientProperty create(String name, String value) {
+ return dorisClientConverter.getPropertyConverter().create(name, value);
+ }
+}
diff --git a/fastmodel-transform/fastmodel-transform-doris/src/main/java/com/aliyun/fastmodel/transform/doris/builder/DefaultBuilder.java b/fastmodel-transform/fastmodel-transform-doris/src/main/java/com/aliyun/fastmodel/transform/doris/builder/DefaultBuilder.java
new file mode 100644
index 0000000..50a5d3f
--- /dev/null
+++ b/fastmodel-transform/fastmodel-transform-doris/src/main/java/com/aliyun/fastmodel/transform/doris/builder/DefaultBuilder.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2021. Aliyun.com All right reserved. This software is the
+ * confidential and proprietary information of Aliyun.com ("Confidential
+ * Information"). You shall not disclose such Confidential Information and shall
+ * use it only in accordance with the terms of the license agreement you entered
+ * into with Aliyun.com.
+ */
+
+package com.aliyun.fastmodel.transform.doris.builder;
+
+import com.aliyun.fastmodel.core.tree.BaseStatement;
+import com.aliyun.fastmodel.transform.api.builder.BuilderAnnotation;
+import com.aliyun.fastmodel.transform.api.builder.StatementBuilder;
+import com.aliyun.fastmodel.transform.api.dialect.DialectName.Constants;
+import com.aliyun.fastmodel.transform.api.dialect.DialectNode;
+import com.aliyun.fastmodel.transform.doris.context.DorisContext;
+import com.aliyun.fastmodel.transform.doris.format.DorisOutVisitor;
+import com.google.auto.service.AutoService;
+
+/**
+ * 默认的builder实现
+ * 支持doris的DDL输出
+ *
+ * @author panguanjing
+ */
+@BuilderAnnotation(dialect = Constants.DORIS, values = {BaseStatement.class})
+@AutoService(StatementBuilder.class)
+public class DefaultBuilder implements StatementBuilder {
+
+ @Override
+ public DialectNode build(BaseStatement source, DorisContext context) {
+ DorisOutVisitor outVisitor = new DorisOutVisitor(context);
+ Boolean process = outVisitor.process(source, 0);
+ StringBuilder builder = outVisitor.getBuilder();
+ return new DialectNode(builder.toString(), process);
+ }
+}
diff --git a/fastmodel-transform/fastmodel-transform-doris/src/main/java/com/aliyun/fastmodel/transform/doris/client/DorisClientConverter.java b/fastmodel-transform/fastmodel-transform-doris/src/main/java/com/aliyun/fastmodel/transform/doris/client/DorisClientConverter.java
new file mode 100644
index 0000000..cb0a2a5
--- /dev/null
+++ b/fastmodel-transform/fastmodel-transform-doris/src/main/java/com/aliyun/fastmodel/transform/doris/client/DorisClientConverter.java
@@ -0,0 +1,51 @@
+package com.aliyun.fastmodel.transform.doris.client;
+
+import com.aliyun.fastmodel.core.parser.LanguageParser;
+import com.aliyun.fastmodel.core.tree.Node;
+import com.aliyun.fastmodel.core.tree.datatype.IDataTypeName;
+import com.aliyun.fastmodel.transform.api.client.PropertyConverter;
+import com.aliyun.fastmodel.transform.api.extension.client.converter.ExtensionClientConverter;
+import com.aliyun.fastmodel.transform.doris.context.DorisContext;
+import com.aliyun.fastmodel.transform.doris.format.DorisOutVisitor;
+import com.aliyun.fastmodel.transform.doris.parser.DorisLanguageParser;
+import com.aliyun.fastmodel.transform.doris.parser.tree.DorisDataTypeName;
+
+/**
+ * DorisClientConverter
+ *
+ * @author panguanjing
+ * @date 2024/1/21
+ */
+public class DorisClientConverter extends ExtensionClientConverter {
+
+ private final DorisLanguageParser dorisLanguageParser;
+
+ private final DorisPropertyConverter dorisPropertyConverter;
+
+ public DorisClientConverter() {
+ dorisLanguageParser = new DorisLanguageParser();
+ dorisPropertyConverter = new DorisPropertyConverter();
+ }
+
+ @Override
+ public IDataTypeName getDataTypeName(String dataTypeName) {
+ return DorisDataTypeName.getByValue(dataTypeName);
+ }
+
+ @Override
+ public LanguageParser getLanguageParser() {
+ return this.dorisLanguageParser;
+ }
+
+ @Override
+ public String getRaw(Node node) {
+ DorisOutVisitor dorisOutVisitor = new DorisOutVisitor(DorisContext.builder().build());
+ node.accept(dorisOutVisitor, 0);
+ return dorisOutVisitor.getBuilder().toString();
+ }
+
+ @Override
+ public PropertyConverter getPropertyConverter() {
+ return dorisPropertyConverter;
+ }
+}
diff --git a/fastmodel-transform/fastmodel-transform-doris/src/main/java/com/aliyun/fastmodel/transform/doris/client/DorisPropertyConverter.java b/fastmodel-transform/fastmodel-transform-doris/src/main/java/com/aliyun/fastmodel/transform/doris/client/DorisPropertyConverter.java
new file mode 100644
index 0000000..6f5bde4
--- /dev/null
+++ b/fastmodel-transform/fastmodel-transform-doris/src/main/java/com/aliyun/fastmodel/transform/doris/client/DorisPropertyConverter.java
@@ -0,0 +1,32 @@
+package com.aliyun.fastmodel.transform.doris.client;
+
+import java.util.Map;
+import java.util.function.Function;
+
+import com.aliyun.fastmodel.transform.api.client.converter.BasePropertyConverter;
+import com.aliyun.fastmodel.transform.api.client.dto.property.BaseClientProperty;
+import com.google.common.collect.Maps;
+
+/**
+ * doris property converter
+ *
+ * @author panguanjing
+ * @date 2024/1/21
+ */
+public class DorisPropertyConverter extends BasePropertyConverter {
+
+ private static Map> functionMap = Maps.newHashMap();
+
+ public DorisPropertyConverter() {
+ init();
+ }
+
+ private void init() {
+
+ }
+
+ @Override
+ protected Map> getFunctionMap() {
+ return functionMap;
+ }
+}
diff --git a/fastmodel-transform/fastmodel-transform-doris/src/main/java/com/aliyun/fastmodel/transform/doris/context/DorisContext.java b/fastmodel-transform/fastmodel-transform-doris/src/main/java/com/aliyun/fastmodel/transform/doris/context/DorisContext.java
new file mode 100644
index 0000000..3add3fb
--- /dev/null
+++ b/fastmodel-transform/fastmodel-transform-doris/src/main/java/com/aliyun/fastmodel/transform/doris/context/DorisContext.java
@@ -0,0 +1,31 @@
+package com.aliyun.fastmodel.transform.doris.context;
+
+import com.aliyun.fastmodel.transform.api.context.TransformContext;
+
+/**
+ * doris context
+ *
+ * @author panguanjing
+ * @date 2024/1/20
+ */
+public class DorisContext extends TransformContext {
+ public DorisContext(TransformContext context) {
+ super(context);
+ }
+
+ public DorisContext(Builder tBuilder) {
+ super(tBuilder);
+ }
+
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ public static class Builder extends TransformContext.Builder