Skip to content

Commit

Permalink
CHANGELOG 0.5.13
Browse files Browse the repository at this point in the history
  • Loading branch information
Willam2004 committed Aug 25, 2024
1 parent 8db97e9 commit 2dcd64a
Show file tree
Hide file tree
Showing 26 changed files with 497 additions and 94 deletions.
20 changes: 20 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,26 @@ Transformer
• 支持Hologres的Text字段转换
• 修复Hologres的Compare的bug

向下兼容(compatibility)
• 暂无

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

## 0.5.13
新功能(new features)
Core
• 无


Transformer
• 支持Oceanbase Mysql ZeroFill转换
• 支持Hologres的Cluster Key解析
• 修复列类型解析的bug


向下兼容(compatibility)
• 暂无

Expand Down
13 changes: 10 additions & 3 deletions fastmodel-dependencies-bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<version>${revision}</version>

<properties>
<revision>0.5.12</revision>
<revision>0.5.13</revision>
<maven_flatten_version>1.1.0</maven_flatten_version>
<dep.jline.version>3.17.1</dep.jline.version>
<dep.antlr.version>4.13.1</dep.antlr.version>
Expand All @@ -44,7 +44,7 @@
<profile>
<id>jdk11</id>
<properties>
<revision>0.5.12</revision>
<revision>0.5.13</revision>
</properties>
<activation>
<activeByDefault>true</activeByDefault>
Expand All @@ -62,7 +62,7 @@
<profile>
<id>jdk8</id>
<properties>
<revision>0.5.12-jdk8</revision>
<revision>0.5.13-jdk8</revision>
</properties>
<dependencyManagement>
<dependencies>
Expand Down Expand Up @@ -290,6 +290,13 @@
<version>4.13.1</version>
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<scope>test</scope>
</dependency>


</dependencies>
</dependencyManagement>
Expand Down
5 changes: 5 additions & 0 deletions fastmodel-transform/fastmodel-transform-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,10 @@
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

import com.aliyun.fastmodel.core.tree.BaseStatement;
import com.aliyun.fastmodel.core.tree.statement.CompositeStatement;
import com.aliyun.fastmodel.transform.api.builder.merge.exception.MergeException;

/**
* merge builder
Expand All @@ -27,8 +28,9 @@ public interface MergeBuilder {
*
* @param baseStatements
* @return
* @throws {@see MergeException}
*/
BaseStatement getMainStatement(List<BaseStatement> baseStatements);
BaseStatement getMainStatement(List<BaseStatement> baseStatements) throws MergeException;

/**
* merge statement
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Copyright [2024] [name of copyright owner]
*
* 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.
*/

package com.aliyun.fastmodel.transform.api.builder.merge.exception;

import lombok.Getter;

/**
* merge error code
*
* @author panguanjing
* @date 2024/5/1
*/
public enum MergeErrorCode {
/**
* create table not exists
*/
ERR_CREATE_TABLE_NOT_EXISTS("Error: 'CREATE TABLE' statement not exists."),
/**
* 只允许有一个create table语句
*/
ERR_TOO_MANY_CREATE_TABLES("Error: Only one 'CREATE TABLE' statement is allowed.");
@Getter
private final String message;

MergeErrorCode(String message) {
this.message = message;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Copyright [2024] [name of copyright owner]
*
* 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.
*/

package com.aliyun.fastmodel.transform.api.builder.merge.exception;

import lombok.Getter;

/**
* MergeException
*
* @author panguanjing
* @date 2024/5/1
*/
public class MergeException extends RuntimeException {

@Getter
private final MergeErrorCode mergeErrorCode;

public MergeException(MergeErrorCode mergeErrorCode) {
super(mergeErrorCode.getMessage());
this.mergeErrorCode = mergeErrorCode;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

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

import com.aliyun.fastmodel.core.tree.BaseStatement;
import com.aliyun.fastmodel.core.tree.Comment;
Expand All @@ -25,10 +26,12 @@
import com.aliyun.fastmodel.core.tree.util.PropertyUtil;
import com.aliyun.fastmodel.transform.api.builder.merge.MergeBuilder;
import com.aliyun.fastmodel.transform.api.builder.merge.MergeResult;
import com.aliyun.fastmodel.transform.api.builder.merge.exception.MergeErrorCode;
import com.aliyun.fastmodel.transform.api.builder.merge.exception.MergeException;
import com.google.common.collect.Lists;

/**
* Desc:
* CreateTableMergeBuilder
*
* @author panguanjing
* @date 2022/6/29
Expand All @@ -37,9 +40,16 @@ public class CreateTableMergeBuilder implements MergeBuilder {

@Override
public BaseStatement getMainStatement(List<BaseStatement> baseStatements) {
return baseStatements.stream().filter(
List<BaseStatement> baseStatementStream = baseStatements.stream().filter(
x -> x instanceof CreateTable
).findFirst().orElse(null);
).collect(Collectors.toList());
if (baseStatementStream.isEmpty()) {
throw new MergeException(MergeErrorCode.ERR_CREATE_TABLE_NOT_EXISTS);
}
if (baseStatementStream.size() > 1) {
throw new MergeException(MergeErrorCode.ERR_TOO_MANY_CREATE_TABLES);
}
return baseStatementStream.get(0);
}

@Override
Expand Down Expand Up @@ -187,7 +197,7 @@ private MergeResult getMergeResult(CreateTable create, SetTableComment baseOpera
}

private List<ColumnDefinition> mergeColumn(List<ColumnDefinition> sourceColumnDefinition, Identifier changeColumn,
Comment comment) {
Comment comment) {
List<ColumnDefinition> list = Lists.newArrayListWithCapacity(sourceColumnDefinition.size());
for (ColumnDefinition columnDefinition : sourceColumnDefinition) {
if (!columnDefinition.getColName().equals(changeColumn)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,12 @@ protected Boolean isExternal(CreateTable createTable) {
return false;
}

/**
* fromat expression
*
* @param baseExpression
* @return
*/
protected String formatExpression(BaseExpression baseExpression) {
return baseExpression.toString();
}
Expand Down Expand Up @@ -712,8 +718,14 @@ protected Column getColumn(ColumnDefinition c, boolean partitionKey, Integer par
column.setDataType(dataType.getOrigin());
return column;
}
if (!(dataType instanceof GenericDataType)) {return column;}
if (!(dataType instanceof GenericDataType)) {
return column;
}
GenericDataType genericDataType = (GenericDataType)dataType;
return getColumn(genericDataType, column, dimension);
}

private Column getColumn(GenericDataType genericDataType, Column column, Dimension dimension) {
List<DataTypeParameter> arguments = genericDataType.getArguments();
if (CollectionUtils.isEmpty(arguments)) {
return column;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -561,13 +561,16 @@ protected FunctionCall getFunctionCall(TimeExpressionPartitionProperty baseClien

@Override
public BaseDataType getDataType(Column column) {
ReverseContext context = ReverseContext.builder().build();
String dataTypeName = column.getDataType();
if (StringUtils.isBlank(dataTypeName)) {
throw new IllegalArgumentException("dataType name can't be null:" + column.getName());
}
IDataTypeName byValue = getDataTypeName(dataTypeName);
if (byValue == null) {
return getLanguageParser().parseDataType(dataTypeName, context);
}
Dimension dimension = byValue.getDimension();
ReverseContext context = ReverseContext.builder().build();
if (dimension == null || dimension == Dimension.ZERO) {
return getLanguageParser().parseDataType(dataTypeName, context);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* Copyright [2024] [name of copyright owner]
*
* 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.
*/

package com.aliyun.fastmodel.transform.api.builder.merge.impl;

import java.util.List;

import com.aliyun.fastmodel.core.tree.BaseStatement;
import com.aliyun.fastmodel.core.tree.QualifiedName;
import com.aliyun.fastmodel.core.tree.statement.table.CreateTable;
import com.aliyun.fastmodel.transform.api.builder.merge.exception.MergeException;
import com.google.common.collect.Lists;
import org.junit.Test;

/**
* Desc:
*
* @author panguanjing
* @date 2024/5/1
*/
public class CreateTableMergeBuilderTest {

@Test(expected = MergeException.class)
public void testGetMainStatement() {
CreateTableMergeBuilder createTableMergeBuilder = new CreateTableMergeBuilder();
List<BaseStatement> baseStatements = Lists.newArrayList(
CreateTable.builder().tableName(QualifiedName.of("t1")).build(),
CreateTable.builder().tableName(QualifiedName.of("t2")).build()
);
createTableMergeBuilder.getMainStatement(baseStatements);
}

@Test(expected = MergeException.class)
public void testGetMainStatement2() {
CreateTableMergeBuilder createTableMergeBuilder = new CreateTableMergeBuilder();
List<BaseStatement> baseStatements = Lists.newArrayList(
);
createTableMergeBuilder.getMainStatement(baseStatements);
}
}
1 change: 1 addition & 0 deletions fastmodel-transform/fastmodel-transform-hologres/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
<scope>test</scope>
</dependency>


</dependencies>

<build>
Expand Down
Loading

0 comments on commit 2dcd64a

Please sign in to comment.