Skip to content

Commit fe53c0d

Browse files
committed
feat: release 0.5.15
1 parent 87a228c commit fe53c0d

File tree

286 files changed

+33910
-8682
lines changed

Some content is hidden

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

286 files changed

+33910
-8682
lines changed

fastmodel-bom/pom.xml

+13
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,19 @@
195195
<version>${project.version}</version>
196196
</dependency>
197197

198+
199+
<dependency>
200+
<groupId>com.aliyun.fastmodel</groupId>
201+
<artifactId>fastmodel-transform-adbpg</artifactId>
202+
<version>${project.version}</version>
203+
</dependency>
204+
205+
<dependency>
206+
<groupId>com.aliyun.fastmodel</groupId>
207+
<artifactId>fastmodel-transform-postgresql</artifactId>
208+
<version>${project.version}</version>
209+
</dependency>
210+
198211
</dependencies>
199212
</dependencyManagement>
200213
</project>

fastmodel-common/src/main/java/com/aliyun/fastmodel/common/parser/ParserHelper.java

+18
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import java.util.Objects;
1515
import java.util.Optional;
1616
import java.util.function.Function;
17+
import java.util.stream.Collectors;
1718

1819
import com.aliyun.fastmodel.common.parser.lexer.CaseChangingCharStream;
1920
import com.aliyun.fastmodel.common.utils.StripUtils;
@@ -232,4 +233,21 @@ public static <T> List<T> getListNode(ListNode node, Class<T> clazz) {
232233
}
233234
return list;
234235
}
236+
237+
public static List<String> getColumnList(List<Identifier> columnList) {
238+
if (columnList == null) {
239+
return null;
240+
}
241+
return columnList.stream()
242+
.map(Identifier::getValue)
243+
.collect(Collectors.toList());
244+
}
245+
246+
public static LongLiteral getLongLiteral(Long value) {
247+
LongLiteral partitionCount = null;
248+
if (value != null) {
249+
partitionCount = new LongLiteral(String.valueOf(value));
250+
}
251+
return partitionCount;
252+
}
235253
}

fastmodel-compare/src/test/java/com/aliyun/fastmodel/compare/table/TableIndexCompareTest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public void testTableIndex() {
5656
).build();
5757
List<BaseStatement> baseStatementList = tableIndexCompare.compareTableElement(before, after);
5858
assertEquals(1, baseStatementList.size());
59-
assertEquals(baseStatementList.get(0).toString(), "CREATE INDEX index_name ON abc (a)");
59+
assertEquals(baseStatementList.get(0).toString(), "CREATE INDEX index_name ON abc(a)");
6060
}
6161

6262
@Test
@@ -94,6 +94,6 @@ public void testTableIndexAddDrop() {
9494
List<BaseStatement> baseStatementList = tableIndexCompare.compareTableElement(before, after);
9595
assertEquals(2, baseStatementList.size());
9696
assertEquals(baseStatementList.get(0).toString(), "DROP INDEX index_name ON abc");
97-
assertEquals(baseStatementList.get(1).toString(), "CREATE INDEX index_name ON abc (b)");
97+
assertEquals(baseStatementList.get(1).toString(), "CREATE INDEX index_name ON abc(b)");
9898
}
9999
}

fastmodel-core/src/main/java/com/aliyun/fastmodel/core/formatter/ExpressionVisitor.java

+5-7
Original file line numberDiff line numberDiff line change
@@ -355,10 +355,11 @@ public String visitIntervalLiteral(IntervalLiteral node, Void context) {
355355

356356
@Override
357357
public String visitIdentifier(Identifier node, Void context) {
358-
if (!node.isDelimited()) {
359-
return node.getValue();
358+
String value = node.getValue();
359+
boolean containsSpecialChars = value.contains(":");
360+
if (!node.isDelimited() && !containsSpecialChars) {
361+
return value;
360362
} else {
361-
String value = node.getValue();
362363
//if value is start `, then
363364
if (value.startsWith(PREFIX)) {
364365
return value;
@@ -742,7 +743,4 @@ private Function<SortItem, String> sortItemFormatterFunction() {
742743
return builder.toString();
743744
};
744745
}
745-
746-
}
747-
748-
746+
}

fastmodel-core/src/main/java/com/aliyun/fastmodel/core/formatter/FastModelVisitor.java

+3-4
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ private String formatChecker(Checker checker) {
347347
formatExpression(checker.getExpression()) + formatComment(checker.getComment());
348348
}
349349

350-
private void appendProperties(StringBuilder sb, List<Property> properties) {
350+
protected void appendProperties(StringBuilder sb, List<Property> properties) {
351351
if (properties == null || properties.isEmpty()) {
352352
return;
353353
}
@@ -662,7 +662,7 @@ public Boolean visitTableIndex(TableIndex tableIndex, Integer ident) {
662662
}
663663

664664
protected void appendTableIndex(List<IndexSortKey> tableIndex) {
665-
builder.append(" (");
665+
builder.append("(");
666666
builder.append(tableIndex.stream().map(
667667
index -> {
668668
if (index instanceof IndexColumnName) {
@@ -680,10 +680,9 @@ protected void appendTableIndex(List<IndexSortKey> tableIndex) {
680680
}
681681

682682
private String formatIndexExpr(IndexExpr indexExpr) {
683-
StringBuilder stringBuilder = new StringBuilder("(");
683+
StringBuilder stringBuilder = new StringBuilder();
684684
String expression = formatExpression(indexExpr.getExpression());
685685
stringBuilder.append(expression);
686-
stringBuilder.append(")");
687686
SortType sortType = indexExpr.getSortType();
688687
if (sortType != null) {
689688
stringBuilder.append(" ").append(sortType.name());

fastmodel-core/src/main/java/com/aliyun/fastmodel/core/tree/IAstVisitor.java

+19
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
import com.aliyun.fastmodel.core.tree.expr.atom.IfExpression;
4040
import com.aliyun.fastmodel.core.tree.expr.atom.InPredicate;
4141
import com.aliyun.fastmodel.core.tree.expr.atom.IntervalExpression;
42+
import com.aliyun.fastmodel.core.tree.expr.atom.LambdaExpression;
4243
import com.aliyun.fastmodel.core.tree.expr.atom.ListExpression;
4344
import com.aliyun.fastmodel.core.tree.expr.atom.SearchedCaseExpression;
4445
import com.aliyun.fastmodel.core.tree.expr.atom.SimpleCaseExpression;
@@ -1356,7 +1357,25 @@ default R visitJsonDataType(JsonDataType jsonDataType, C context) {
13561357
return visitRowDataType(jsonDataType, context);
13571358
}
13581359

1360+
/**
1361+
* visit index expr
1362+
*
1363+
* @param indexExpr
1364+
* @param context
1365+
* @return
1366+
*/
13591367
default R visitIndexExpr(IndexExpr indexExpr, C context) {
13601368
return visitNode(indexExpr, context);
13611369
}
1370+
1371+
/**
1372+
* lambda expression
1373+
*
1374+
* @param lambdaExpression
1375+
* @param context
1376+
* @return
1377+
*/
1378+
default R visitLambdaExpression(LambdaExpression lambdaExpression, C context) {
1379+
return visitExpression(lambdaExpression, context);
1380+
}
13621381
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*
2+
* Copyright [2024] [name of copyright owner]
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.aliyun.fastmodel.core.tree.expr.atom;
18+
19+
import com.aliyun.fastmodel.core.tree.IAstVisitor;
20+
import com.aliyun.fastmodel.core.tree.NodeLocation;
21+
import com.aliyun.fastmodel.core.tree.expr.BaseExpression;
22+
import com.aliyun.fastmodel.core.tree.expr.Identifier;
23+
import lombok.EqualsAndHashCode;
24+
import lombok.Getter;
25+
26+
/**
27+
* lambda expression
28+
*
29+
* @author panguanjing
30+
* @date 2024/10/4
31+
*/
32+
@Getter
33+
@EqualsAndHashCode(callSuper = false)
34+
public class LambdaExpression extends BaseExpression {
35+
36+
private final Identifier identifier;
37+
38+
private final BaseExpression expression;
39+
40+
public LambdaExpression(NodeLocation location, Identifier identifier, BaseExpression expression) {
41+
super(location);
42+
this.identifier = identifier;
43+
this.expression = expression;
44+
}
45+
46+
@Override
47+
public <R, C> R accept(IAstVisitor<R, C> visitor, C context) {
48+
return visitor.visitLambdaExpression(this, context);
49+
}
50+
}

fastmodel-core/src/main/java/com/aliyun/fastmodel/core/tree/statement/constants/ShowObjectsType.java

+6-1
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,12 @@ public enum ShowObjectsType {
164164
/**
165165
* 物化信息
166166
*/
167-
MATERIALIZED_VIEWS("MATERIALIZED VIEWS");
167+
MATERIALIZED_VIEWS("MATERIALIZED VIEWS"),
168+
169+
/**
170+
* etl信息
171+
*/
172+
ETL("ETL");
168173

169174
/**
170175
* 对应的code信息

fastmodel-core/src/main/java/com/aliyun/fastmodel/core/tree/statement/table/index/SortType.java

+12
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
package com.aliyun.fastmodel.core.tree.statement.table.index;
1010

11+
import org.apache.commons.lang3.StringUtils;
12+
1113
/**
1214
* Sort Type
1315
*
@@ -23,4 +25,14 @@ public enum SortType {
2325
* 倒序
2426
*/
2527
DESC;
28+
29+
public static SortType fromValue(String sort) {
30+
SortType[] sortTypes = SortType.values();
31+
for (SortType sortType : sortTypes) {
32+
if (StringUtils.equalsIgnoreCase(sortType.name(), sort)) {
33+
return sortType;
34+
}
35+
}
36+
return null;
37+
}
2638
}

fastmodel-core/src/main/java/com/aliyun/fastmodel/core/tree/util/PropertyUtil.java

+30-10
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,22 @@
4545
*/
4646
public class PropertyUtil {
4747

48+
/**
49+
* to map use lower case
50+
*
51+
* @param propertyList
52+
* @return {@see Map}
53+
*/
4854
public static Map<String, String> toMap(List<Property> propertyList) {
49-
if (propertyList == null) {
50-
return Maps.newLinkedHashMap();
51-
}
52-
Map<String, String> maps = new LinkedHashMap<>(propertyList.size());
53-
for (Property property : propertyList) {
54-
maps.put(property.getName(), property.getValue());
55-
}
56-
return maps;
55+
return toMap(propertyList, false);
5756
}
5857

58+
/**
59+
* to property with map
60+
*
61+
* @param map
62+
* @return
63+
*/
5964
public static List<Property> toProperty(Map<String, String> map) {
6065
if (map == null) {
6166
return ImmutableList.of();
@@ -79,8 +84,23 @@ public static String getPropertyValue(List<Property> properties, String property
7984
if (properties == null || properties.isEmpty()) {
8085
return null;
8186
}
82-
Map<String, String> stringStringMap = toMap(properties);
83-
return stringStringMap.get(propertyKey);
87+
Map<String, String> stringStringMap = toMap(properties, true);
88+
return stringStringMap.get(propertyKey.toLowerCase());
89+
}
90+
91+
private static Map<String, String> toMap(List<Property> propertyList, boolean lowerCase) {
92+
if (propertyList == null) {
93+
return Maps.newLinkedHashMap();
94+
}
95+
Map<String, String> maps = new LinkedHashMap<>(propertyList.size());
96+
for (Property property : propertyList) {
97+
if (lowerCase) {
98+
maps.put(property.getName().toLowerCase(), property.getValue());
99+
} else {
100+
maps.put(property.getName(), property.getValue());
101+
}
102+
}
103+
return maps;
84104
}
85105

86106
/**
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
* Copyright [2024] [name of copyright owner]
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.aliyun.fastmodel.core.tree.statement.constants;
18+
19+
import org.junit.Test;
20+
21+
import static org.junit.Assert.assertEquals;
22+
23+
/**
24+
* Desc:
25+
*
26+
* @author panguanjing
27+
* @date 2024/9/25
28+
*/
29+
public class ShowObjectsTypeTest {
30+
31+
@Test
32+
public void getByCode() {
33+
ShowObjectsType showObjectsType = ShowObjectsType.getByCode("ETL");
34+
assertEquals(ShowObjectsType.ETL, showObjectsType);
35+
}
36+
}

fastmodel-dependencies-bom/pom.xml

+3-3
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
<version>${revision}</version>
2727

2828
<properties>
29-
<revision>0.5.14</revision>
29+
<revision>0.5.15</revision>
3030
<maven_flatten_version>1.1.0</maven_flatten_version>
3131
<dep.jline.version>3.17.1</dep.jline.version>
3232
<dep.antlr.version>4.13.1</dep.antlr.version>
@@ -44,7 +44,7 @@
4444
<profile>
4545
<id>jdk11</id>
4646
<properties>
47-
<revision>0.5.14</revision>
47+
<revision>0.5.15</revision>
4848
</properties>
4949
<activation>
5050
<activeByDefault>true</activeByDefault>
@@ -62,7 +62,7 @@
6262
<profile>
6363
<id>jdk8</id>
6464
<properties>
65-
<revision>0.5.14-jdk8</revision>
65+
<revision>0.5.15-jdk8</revision>
6666
</properties>
6767
<dependencyManagement>
6868
<dependencies>

0 commit comments

Comments
 (0)