Skip to content

Commit

Permalink
Setting default metadata enable as false for Java
Browse files Browse the repository at this point in the history
  • Loading branch information
nsivabalan committed Nov 15, 2021
1 parent 93fd351 commit d693cfa
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2175,7 +2175,7 @@ protected void setDefaults() {
writeConfig.setDefaultOnCondition(!isPayloadConfigSet,
HoodiePayloadConfig.newBuilder().fromProperties(writeConfig.getProps()).build());
writeConfig.setDefaultOnCondition(!isMetadataConfigSet,
HoodieMetadataConfig.newBuilder().fromProperties(writeConfig.getProps()).build());
HoodieMetadataConfig.newBuilder().withEngineType(engineType).fromProperties(writeConfig.getProps()).build());
writeConfig.setDefaultOnCondition(!isLockConfigSet,
HoodieLockConfig.newBuilder().fromProperties(writeConfig.getProps()).build());
writeConfig.setDefaultOnCondition(!isPreCommitValidationConfigSet,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import org.apache.hudi.client.HoodieJavaWriteClient;
import org.apache.hudi.client.WriteStatus;
import org.apache.hudi.common.bloom.BloomFilter;
import org.apache.hudi.common.config.HoodieMetadataConfig;
import org.apache.hudi.common.engine.EngineType;
import org.apache.hudi.common.fs.FSUtils;
import org.apache.hudi.common.model.HoodieKey;
Expand Down Expand Up @@ -115,8 +114,7 @@ private HoodieWriteConfig.Builder makeHoodieClientConfigBuilder() {
return HoodieWriteConfig.newBuilder()
.withEngineType(EngineType.JAVA)
.withPath(basePath)
.withSchema(SCHEMA.toString())
.withMetadataConfig(HoodieMetadataConfig.newBuilder().enable(false).build());
.withSchema(SCHEMA.toString());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@

package org.apache.hudi.common.config;

import org.apache.hudi.common.engine.EngineType;
import org.apache.hudi.exception.HoodieNotSupportedException;

import javax.annotation.concurrent.Immutable;

import java.io.File;
Expand Down Expand Up @@ -163,6 +166,7 @@ public boolean enableFullScan() {

public static class Builder {

private EngineType engineType = EngineType.SPARK;
private final HoodieMetadataConfig metadataConfig = new HoodieMetadataConfig();

public Builder fromFile(File propertiesFile) throws IOException {
Expand Down Expand Up @@ -233,10 +237,28 @@ public Builder enableFullScan(boolean enableFullScan) {
return this;
}

public Builder withEngineType(EngineType engineType) {
this.engineType = engineType;
return this;
}

public HoodieMetadataConfig build() {
metadataConfig.setDefaultValue(ENABLE, getDefaultMetadataEnable(engineType));
metadataConfig.setDefaults(HoodieMetadataConfig.class.getName());
return metadataConfig;
}

private boolean getDefaultMetadataEnable(EngineType engineType) {
switch (engineType) {
case SPARK:
return ENABLE.defaultValue();
case FLINK:
case JAVA:
return false;
default:
throw new HoodieNotSupportedException("Unsupported engine " + engineType);
}
}
}

/**
Expand Down

0 comments on commit d693cfa

Please sign in to comment.