-
Notifications
You must be signed in to change notification settings - Fork 534
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[INLONG-9508][Manager] Add Iceberg field type mapping strategy to imp…
…rove usability (#9545) Co-authored-by: chestnufang <[email protected]>
- Loading branch information
1 parent
869aeb0
commit bc73361
Showing
4 changed files
with
128 additions
and
2 deletions.
There are no files selected for viewing
43 changes: 43 additions & 0 deletions
43
...in/java/org/apache/inlong/manager/common/fieldtype/strategy/IcebergFieldTypeStrategy.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
package org.apache.inlong.manager.common.fieldtype.strategy; | ||
|
||
import org.apache.inlong.manager.common.consts.DataNodeType; | ||
import org.apache.inlong.manager.common.fieldtype.FieldTypeMappingReader; | ||
|
||
import org.apache.commons.lang3.StringUtils; | ||
|
||
import static org.apache.inlong.manager.common.consts.InlongConstants.LEFT_BRACKET; | ||
|
||
/** | ||
* The iceberg field type mapping strategy | ||
*/ | ||
public class IcebergFieldTypeStrategy implements FieldTypeMappingStrategy { | ||
|
||
private final FieldTypeMappingReader reader; | ||
|
||
public IcebergFieldTypeStrategy() { | ||
this.reader = new FieldTypeMappingReader(DataNodeType.ICEBERG); | ||
} | ||
|
||
@Override | ||
public String getFieldTypeMapping(String sourceType) { | ||
String dataType = StringUtils.substringBefore(sourceType, LEFT_BRACKET).toUpperCase(); | ||
return reader.getFIELD_TYPE_MAPPING_MAP().getOrDefault(dataType, sourceType.toUpperCase()); | ||
} | ||
} |
63 changes: 63 additions & 0 deletions
63
inlong-manager/manager-common/src/main/resources/iceberg-field-type-mapping.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
# | ||
# 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. | ||
# | ||
|
||
source.type.to.target.type.converter: | ||
|
||
- source.type: INTEGER | ||
target.type: INT | ||
|
||
- source.type: FLOAT | ||
target.type: FLOAT | ||
|
||
- source.type: DOUBLE | ||
target.type: DOUBLE | ||
|
||
- source.type: LONG | ||
target.type: LONG | ||
|
||
- source.type: DECIMAL | ||
target.type: DECIMAL | ||
|
||
- source.type: BOOLEAN | ||
target.type: BOOLEAN | ||
|
||
- source.type: DATE | ||
target.type: DATE | ||
|
||
- source.type: TIME | ||
target.type: TIME | ||
|
||
- source.type: TIMESTAMP | ||
target.type: LOCAL_ZONE_TIMESTAMP | ||
|
||
- source.type: TIMESTAMP WITH TIMEZONE | ||
target.type: LOCAL_ZONE_TIMESTAMP | ||
|
||
- source.type: TIMESTAMP WITHOUT TIMEZONE | ||
target.type: TIMESTAMP | ||
|
||
- source.type: UUID | ||
target.type: STRING | ||
|
||
- source.type: STRING | ||
target.type: STRING | ||
|
||
- source.type: FIXED | ||
target.type: VARBINARY | ||
|
||
- source.type: BINARY | ||
target.type: BINARY |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters