Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[INLONG-9333][Sort] Related problem with attribute exceptions when creating 'hudiSink' #9334

Merged
merged 2 commits into from
Nov 27, 2023
Merged
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 @@ -39,6 +39,7 @@
import org.junit.jupiter.api.Test;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.concurrent.TimeUnit;

Expand Down Expand Up @@ -157,6 +158,13 @@ public HudiSink createHudiSink() {
fields.add(field3);
fields.add(field4);
sink.setSinkFieldList(fields);

List<HashMap<String, String>> extList = new ArrayList<>();
HashMap<String, String> map = new HashMap<>();
map.put("hoodie.datasource.hive_sync.partition_fields", "name");
extList.add(map);
sink.setExtList(extList);
sink.setPrimaryKey("name");
return sink;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import com.google.common.base.Preconditions;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.flink.shaded.jackson2.com.fasterxml.jackson.annotation.JsonInclude;
import org.apache.flink.shaded.jackson2.com.fasterxml.jackson.annotation.JsonInclude.Include;
Expand Down Expand Up @@ -142,15 +143,17 @@ public Map<String, String> tableOptions() {

// If the extend attributes starts with .ddl,
// it will be passed to the ddl statement of the table
extList.forEach(ext -> {
String keyName = ext.get(EXTEND_ATTR_KEY_NAME);
if (StringUtils.isNoneBlank(keyName) &&
keyName.startsWith(DDL_ATTR_PREFIX)) {
String ddlKeyName = keyName.substring(DDL_ATTR_PREFIX.length());
String ddlValue = ext.get(EXTEND_ATTR_VALUE_NAME);
options.put(ddlKeyName, ddlValue);
}
});
if (CollectionUtils.isNotEmpty(extList)) {
LiJie20190102 marked this conversation as resolved.
Show resolved Hide resolved
extList.forEach(ext -> {
String keyName = ext.get(EXTEND_ATTR_KEY_NAME);
if (StringUtils.isNoneBlank(keyName) &&
keyName.startsWith(DDL_ATTR_PREFIX)) {
String ddlKeyName = keyName.substring(DDL_ATTR_PREFIX.length());
String ddlValue = ext.get(EXTEND_ATTR_VALUE_NAME);
options.put(ddlKeyName, ddlValue);
}
});
}

String path = String.format("%s/%s.db/%s", warehouse, dbName, tableName);
options.put(HUDI_OPTION_DEFAULT_PATH, path);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.flink.shaded.jackson2.com.fasterxml.jackson.annotation.JsonCreator;
import org.apache.flink.shaded.jackson2.com.fasterxml.jackson.annotation.JsonProperty;
Expand Down Expand Up @@ -145,15 +146,17 @@ public Map<String, String> tableOptions() {

// If the extend attributes starts with .ddl,
// it will be passed to the ddl statement of the table
extList.forEach(ext -> {
String keyName = ext.get(EXTEND_ATTR_KEY_NAME);
if (StringUtils.isNoneBlank(keyName) &&
keyName.startsWith(DDL_ATTR_PREFIX)) {
String ddlKeyName = keyName.substring(DDL_ATTR_PREFIX.length());
String ddlValue = ext.get(EXTEND_ATTR_VALUE_NAME);
options.put(ddlKeyName, ddlValue);
}
});
if (CollectionUtils.isNotEmpty(extList)) {
extList.forEach(ext -> {
String keyName = ext.get(EXTEND_ATTR_KEY_NAME);
if (StringUtils.isNoneBlank(keyName) &&
keyName.startsWith(DDL_ATTR_PREFIX)) {
String ddlKeyName = keyName.substring(DDL_ATTR_PREFIX.length());
String ddlValue = ext.get(EXTEND_ATTR_VALUE_NAME);
options.put(ddlKeyName, ddlValue);
}
});
}

String path = String.format("%s/%s.db/%s", warehouse, dbName, tableName);
options.put(HUDI_OPTION_DEFAULT_PATH, path);
Expand Down