Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -72,19 +72,16 @@ public static TypeInfo<?> fromTypeString(String typeString) {
LOG.debug("type string = {}.", typeString);
typeString = StringUtils.trim(StringUtils.upperCase(typeString));

if (StringUtils.startsWithIgnoreCase(typeString, Types.MAP.name())
|| StringUtils.startsWithIgnoreCase(typeString, Types.LIST.name())) {

if (StringUtils.startsWithIgnoreCase(typeString, Types.MAP.name())) {

String[] mapTypeString = parseMapTypeString(typeString);
return new MapTypeInfo<>(fromTypeString(mapTypeString[0]), fromTypeString(mapTypeString[1]));
} else {
if (StringUtils.startsWithIgnoreCase(typeString, Types.MAP.name())) {
String[] mapTypeString = parseMapTypeString(typeString);
return new MapTypeInfo<>(fromTypeString(mapTypeString[0]), fromTypeString(mapTypeString[1]));
}

String elementTypeString = parseListTypeString(typeString);
return new ListTypeInfo<>(fromTypeString(elementTypeString));
}
if (StringUtils.startsWithIgnoreCase(typeString, Types.LIST.name())) {
String elementTypeString = parseListTypeString(typeString);
return new ListTypeInfo<>(fromTypeString(elementTypeString));
}

TypeInfo<?> typeInfo = TypeInfoBridge.bridgeTypeInfo(typeString);
if (Objects.isNull(typeInfo)) {
throw BitSailException.asBitSailException(CommonErrorCode.INTERNAL_ERROR,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ protected void handleEngineTypeToCustom(Map<String, String> tmpToTypeInformation
.format("Engine type %s not support transform to custom type.", entry.getValue()));
}

toTypeInformation.put(entry.getKey(), customTypeInfo);
toTypeInformation.put(StringUtils.lowerCase(entry.getKey()), customTypeInfo);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will influence the logic in the class FileMappingTypeInfoConverter and it's subclass, plz add more test for this one.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your suggestion. I will add more tests later.

}
}

Expand All @@ -125,7 +125,7 @@ protected void handleCustomToEngineType(Map<String, String> tmpFromTypeInformati
throw new IllegalArgumentException(String.format("From Custom type %s is invalid.", entry.getKey()));
}

fromTypeInformation.put(typeInfo, entry.getValue());
fromTypeInformation.put(typeInfo, StringUtils.lowerCase(entry.getValue()));
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* Copyright 2022 Bytedance Ltd. and/or its affiliates.
*
* 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.bytedance.bitsail.common.typeinfo;

import com.bytedance.bitsail.common.model.ColumnInfo;
import com.bytedance.bitsail.common.type.filemapping.FileMappingTypeInfoConverter;

import org.junit.Assert;
import org.junit.Test;

import java.util.ArrayList;
import java.util.List;

public class TypeInfoUtilsTest {

@Test
public void testGetTypeInfos() {
FileMappingTypeInfoConverter fileMappingTypeInfoConverter = new FileMappingTypeInfoConverter("fake");

List<ColumnInfo> columnInfos = new ArrayList<>();
columnInfos.add(new ColumnInfo("id", "long"));
columnInfos.add(new ColumnInfo("name", "String"));

TypeInfo<?>[] typeInfos = TypeInfoUtils.getTypeInfos(fileMappingTypeInfoConverter, columnInfos);
Assert.assertEquals(typeInfos.length, 2);
}
}
2 changes: 1 addition & 1 deletion bitsail-common/src/test/resources/fake-type-converter.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ engine.type.to.bitsail.type.converter:
- source.type: date
target.type: date.date

- source.type: long
- source.type: Long
target.type: long

- source.type: string
Expand Down