YuweiXiao commented on code in PR #5771:
URL: https://github.com/apache/hudi/pull/5771#discussion_r891894308
##########
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/config/HoodieIndexConfig.java:
##########
@@ -633,13 +633,16 @@ public EngineType getEngineType() {
private void validateBucketIndexConfig() {
if
(hoodieIndexConfig.getString(INDEX_TYPE).equalsIgnoreCase(HoodieIndex.IndexType.BUCKET.toString()))
{
+ if
(!hoodieIndexConfig.contains(KeyGeneratorOptions.RECORDKEY_FIELD_NAME)) {
+ throw new HoodieIndexException(String.format("No record key field
specified. Set %s to ue bucket index.",
KeyGeneratorOptions.RECORDKEY_FIELD_NAME.key()));
Review Comment:
typo, ue -> use
##########
hudi-common/src/main/java/org/apache/hudi/keygen/constant/KeyGeneratorOptions.java:
##########
@@ -45,7 +45,7 @@ public class KeyGeneratorOptions extends HoodieConfig {
public static final ConfigProperty<String> RECORDKEY_FIELD_NAME =
ConfigProperty
.key("hoodie.datasource.write.recordkey.field")
- .defaultValue("uuid")
+ .noDefaultValue()
.withDocumentation("Record key field. Value to be used as the
`recordKey` component of `HoodieKey`.\n"
+ "Actual value will be obtained by invoking .toString() on the
field value. Nested fields can be specified using\n"
+ "the dot notation eg: `a.b.c`");
Review Comment:
Could we add the description of default behavior, e.g., no value provided
means no record key (leads to append-only hudi table)?
##########
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/keygen/ComplexAvroKeyGenerator.java:
##########
@@ -44,6 +52,9 @@ public ComplexAvroKeyGenerator(TypedProperties props) {
@Override
public String getRecordKey(GenericRecord record) {
+ if (getRecordKeyFields().isEmpty()) {
Review Comment:
Would it be better to move the empty check into KeyGenUtils, in order to
avoid duplicate code in different KeyGenerators?
##########
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/keygen/ComplexAvroKeyGenerator.java:
##########
@@ -32,10 +36,14 @@ public class ComplexAvroKeyGenerator extends
BaseKeyGenerator {
public ComplexAvroKeyGenerator(TypedProperties props) {
super(props);
- this.recordKeyFields =
Arrays.stream(props.getString(KeyGeneratorOptions.RECORDKEY_FIELD_NAME.key()).split(","))
- .map(String::trim)
- .filter(s -> !s.isEmpty())
- .collect(Collectors.toList());
+ if (props.containsKey(KeyGeneratorOptions.RECORDKEY_FIELD_NAME.key())) {
Review Comment:
We could use `props.getString(key, default)` interface to avoid the extra if
condition.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]