You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hudi.apache.org by yi...@apache.org on 2025/11/10 18:13:42 UTC
(hudi) 05/16: fix: Fixing record index related configs and enums (#14180)
This is an automated email from the ASF dual-hosted git repository.
yihua pushed a commit to branch release-1.1.0
in repository https://gitbox.apache.org/repos/asf/hudi.git
commit 1e7bc3ee8f973af422b7c162e7a2dd39ec2b2efb
Author: Sivabalan Narayanan <n....@gmail.com>
AuthorDate: Wed Nov 5 09:02:36 2025 -0800
fix: Fixing record index related configs and enums (#14180)
* Fixing record index related configs and enums
* Fixing compilation after rebase
* Addressing feedback from Ethan
* fixing compilation error
---
.../org/apache/hudi/config/HoodieIndexConfig.java | 5 +-
.../org/apache/hudi/config/HoodieWriteConfig.java | 12 +-
.../java/org/apache/hudi/index/HoodieIndex.java | 15 +-
.../org/apache/hudi/index/HoodieIndexUtils.java | 7 +-
.../metadata/HoodieBackedTableMetadataWriter.java | 18 +-
.../apache/hudi/metadata/RecordIndexMapper.java | 2 +-
.../java/org/apache/hudi/table/HoodieTable.java | 2 +-
.../apache/hudi/index/TestHoodieIndexUtils.java | 6 +-
.../hudi/client/TestJavaHoodieBackedMetadata.java | 4 +-
.../apache/hudi/index/HoodieSparkIndexClient.java | 8 +-
.../apache/hudi/index/SparkHoodieIndexFactory.java | 10 +-
... SparkMetadataTableGlobalRecordLevelIndex.java} | 8 +-
...ava => SparkMetadataTableRecordLevelIndex.java} | 6 +-
.../client/TestSparkRDDMetadataWriteClient.java | 2 +-
.../apache/hudi/index/TestHoodieIndexConfigs.java | 2 +-
.../table/upgrade/TestUpgradeDowngradeLegacy.java | 2 +-
.../hudi/common/config/HoodieMetadataConfig.java | 23 +-
.../hudi/metadata/HoodieTableMetadataUtil.java | 8 +-
.../hudi/metadata/MetadataPartitionType.java | 2 +-
.../common/config/TestHoodieMetadataConfig.java | 24 +
.../hudi/metadata/TestMetadataPartitionType.java | 6 +-
.../org/apache/hudi/TestMetadataTableSupport.java | 2 +-
.../hudi/client/TestHoodieClientMultiWriter.java | 2 +-
.../TestMetadataUtilRLIandSIRecordGeneration.java | 4 +-
.../TestGlobalIndexEnableUpdatePartitions.java | 2 +-
.../hudi/functional/TestHoodieBackedMetadata.java | 14 +-
.../apache/hudi/functional/TestHoodieIndex.java | 2 +-
.../java/org/apache/hudi/io/TestAppendHandle.java | 2 +-
.../java/org/apache/hudi/io/TestCreateHandle.java | 2 +-
.../java/org/apache/hudi/io/TestMergeHandle.java | 2 +-
.../apache/hudi/io/TestMetadataWriterCommit.java | 4 +-
.../hudi/table/upgrade/TestUpgradeDowngrade.java | 4 +-
.../org/apache/hudi/TestInsertDedupPolicy.scala | 2 +-
.../hudi/functional/RecordLevelIndexTestBase.scala | 2 +-
...ndex.scala => TestGlobalRecordLevelIndex.scala} | 51 +-
...estGlobalRecordLevelIndexTableVersionSix.scala} | 2 +-
...ala => TestGlobalRecordLevelIndexWithSQL.scala} | 4 +-
.../apache/hudi/functional/TestMORDataSource.scala | 4 +-
.../hudi/functional/TestMetadataRecordIndex.scala | 2 +-
.../hudi/functional/TestPartitionStatsIndex.scala | 2 +-
.../TestPartitionedRecordLevelIndex.scala | 494 ---------
.../hudi/functional/TestRecordLevelIndex.scala | 1044 ++++++++------------
.../functional/TestSecondaryIndexPruning.scala | 2 +-
.../hudi/functional/TestSevenToEightUpgrade.scala | 2 +-
.../hudi/feature/index/TestSecondaryIndex.scala | 2 +-
.../org/apache/hudi/utilities/HoodieIndexer.java | 4 +-
.../utilities/HoodieMetadataTableValidator.java | 2 +-
.../apache/hudi/utilities/TestHoodieIndexer.java | 2 +-
.../TestHoodieMetadataTableValidator.java | 16 +-
.../deltastreamer/TestHoodieDeltaStreamer.java | 6 +-
50 files changed, 586 insertions(+), 1269 deletions(-)
diff --git a/hudi-client/hudi-client-common/src/main/java/org/apache/hudi/config/HoodieIndexConfig.java b/hudi-client/hudi-client-common/src/main/java/org/apache/hudi/config/HoodieIndexConfig.java
index a18cda1ce6b8..5d718fe100cc 100644
--- a/hudi-client/hudi-client-common/src/main/java/org/apache/hudi/config/HoodieIndexConfig.java
+++ b/hudi-client/hudi-client-common/src/main/java/org/apache/hudi/config/HoodieIndexConfig.java
@@ -51,10 +51,11 @@ import static org.apache.hudi.index.HoodieIndex.IndexType.BLOOM;
import static org.apache.hudi.index.HoodieIndex.IndexType.BUCKET;
import static org.apache.hudi.index.HoodieIndex.IndexType.FLINK_STATE;
import static org.apache.hudi.index.HoodieIndex.IndexType.GLOBAL_BLOOM;
+import static org.apache.hudi.index.HoodieIndex.IndexType.GLOBAL_RECORD_LEVEL_INDEX;
import static org.apache.hudi.index.HoodieIndex.IndexType.GLOBAL_SIMPLE;
import static org.apache.hudi.index.HoodieIndex.IndexType.INMEMORY;
import static org.apache.hudi.index.HoodieIndex.IndexType.RECORD_INDEX;
-import static org.apache.hudi.index.HoodieIndex.IndexType.PARTITIONED_RECORD_INDEX;
+import static org.apache.hudi.index.HoodieIndex.IndexType.RECORD_LEVEL_INDEX;
import static org.apache.hudi.index.HoodieIndex.IndexType.SIMPLE;
/**
@@ -75,7 +76,7 @@ public class HoodieIndexConfig extends HoodieConfig {
// Builder#getDefaultIndexType has already set it according to engine type
.noDefaultValue()
.withValidValues(INMEMORY.name(), BLOOM.name(), GLOBAL_BLOOM.name(), SIMPLE.name(), GLOBAL_SIMPLE.name(),
- BUCKET.name(), FLINK_STATE.name(), RECORD_INDEX.name(), PARTITIONED_RECORD_INDEX.name())
+ BUCKET.name(), FLINK_STATE.name(), RECORD_INDEX.name(), RECORD_LEVEL_INDEX.name(), GLOBAL_RECORD_LEVEL_INDEX.name())
.withDocumentation(HoodieIndex.IndexType.class);
diff --git a/hudi-client/hudi-client-common/src/main/java/org/apache/hudi/config/HoodieWriteConfig.java b/hudi-client/hudi-client-common/src/main/java/org/apache/hudi/config/HoodieWriteConfig.java
index c1ba48226bcb..f53b7d2d3b3b 100644
--- a/hudi-client/hudi-client-common/src/main/java/org/apache/hudi/config/HoodieWriteConfig.java
+++ b/hudi-client/hudi-client-common/src/main/java/org/apache/hudi/config/HoodieWriteConfig.java
@@ -2138,21 +2138,21 @@ public class HoodieWriteConfig extends HoodieConfig {
}
/**
- * Determines if the record index is enabled.
+ * Determines if the global record index is enabled.
*
- * <p>The record index is enabled if the record index is enabled in the metadata configuration.
+ * <p>The global record index is enabled if the record index is enabled in the metadata configuration.
*
* <p>IMPORTANT: Make sure the logic is consistent with {@code MetadataPartitionType.isMetadataPartitionEnabled}
* which is the only truth that defines whether the index is enabled(through table config {@link HoodieTableConfig#TABLE_METADATA_PARTITIONS}).
*
* @return {@code true} if the record index is enabled, {@code false} otherwise.
*/
- public boolean isRecordIndexEnabled() {
- return metadataConfig.isRecordIndexEnabled();
+ public boolean isGlobalRecordLevelIndexEnabled() {
+ return metadataConfig.isGlobalRecordLevelIndexEnabled();
}
- public boolean isPartitionedRecordIndexEnabled() {
- return metadataConfig.isPartitionedRecordIndexEnabled();
+ public boolean isRecordLevelIndexEnabled() {
+ return metadataConfig.isRecordLevelIndexEnabled();
}
public int getPartitionStatsIndexParallelism() {
diff --git a/hudi-client/hudi-client-common/src/main/java/org/apache/hudi/index/HoodieIndex.java b/hudi-client/hudi-client-common/src/main/java/org/apache/hudi/index/HoodieIndex.java
index 0eebc1f40f61..6808dfe99f45 100644
--- a/hudi-client/hudi-client-common/src/main/java/org/apache/hudi/index/HoodieIndex.java
+++ b/hudi-client/hudi-client-common/src/main/java/org/apache/hudi/index/HoodieIndex.java
@@ -191,19 +191,28 @@ public abstract class HoodieIndex<I, O> implements Serializable {
@EnumFieldDescription("Internal Config for indexing based on Flink state.")
FLINK_STATE,
+ @Deprecated
@EnumFieldDescription("Index which saves the record key to location mappings in the "
+ "HUDI Metadata Table. Record index is a global index, enforcing key uniqueness across all "
+ "partitions in the table. Supports sharding to achieve very high scale. For a table with "
- + "keys that are only unique inside each partition, use `PARTITIONED_RECORD_INDEX` instead.")
+ + "keys that are only unique inside each partition, use `RECORD_LEVEL_INDEX` instead. "
+ + "This enum is deprecated. Use GLOBAL_RECORD_LEVEL_INDEX for global uniqueness of record "
+ + "keys or RECORD_LEVEL_INDEX for partition-level uniqueness of record keys.")
RECORD_INDEX,
+ @EnumFieldDescription("Index which saves the record key to location mappings in the "
+ + "HUDI Metadata Table. Record index is a global index, enforcing key uniqueness across all "
+ + "partitions in the table. Supports sharding to achieve very high scale. For a table with "
+ + "keys that are only unique inside each partition, use `RECORD_LEVEL_INDEX` instead.")
+ GLOBAL_RECORD_LEVEL_INDEX,
+
@EnumFieldDescription("Index which saves the record key to location mappings in the "
+ "HUDI Metadata Table. Supports sharding to achieve very high scale. This is a "
+ "non global index, where keys can be replicated across partitions, since a "
+ "pair of partition path and record keys will uniquely map to a location using "
+ "this index. If users expect record keys to be unique across all partitions, "
- + "use `RECORD_INDEX` instead.")
- PARTITIONED_RECORD_INDEX
+ + "use `GLOBAL_RECORD_LEVEL_INDEX` instead.")
+ RECORD_LEVEL_INDEX
}
@EnumDescription("Determines the type of bucketing or hashing to use when `hoodie.index.type`"
diff --git a/hudi-client/hudi-client-common/src/main/java/org/apache/hudi/index/HoodieIndexUtils.java b/hudi-client/hudi-client-common/src/main/java/org/apache/hudi/index/HoodieIndexUtils.java
index 63844a78b20f..c25e0c692d42 100644
--- a/hudi-client/hudi-client-common/src/main/java/org/apache/hudi/index/HoodieIndexUtils.java
+++ b/hudi-client/hudi-client-common/src/main/java/org/apache/hudi/index/HoodieIndexUtils.java
@@ -93,7 +93,7 @@ import java.util.stream.Collectors;
import static java.util.stream.Collectors.toList;
import static org.apache.hudi.avro.HoodieAvroUtils.getNestedFieldSchemaFromWriteSchema;
-import static org.apache.hudi.common.config.HoodieMetadataConfig.RECORD_INDEX_ENABLE_PROP;
+import static org.apache.hudi.common.config.HoodieMetadataConfig.GLOBAL_RECORD_LEVEL_INDEX_ENABLE_PROP;
import static org.apache.hudi.common.util.ConfigUtils.DEFAULT_HUDI_CONFIG_FOR_READER;
import static org.apache.hudi.common.util.HoodieRecordUtils.getOrderingFieldNames;
import static org.apache.hudi.common.util.ValidationUtils.checkArgument;
@@ -771,14 +771,15 @@ public class HoodieIndexUtils {
boolean hasRecordIndex = metaClient.getTableConfig().getMetadataPartitions().stream()
.anyMatch(partition -> partition.equals(MetadataPartitionType.RECORD_INDEX.getPartitionPath()));
boolean recordIndexEnabled = Boolean.parseBoolean(
- options.getOrDefault(RECORD_INDEX_ENABLE_PROP.key(), RECORD_INDEX_ENABLE_PROP.defaultValue().toString()));
+ options.getOrDefault(GLOBAL_RECORD_LEVEL_INDEX_ENABLE_PROP.key(), options.getOrDefault("hoodie.metadata.record.index.enable",
+ GLOBAL_RECORD_LEVEL_INDEX_ENABLE_PROP.defaultValue().toString())));
if (!hasRecordIndex && !recordIndexEnabled) {
throw new HoodieMetadataIndexException(String.format(
"Cannot create secondary index '%s': Record index is required for secondary indexes but is not enabled. "
+ "Please enable the record index by setting '%s' to 'true' in the index creation options, "
+ "or create a record index first using: CREATE INDEX record_index ON %s USING record_index",
- userIndexName, RECORD_INDEX_ENABLE_PROP.key(), metaClient.getTableConfig().getTableName()));
+ userIndexName, GLOBAL_RECORD_LEVEL_INDEX_ENABLE_PROP.key(), metaClient.getTableConfig().getTableName()));
}
}
}
diff --git a/hudi-client/hudi-client-common/src/main/java/org/apache/hudi/metadata/HoodieBackedTableMetadataWriter.java b/hudi-client/hudi-client-common/src/main/java/org/apache/hudi/metadata/HoodieBackedTableMetadataWriter.java
index 20f9d1f6601a..1a4cab3bb185 100644
--- a/hudi-client/hudi-client-common/src/main/java/org/apache/hudi/metadata/HoodieBackedTableMetadataWriter.java
+++ b/hudi-client/hudi-client-common/src/main/java/org/apache/hudi/metadata/HoodieBackedTableMetadataWriter.java
@@ -471,7 +471,7 @@ public abstract class HoodieBackedTableMetadataWriter<I, O> implements HoodieTab
initializeFilegroupsAndCommit(partitionType, COLUMN_STATS.getPartitionPath(), fileGroupCountAndRecordsPair, instantTimeForPartition, colStatsColumnsAndRecord.getKey());
break;
case RECORD_INDEX:
- boolean isPartitionedRLI = dataWriteConfig.isPartitionedRecordIndexEnabled();
+ boolean isPartitionedRLI = dataWriteConfig.isRecordLevelIndexEnabled();
initializeFilegroupsAndCommitToRecordIndexPartition(instantTimeForPartition, lazyLatestMergedPartitionFileSliceList, isPartitionedRLI);
break;
case EXPRESSION_INDEX:
@@ -808,7 +808,7 @@ public abstract class HoodieBackedTableMetadataWriter<I, O> implements HoodieTab
private int estimateFileGroupCount(long recordCount) {
int minFileGroupCount;
int maxFileGroupCount;
- if (dataWriteConfig.isPartitionedRecordIndexEnabled()) {
+ if (dataWriteConfig.isRecordLevelIndexEnabled()) {
minFileGroupCount = dataWriteConfig.getPartitionedRecordIndexMinFileGroupCount();
maxFileGroupCount = dataWriteConfig.getPartitionedRecordIndexMaxFileGroupCount();
} else {
@@ -1400,14 +1400,14 @@ public abstract class HoodieBackedTableMetadataWriter<I, O> implements HoodieTab
* @param instantTime Timestamp for the mdt commit
*/
private void maybeInitializeNewFileGroupsForPartitionedRLI(HoodieCommitMetadata commitMetadata, String instantTime) {
- if (dataWriteConfig.isPartitionedRecordIndexEnabled()) {
+ if (dataWriteConfig.isRecordLevelIndexEnabled()) {
Set<String> partitionsTouchedByInflightCommit = new HashSet<>(commitMetadata.getPartitionToWriteStats().keySet());
initializeNewFileGroupsForPartitionedRLIHelper(partitionsTouchedByInflightCommit, instantTime);
}
}
private void maybeInitializeNewFileGroupsForPartitionedRLI(HoodieData<WriteStatus> writeStatus, String instantTime) {
- if (dataWriteConfig.isPartitionedRecordIndexEnabled()) {
+ if (dataWriteConfig.isRecordLevelIndexEnabled()) {
Set<String> partitionsTouchedByInflightCommit = new HashSet<>(writeStatus.map(WriteStatus::getPartitionPath).collectAsList());
initializeNewFileGroupsForPartitionedRLIHelper(partitionsTouchedByInflightCommit, instantTime);
}
@@ -1875,13 +1875,13 @@ public abstract class HoodieBackedTableMetadataWriter<I, O> implements HoodieTab
for (Map.Entry<String, HoodieData<HoodieRecord>> entry : partitionRecordsMap.entrySet()) {
final String partitionPath = entry.getKey();
HoodieData<HoodieRecord> records = entry.getValue();
- boolean isPartitionedRLI = Objects.equals(partitionPath, RECORD_INDEX.getPartitionPath()) && dataWriteConfig.isPartitionedRecordIndexEnabled();
+ boolean isNonGlobalRLI = Objects.equals(partitionPath, RECORD_INDEX.getPartitionPath()) && dataWriteConfig.isRecordLevelIndexEnabled();
List<FileSlice> fileSlices =
HoodieTableMetadataUtil.getPartitionLatestFileSlices(metadataMetaClient, Option.ofNullable(fsView), partitionPath);
// scheduling of INDEX only initializes the file group and not add commit
// so if there are no committed file slices, look for inflight slices
- if (isPartitionedRLI) {
- // For isPartitionedRLI, new partitions added to the data table will cause new filegroups that are not yet commited
+ if (isNonGlobalRLI) {
+ // For isNonGlobalRLI, new partitions added to the data table will cause new filegroups that are not yet commited
// therefore, we always need to look for inflight filegroups
fileSlices = getPartitionLatestFileSlicesIncludingInflight(metadataMetaClient, Option.ofNullable(fsView), partitionPath);
} else if (fileSlices.isEmpty()) {
@@ -1902,7 +1902,7 @@ public abstract class HoodieBackedTableMetadataWriter<I, O> implements HoodieTab
MetadataPartitionType partitionType = MetadataPartitionType.fromPartitionPath(partitionPath);
// Determine key format once per partition to avoid repeated checks
SerializableBiFunction<String, Integer, Integer> mappingFunction = partitionType.getFileGroupMappingFunction(indexVersion);
- if (partitionType == RECORD_INDEX && dataWriteConfig.isPartitionedRecordIndexEnabled()) {
+ if (partitionType == RECORD_INDEX && dataWriteConfig.isRecordLevelIndexEnabled()) {
return getRecordTaggerPartitionedRLI(fileSlices, mappingFunction);
}
final int fileGroupCount = fileSlices.size();
@@ -2164,7 +2164,7 @@ public abstract class HoodieBackedTableMetadataWriter<I, O> implements HoodieTab
dataMetaClient.getBasePath(),
storageConf,
this.getClass().getSimpleName(),
- dataWriteConfig.isPartitionedRecordIndexEnabled());
+ dataWriteConfig.isRecordLevelIndexEnabled());
}
private HoodieData<HoodieRecord> getRecordIndexAdditionalUpserts(HoodieData<HoodieRecord> updatesFromWriteStatuses, HoodieCommitMetadata commitMetadata) {
diff --git a/hudi-client/hudi-client-common/src/main/java/org/apache/hudi/metadata/RecordIndexMapper.java b/hudi-client/hudi-client-common/src/main/java/org/apache/hudi/metadata/RecordIndexMapper.java
index 13029bca3df9..1ccea5522fd0 100644
--- a/hudi-client/hudi-client-common/src/main/java/org/apache/hudi/metadata/RecordIndexMapper.java
+++ b/hudi-client/hudi-client-common/src/main/java/org/apache/hudi/metadata/RecordIndexMapper.java
@@ -74,7 +74,7 @@ public class RecordIndexMapper extends MetadataIndexMapper {
}
} else {
// Delete existing index for a deleted record
- hoodieRecord = HoodieMetadataPayload.createRecordIndexDelete(recordDelegate.getRecordKey(), recordDelegate.getPartitionPath(), dataWriteConfig.isPartitionedRecordIndexEnabled());
+ hoodieRecord = HoodieMetadataPayload.createRecordIndexDelete(recordDelegate.getRecordKey(), recordDelegate.getPartitionPath(), dataWriteConfig.isRecordLevelIndexEnabled());
allRecords.add(hoodieRecord);
}
}
diff --git a/hudi-client/hudi-client-common/src/main/java/org/apache/hudi/table/HoodieTable.java b/hudi-client/hudi-client-common/src/main/java/org/apache/hudi/table/HoodieTable.java
index 4ae51ac75298..bf4fca36fc45 100644
--- a/hudi-client/hudi-client-common/src/main/java/org/apache/hudi/table/HoodieTable.java
+++ b/hudi-client/hudi-client-common/src/main/java/org/apache/hudi/table/HoodieTable.java
@@ -1196,7 +1196,7 @@ public abstract class HoodieTable<T, I, K, O> implements Serializable {
metadataIndexDisabled = !config.isMetadataBloomFilterIndexEnabled();
break;
case RECORD_INDEX:
- metadataIndexDisabled = !config.isRecordIndexEnabled() && !config.isPartitionedRecordIndexEnabled();
+ metadataIndexDisabled = !config.isGlobalRecordLevelIndexEnabled() && !config.isRecordLevelIndexEnabled();
break;
// PARTITION_STATS should have same behavior as COLUMN_STATS
case PARTITION_STATS:
diff --git a/hudi-client/hudi-client-common/src/test/java/org/apache/hudi/index/TestHoodieIndexUtils.java b/hudi-client/hudi-client-common/src/test/java/org/apache/hudi/index/TestHoodieIndexUtils.java
index 51096a8f3453..656203d8a905 100644
--- a/hudi-client/hudi-client-common/src/test/java/org/apache/hudi/index/TestHoodieIndexUtils.java
+++ b/hudi-client/hudi-client-common/src/test/java/org/apache/hudi/index/TestHoodieIndexUtils.java
@@ -41,7 +41,7 @@ import java.util.HashSet;
import java.util.Map;
import java.util.Set;
-import static org.apache.hudi.common.config.HoodieMetadataConfig.RECORD_INDEX_ENABLE_PROP;
+import static org.apache.hudi.common.config.HoodieMetadataConfig.GLOBAL_RECORD_LEVEL_INDEX_ENABLE_PROP;
import static org.apache.hudi.index.HoodieIndexUtils.validateDataTypeForSecondaryIndex;
import static org.apache.hudi.index.HoodieIndexUtils.validateDataTypeForSecondaryOrExpressionIndex;
import static org.apache.hudi.metadata.HoodieTableMetadataUtil.PARTITION_NAME_SECONDARY_INDEX;
@@ -112,7 +112,7 @@ public class TestHoodieIndexUtils {
// Test case 2: Secondary index with record index enabled in options
// Given: No record index partition but enabled in options
when(mockTableConfig.getMetadataPartitions()).thenReturn(Collections.emptySet());
- options.put(RECORD_INDEX_ENABLE_PROP.key(), "true");
+ options.put(GLOBAL_RECORD_LEVEL_INDEX_ENABLE_PROP.key(), "true");
// When: Checking eligibility for secondary index
// Then: Should not throw exception because data type is supported and record index is enabled
@@ -449,7 +449,7 @@ public class TestHoodieIndexUtils {
// Test case 2: Record index explicitly disabled
// Given: Record index is explicitly disabled in options
- options.put(RECORD_INDEX_ENABLE_PROP.key(), "false");
+ options.put(GLOBAL_RECORD_LEVEL_INDEX_ENABLE_PROP.key(), "false");
// When: Checking eligibility for secondary index
// Then: Should throw exception because record index is disabled
diff --git a/hudi-client/hudi-java-client/src/test/java/org/apache/hudi/client/TestJavaHoodieBackedMetadata.java b/hudi-client/hudi-java-client/src/test/java/org/apache/hudi/client/TestJavaHoodieBackedMetadata.java
index f263ab7a7827..d439189a0a63 100644
--- a/hudi-client/hudi-java-client/src/test/java/org/apache/hudi/client/TestJavaHoodieBackedMetadata.java
+++ b/hudi-client/hudi-java-client/src/test/java/org/apache/hudi/client/TestJavaHoodieBackedMetadata.java
@@ -1226,7 +1226,7 @@ public class TestJavaHoodieBackedMetadata extends TestHoodieMetadataBase {
HoodieWriteConfig writeConfig = getWriteConfigBuilder(true, true, false)
.withMetadataConfig(HoodieMetadataConfig.newBuilder()
.enable(true)
- .withEnableRecordIndex(true)
+ .withEnableGlobalRecordLevelIndex(true)
.withRecordIndexFileGroupCount(5, 5)
.build())
.build();
@@ -1271,7 +1271,7 @@ public class TestJavaHoodieBackedMetadata extends TestHoodieMetadataBase {
writeConfig = getWriteConfigBuilder(true, true, false)
.withMetadataConfig(HoodieMetadataConfig.newBuilder()
.enable(true)
- .withEnableRecordIndex(true)
+ .withEnableGlobalRecordLevelIndex(true)
.withRecordIndexFileGroupCount(3, 3)
.build())
.build();
diff --git a/hudi-client/hudi-spark-client/src/main/java/org/apache/hudi/index/HoodieSparkIndexClient.java b/hudi-client/hudi-spark-client/src/main/java/org/apache/hudi/index/HoodieSparkIndexClient.java
index c2c0854f1233..e1f164fba241 100644
--- a/hudi-client/hudi-spark-client/src/main/java/org/apache/hudi/index/HoodieSparkIndexClient.java
+++ b/hudi-client/hudi-spark-client/src/main/java/org/apache/hudi/index/HoodieSparkIndexClient.java
@@ -59,7 +59,7 @@ import scala.collection.JavaConverters;
import static org.apache.hudi.common.config.HoodieMetadataConfig.ENABLE_METADATA_INDEX_BLOOM_FILTER;
import static org.apache.hudi.common.config.HoodieMetadataConfig.ENABLE_METADATA_INDEX_COLUMN_STATS;
-import static org.apache.hudi.common.config.HoodieMetadataConfig.RECORD_INDEX_ENABLE_PROP;
+import static org.apache.hudi.common.config.HoodieMetadataConfig.GLOBAL_RECORD_LEVEL_INDEX_ENABLE_PROP;
import static org.apache.hudi.index.HoodieIndexUtils.indexExists;
import static org.apache.hudi.index.HoodieIndexUtils.register;
import static org.apache.hudi.metadata.HoodieTableMetadataUtil.PARTITION_NAME_BLOOM_FILTERS;
@@ -114,7 +114,7 @@ public class HoodieSparkIndexClient extends BaseHoodieIndexClient {
Map<String, String> overrideOpts = Collections.emptyMap();
if (HoodieRecordIndex.isPartitioned(options)) {
- overrideOpts = Collections.singletonMap(HoodieMetadataConfig.PARTITIONED_RECORD_INDEX_ENABLE_PROP.key(), "true");
+ overrideOpts = Collections.singletonMap(HoodieMetadataConfig.RECORD_LEVEL_INDEX_ENABLE_PROP.key(), "true");
}
HoodieIndexVersion version = HoodieIndexVersion.getCurrentVersion(metaClient.getTableConfig().getTableVersion(), MetadataPartitionType.RECORD_INDEX);
LOG.info("Creating index {} using version {}", fullIndexName, version);
@@ -266,7 +266,7 @@ public class HoodieSparkIndexClient extends BaseHoodieIndexClient {
// [HUDI-7472] Ensure write-config contains the existing MDT partition to prevent those from getting deleted
metaClient.getTableConfig().getMetadataPartitions().forEach(partitionPath -> {
if (partitionPath.equals(MetadataPartitionType.RECORD_INDEX.getPartitionPath())) {
- writeConfig.put(RECORD_INDEX_ENABLE_PROP.key(), "true");
+ writeConfig.put(GLOBAL_RECORD_LEVEL_INDEX_ENABLE_PROP.key(), "true");
}
if (partitionPath.equals(MetadataPartitionType.BLOOM_FILTERS.getPartitionPath())) {
@@ -281,7 +281,7 @@ public class HoodieSparkIndexClient extends BaseHoodieIndexClient {
if (indexTypeOpt.isPresent()) {
String indexType = indexTypeOpt.get();
if (indexType.equals(PARTITION_NAME_RECORD_INDEX)) {
- writeConfig.put(RECORD_INDEX_ENABLE_PROP.key(), "true");
+ writeConfig.put(GLOBAL_RECORD_LEVEL_INDEX_ENABLE_PROP.key(), "true");
}
}
}
diff --git a/hudi-client/hudi-spark-client/src/main/java/org/apache/hudi/index/SparkHoodieIndexFactory.java b/hudi-client/hudi-spark-client/src/main/java/org/apache/hudi/index/SparkHoodieIndexFactory.java
index 3ceb06767930..ae608bc30b68 100644
--- a/hudi-client/hudi-spark-client/src/main/java/org/apache/hudi/index/SparkHoodieIndexFactory.java
+++ b/hudi-client/hudi-spark-client/src/main/java/org/apache/hudi/index/SparkHoodieIndexFactory.java
@@ -66,9 +66,10 @@ public final class SparkHoodieIndexFactory {
throw new HoodieIndexException("Unknown bucket index engine type: " + config.getBucketIndexEngineType());
}
case RECORD_INDEX:
- return new SparkMetadataTableRecordIndex(config);
- case PARTITIONED_RECORD_INDEX:
- return new SparkMetadataTablePartitionedRecordIndex(config);
+ case GLOBAL_RECORD_LEVEL_INDEX:
+ return new SparkMetadataTableGlobalRecordLevelIndex(config);
+ case RECORD_LEVEL_INDEX:
+ return new SparkMetadataTableRecordLevelIndex(config);
default:
throw new HoodieIndexException("Index type unspecified, set " + config.getIndexType());
}
@@ -94,8 +95,9 @@ public final class SparkHoodieIndexFactory {
case BUCKET:
return false;
case RECORD_INDEX:
+ case GLOBAL_RECORD_LEVEL_INDEX:
return true;
- case PARTITIONED_RECORD_INDEX:
+ case RECORD_LEVEL_INDEX:
return false;
default:
return createIndex(config).isGlobal();
diff --git a/hudi-client/hudi-spark-client/src/main/java/org/apache/hudi/index/SparkMetadataTableRecordIndex.java b/hudi-client/hudi-spark-client/src/main/java/org/apache/hudi/index/SparkMetadataTableGlobalRecordLevelIndex.java
similarity index 96%
rename from hudi-client/hudi-spark-client/src/main/java/org/apache/hudi/index/SparkMetadataTableRecordIndex.java
rename to hudi-client/hudi-spark-client/src/main/java/org/apache/hudi/index/SparkMetadataTableGlobalRecordLevelIndex.java
index acf2fbec9e60..86595ce6ba3d 100644
--- a/hudi-client/hudi-spark-client/src/main/java/org/apache/hudi/index/SparkMetadataTableRecordIndex.java
+++ b/hudi-client/hudi-spark-client/src/main/java/org/apache/hudi/index/SparkMetadataTableGlobalRecordLevelIndex.java
@@ -58,13 +58,13 @@ import static org.apache.hudi.metadata.HoodieTableMetadataUtil.existingIndexVers
import static org.apache.hudi.metadata.MetadataPartitionType.RECORD_INDEX;
/**
- * Hoodie Index implementation backed by the record index present in the Metadata Table.
+ * Hoodie Index implementation backed by the global record level index present in the Metadata Table.
*/
-public class SparkMetadataTableRecordIndex extends HoodieIndex<Object, Object> {
+public class SparkMetadataTableGlobalRecordLevelIndex extends HoodieIndex<Object, Object> {
- private static final Logger LOG = LoggerFactory.getLogger(SparkMetadataTableRecordIndex.class);
+ private static final Logger LOG = LoggerFactory.getLogger(SparkMetadataTableGlobalRecordLevelIndex.class);
- public SparkMetadataTableRecordIndex(HoodieWriteConfig config) {
+ public SparkMetadataTableGlobalRecordLevelIndex(HoodieWriteConfig config) {
super(config);
}
diff --git a/hudi-client/hudi-spark-client/src/main/java/org/apache/hudi/index/SparkMetadataTablePartitionedRecordIndex.java b/hudi-client/hudi-spark-client/src/main/java/org/apache/hudi/index/SparkMetadataTableRecordLevelIndex.java
similarity index 95%
rename from hudi-client/hudi-spark-client/src/main/java/org/apache/hudi/index/SparkMetadataTablePartitionedRecordIndex.java
rename to hudi-client/hudi-spark-client/src/main/java/org/apache/hudi/index/SparkMetadataTableRecordLevelIndex.java
index 683e9505f072..0e1a16de94ae 100644
--- a/hudi-client/hudi-spark-client/src/main/java/org/apache/hudi/index/SparkMetadataTablePartitionedRecordIndex.java
+++ b/hudi-client/hudi-spark-client/src/main/java/org/apache/hudi/index/SparkMetadataTableRecordLevelIndex.java
@@ -50,11 +50,11 @@ import java.util.Map;
import scala.Tuple2;
/**
- * Index to be used with partitioned RLI. Queries the record index for tables with non-global record keys
+ * Index to be used with RLI. Queries the record index for tables with non-global record keys
*/
-public class SparkMetadataTablePartitionedRecordIndex extends SparkMetadataTableRecordIndex {
+public class SparkMetadataTableRecordLevelIndex extends SparkMetadataTableGlobalRecordLevelIndex {
- public SparkMetadataTablePartitionedRecordIndex(HoodieWriteConfig config) {
+ public SparkMetadataTableRecordLevelIndex(HoodieWriteConfig config) {
super(config);
}
diff --git a/hudi-client/hudi-spark-client/src/test/java/org/apache/hudi/client/TestSparkRDDMetadataWriteClient.java b/hudi-client/hudi-spark-client/src/test/java/org/apache/hudi/client/TestSparkRDDMetadataWriteClient.java
index fe9d4ab41e18..e1b99a909294 100644
--- a/hudi-client/hudi-spark-client/src/test/java/org/apache/hudi/client/TestSparkRDDMetadataWriteClient.java
+++ b/hudi-client/hudi-spark-client/src/test/java/org/apache/hudi/client/TestSparkRDDMetadataWriteClient.java
@@ -88,7 +88,7 @@ public class TestSparkRDDMetadataWriteClient extends HoodieClientTestBase {
public void testWritesViaMetadataWriteClient() throws Exception {
HoodieWriteConfig hoodieWriteConfig = getConfigBuilder()
- .withMetadataConfig(HoodieMetadataConfig.newBuilder().enable(true).withMetadataIndexColumnStats(false).withEnableRecordIndex(true)
+ .withMetadataConfig(HoodieMetadataConfig.newBuilder().enable(true).withMetadataIndexColumnStats(false).withEnableGlobalRecordLevelIndex(true)
.withRecordIndexFileGroupCount(1, 1).withStreamingWriteEnabled(true).build()).build();
// trigger end to end write to data table so that metadata table is also initialized.
diff --git a/hudi-client/hudi-spark-client/src/test/java/org/apache/hudi/index/TestHoodieIndexConfigs.java b/hudi-client/hudi-spark-client/src/test/java/org/apache/hudi/index/TestHoodieIndexConfigs.java
index 4705d0489668..1c58001dcb28 100644
--- a/hudi-client/hudi-spark-client/src/test/java/org/apache/hudi/index/TestHoodieIndexConfigs.java
+++ b/hudi-client/hudi-spark-client/src/test/java/org/apache/hudi/index/TestHoodieIndexConfigs.java
@@ -98,7 +98,7 @@ public class TestHoodieIndexConfigs {
config = clientConfigBuilder.withPath(basePath)
.withIndexConfig(indexConfigBuilder.withIndexType(HoodieIndex.IndexType.RECORD_INDEX).build())
.build();
- assertTrue(SparkHoodieIndexFactory.createIndex(config) instanceof SparkMetadataTableRecordIndex);
+ assertTrue(SparkHoodieIndexFactory.createIndex(config) instanceof SparkMetadataTableGlobalRecordLevelIndex);
break;
default:
// no -op. just for checkstyle errors
diff --git a/hudi-client/hudi-spark-client/src/test/java/org/apache/hudi/table/upgrade/TestUpgradeDowngradeLegacy.java b/hudi-client/hudi-spark-client/src/test/java/org/apache/hudi/table/upgrade/TestUpgradeDowngradeLegacy.java
index ee4a0e6e4f19..04864a749bd7 100644
--- a/hudi-client/hudi-spark-client/src/test/java/org/apache/hudi/table/upgrade/TestUpgradeDowngradeLegacy.java
+++ b/hudi-client/hudi-spark-client/src/test/java/org/apache/hudi/table/upgrade/TestUpgradeDowngradeLegacy.java
@@ -568,7 +568,7 @@ public class TestUpgradeDowngradeLegacy extends HoodieClientTestBase {
.enable(true)
.withMetadataIndexColumnStats(true)
.withMetadataIndexBloomFilter(true)
- .withEnableRecordIndex(true).build())
+ .withEnableGlobalRecordLevelIndex(true).build())
.build();
for (MetadataPartitionType partitionType : MetadataPartitionType.getValidValues()) {
metaClient.getTableConfig().setMetadataPartitionState(metaClient, partitionType.getPartitionPath(), true);
diff --git a/hudi-common/src/main/java/org/apache/hudi/common/config/HoodieMetadataConfig.java b/hudi-common/src/main/java/org/apache/hudi/common/config/HoodieMetadataConfig.java
index ace77303d52c..3b170499fc75 100644
--- a/hudi-common/src/main/java/org/apache/hudi/common/config/HoodieMetadataConfig.java
+++ b/hudi-common/src/main/java/org/apache/hudi/common/config/HoodieMetadataConfig.java
@@ -274,15 +274,16 @@ public final class HoodieMetadataConfig extends HoodieConfig {
.withDocumentation("When there is a pending instant in data table, this config limits the allowed number of deltacommits in metadata table to "
+ "prevent the metadata table's timeline from growing unboundedly as compaction won't be triggered due to the pending data table instant.");
- public static final ConfigProperty<Boolean> RECORD_INDEX_ENABLE_PROP = ConfigProperty
- .key(METADATA_PREFIX + ".record.index.enable")
+ public static final ConfigProperty<Boolean> GLOBAL_RECORD_LEVEL_INDEX_ENABLE_PROP = ConfigProperty
+ .key(METADATA_PREFIX + ".global.record.level.index.enable")
.defaultValue(false)
+ .withAlternatives(METADATA_PREFIX + ".record.index.enable")
.markAdvanced()
.sinceVersion("0.14.0")
.withDocumentation("Create the HUDI Record Index within the Metadata Table");
- public static final ConfigProperty<Boolean> PARTITIONED_RECORD_INDEX_ENABLE_PROP = ConfigProperty
- .key(METADATA_PREFIX + ".partitioned.record.index.enable")
+ public static final ConfigProperty<Boolean> RECORD_LEVEL_INDEX_ENABLE_PROP = ConfigProperty
+ .key(METADATA_PREFIX + ".record.level.index.enable")
.defaultValue(false)
.markAdvanced()
.sinceVersion("1.1.0")
@@ -615,12 +616,12 @@ public final class HoodieMetadataConfig extends HoodieConfig {
return getBooleanOrDefault(ENABLE_METADATA_INDEX_COLUMN_STATS);
}
- public boolean isRecordIndexEnabled() {
- return isEnabled() && getBooleanOrDefault(RECORD_INDEX_ENABLE_PROP);
+ public boolean isGlobalRecordLevelIndexEnabled() {
+ return isEnabled() && getBooleanOrDefault(GLOBAL_RECORD_LEVEL_INDEX_ENABLE_PROP);
}
- public boolean isPartitionedRecordIndexEnabled() {
- return isEnabled() && getBooleanOrDefault(PARTITIONED_RECORD_INDEX_ENABLE_PROP);
+ public boolean isRecordLevelIndexEnabled() {
+ return isEnabled() && getBooleanOrDefault(RECORD_LEVEL_INDEX_ENABLE_PROP);
}
public List<String> getColumnsEnabledForColumnStatsIndex() {
@@ -809,7 +810,7 @@ public final class HoodieMetadataConfig extends HoodieConfig {
public boolean isSecondaryIndexEnabled() {
// Secondary index is enabled only iff record index (primary key index) is also enabled and a secondary index column is specified.
- return isRecordIndexEnabled() && getBoolean(SECONDARY_INDEX_ENABLE_PROP) && StringUtils.nonEmpty(getSecondaryIndexColumn())
+ return isGlobalRecordLevelIndexEnabled() && getBoolean(SECONDARY_INDEX_ENABLE_PROP) && StringUtils.nonEmpty(getSecondaryIndexColumn())
&& !isDropMetadataIndex(MetadataPartitionType.SECONDARY_INDEX.getPartitionPath());
}
@@ -1026,8 +1027,8 @@ public final class HoodieMetadataConfig extends HoodieConfig {
return this;
}
- public Builder withEnableRecordIndex(boolean enabled) {
- metadataConfig.setValue(RECORD_INDEX_ENABLE_PROP, String.valueOf(enabled));
+ public Builder withEnableGlobalRecordLevelIndex(boolean enabled) {
+ metadataConfig.setValue(GLOBAL_RECORD_LEVEL_INDEX_ENABLE_PROP, String.valueOf(enabled));
return this;
}
diff --git a/hudi-common/src/main/java/org/apache/hudi/metadata/HoodieTableMetadataUtil.java b/hudi-common/src/main/java/org/apache/hudi/metadata/HoodieTableMetadataUtil.java
index 39cd361b7102..cfa4c921f35d 100644
--- a/hudi-common/src/main/java/org/apache/hudi/metadata/HoodieTableMetadataUtil.java
+++ b/hudi-common/src/main/java/org/apache/hudi/metadata/HoodieTableMetadataUtil.java
@@ -877,7 +877,7 @@ public class HoodieTableMetadataUtil {
.flatMap(writeStat -> {
HoodieStorage storage = HoodieStorageUtils.getStorage(new StoragePath(writeStat.getPath()), storageConfiguration);
return CollectionUtils.toStream(BaseFileRecordParsingUtils
- .generateRLIMetadataHoodieRecordsForBaseFile(basePath, writeStat, writesFileIdEncoding, instantTime, storage, metadataConfig.isPartitionedRecordIndexEnabled()));
+ .generateRLIMetadataHoodieRecordsForBaseFile(basePath, writeStat, writesFileIdEncoding, instantTime, storage, metadataConfig.isRecordLevelIndexEnabled()));
})
.iterator();
}
@@ -907,7 +907,7 @@ public class HoodieTableMetadataUtil {
.collect(Collectors.toList());
// Process deleted keys to create deletes
List<HoodieRecord> deletedRecords = deletedKeys.stream()
- .map(key -> HoodieMetadataPayload.createRecordIndexDelete(key, partitionPath, metadataConfig.isPartitionedRecordIndexEnabled()))
+ .map(key -> HoodieMetadataPayload.createRecordIndexDelete(key, partitionPath, metadataConfig.isRecordLevelIndexEnabled()))
.collect(Collectors.toList());
// Combine all records into one list
List<HoodieRecord> allRecords = new ArrayList<>();
@@ -933,7 +933,7 @@ public class HoodieTableMetadataUtil {
// (TODO: make this configurable)
long targetPartitionSize = 100 * 1024 * 1024;
parallelism = (int) Math.max(1, (totalWriteBytesForRLI + targetPartitionSize - 1) / targetPartitionSize);
- return reduceByKeys(recordIndexRecords, parallelism, metadataConfig.isPartitionedRecordIndexEnabled());
+ return reduceByKeys(recordIndexRecords, parallelism, metadataConfig.isRecordLevelIndexEnabled());
} catch (Exception e) {
throw new HoodieException("Failed to generate RLI records for metadata table", e);
}
@@ -2383,7 +2383,7 @@ public class HoodieTableMetadataUtil {
}
// Does any enabled partition being enabled need to track the written records
- return config.isRecordIndexEnabled() || config.isPartitionedRecordIndexEnabled();
+ return config.isGlobalRecordLevelIndexEnabled() || config.isRecordLevelIndexEnabled();
}
/**
diff --git a/hudi-common/src/main/java/org/apache/hudi/metadata/MetadataPartitionType.java b/hudi-common/src/main/java/org/apache/hudi/metadata/MetadataPartitionType.java
index 4e52cb378172..0c7d291f97d1 100644
--- a/hudi-common/src/main/java/org/apache/hudi/metadata/MetadataPartitionType.java
+++ b/hudi-common/src/main/java/org/apache/hudi/metadata/MetadataPartitionType.java
@@ -159,7 +159,7 @@ public enum MetadataPartitionType {
RECORD_INDEX(HoodieTableMetadataUtil.PARTITION_NAME_RECORD_INDEX, "record-index-", 5) {
@Override
public boolean isMetadataPartitionEnabled(HoodieMetadataConfig metadataConfig, HoodieTableConfig tableConfig) {
- return metadataConfig.isRecordIndexEnabled() || metadataConfig.isPartitionedRecordIndexEnabled();
+ return metadataConfig.isGlobalRecordLevelIndexEnabled() || metadataConfig.isRecordLevelIndexEnabled();
}
@Override
diff --git a/hudi-common/src/test/java/org/apache/hudi/common/config/TestHoodieMetadataConfig.java b/hudi-common/src/test/java/org/apache/hudi/common/config/TestHoodieMetadataConfig.java
index 73d705df907d..fd3e0fdb961e 100644
--- a/hudi-common/src/test/java/org/apache/hudi/common/config/TestHoodieMetadataConfig.java
+++ b/hudi-common/src/test/java/org/apache/hudi/common/config/TestHoodieMetadataConfig.java
@@ -24,6 +24,8 @@ import org.junit.jupiter.api.Test;
import java.util.Properties;
import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Tests {@link HoodieMetadataConfig}.
@@ -82,4 +84,26 @@ class TestHoodieMetadataConfig {
assertEquals(10000, configWithZeroValue.getStreamingWritesCoalesceDivisorForDataTableWrites());
}
+ @Test
+ void testGlobalRLI() {
+ // Test default value
+ HoodieMetadataConfig config = HoodieMetadataConfig.newBuilder().build();
+ assertFalse(config.isGlobalRecordLevelIndexEnabled());
+
+ //set older config property.
+ Properties props = new Properties();
+ props.put("hoodie.metadata.record.index.enable", "true");
+ HoodieMetadataConfig configWithCustomValue = HoodieMetadataConfig.newBuilder()
+ .fromProperties(props)
+ .build();
+ assertTrue(configWithCustomValue.isGlobalRecordLevelIndexEnabled());
+
+ // set latest config property
+ props = new Properties();
+ props.put(HoodieMetadataConfig.GLOBAL_RECORD_LEVEL_INDEX_ENABLE_PROP.key(), "true");
+ configWithCustomValue = HoodieMetadataConfig.newBuilder()
+ .fromProperties(props)
+ .build();
+ assertTrue(configWithCustomValue.isGlobalRecordLevelIndexEnabled());
+ }
}
diff --git a/hudi-common/src/test/java/org/apache/hudi/metadata/TestMetadataPartitionType.java b/hudi-common/src/test/java/org/apache/hudi/metadata/TestMetadataPartitionType.java
index 3c3036dc1027..2ccddf81add3 100644
--- a/hudi-common/src/test/java/org/apache/hudi/metadata/TestMetadataPartitionType.java
+++ b/hudi-common/src/test/java/org/apache/hudi/metadata/TestMetadataPartitionType.java
@@ -84,7 +84,7 @@ public class TestMetadataPartitionType {
expectedEnabledPartitions = 3;
break;
case SECONDARY_INDEX:
- metadataConfigBuilder.enable(true).withEnableRecordIndex(true).withSecondaryIndexEnabled(true).withSecondaryIndexForColumn("col1");
+ metadataConfigBuilder.enable(true).withEnableGlobalRecordLevelIndex(true).withSecondaryIndexEnabled(true).withSecondaryIndexForColumn("col1");
expectedEnabledPartitions = 4;
break;
case BLOOM_FILTERS:
@@ -92,7 +92,7 @@ public class TestMetadataPartitionType {
expectedEnabledPartitions = 3;
break;
case RECORD_INDEX:
- metadataConfigBuilder.enable(true).withEnableRecordIndex(true);
+ metadataConfigBuilder.enable(true).withEnableGlobalRecordLevelIndex(true);
expectedEnabledPartitions = 3;
break;
default:
@@ -122,7 +122,7 @@ public class TestMetadataPartitionType {
Mockito.when(tableConfig.isMetadataPartitionAvailable(MetadataPartitionType.FILES)).thenReturn(true);
Mockito.when(metaClient.getIndexMetadata()).thenReturn(Option.empty());
Mockito.when(metaClient.getTableConfig().isMetadataPartitionAvailable(MetadataPartitionType.RECORD_INDEX)).thenReturn(true);
- HoodieMetadataConfig metadataConfig = HoodieMetadataConfig.newBuilder().enable(true).withEnableRecordIndex(false).build();
+ HoodieMetadataConfig metadataConfig = HoodieMetadataConfig.newBuilder().enable(true).withEnableGlobalRecordLevelIndex(false).build();
List<MetadataPartitionType> enabledPartitions = MetadataPartitionType.getEnabledPartitions(metadataConfig, metaClient);
diff --git a/hudi-spark-datasource/hudi-spark/src/test/java/org/apache/hudi/TestMetadataTableSupport.java b/hudi-spark-datasource/hudi-spark/src/test/java/org/apache/hudi/TestMetadataTableSupport.java
index 957d15d41454..b3b3fcf550a4 100644
--- a/hudi-spark-datasource/hudi-spark/src/test/java/org/apache/hudi/TestMetadataTableSupport.java
+++ b/hudi-spark-datasource/hudi-spark/src/test/java/org/apache/hudi/TestMetadataTableSupport.java
@@ -60,7 +60,7 @@ class TestMetadataTableSupport extends HoodieSparkClientTestBase {
HoodieWriteConfig config = getConfigBuilder()
.withMetadataConfig(HoodieMetadataConfig.newBuilder()
.enable(true)
- .withEnableRecordIndex(true).build())
+ .withEnableGlobalRecordLevelIndex(true).build())
.build();
try (SparkRDDWriteClient writeClient = getHoodieWriteClient(config)) {
diff --git a/hudi-spark-datasource/hudi-spark/src/test/java/org/apache/hudi/client/TestHoodieClientMultiWriter.java b/hudi-spark-datasource/hudi-spark/src/test/java/org/apache/hudi/client/TestHoodieClientMultiWriter.java
index 26a84c5eb8e6..305119c070d9 100644
--- a/hudi-spark-datasource/hudi-spark/src/test/java/org/apache/hudi/client/TestHoodieClientMultiWriter.java
+++ b/hudi-spark-datasource/hudi-spark/src/test/java/org/apache/hudi/client/TestHoodieClientMultiWriter.java
@@ -1198,7 +1198,7 @@ public class TestHoodieClientMultiWriter extends HoodieClientTestBase {
HoodieWriteConfig.Builder writeConfigBuilder = getConfigBuilder()
.withMetadataConfig(HoodieMetadataConfig.newBuilder()
.withMetadataIndexColumnStats(true)
- .withEnableRecordIndex(true).build())
+ .withEnableGlobalRecordLevelIndex(true).build())
.withArchivalConfig(HoodieArchivalConfig.newBuilder()
.withAutoArchive(false).build())
.withWriteConcurrencyMode(WriteConcurrencyMode.OPTIMISTIC_CONCURRENCY_CONTROL)
diff --git a/hudi-spark-datasource/hudi-spark/src/test/java/org/apache/hudi/client/functional/TestMetadataUtilRLIandSIRecordGeneration.java b/hudi-spark-datasource/hudi-spark/src/test/java/org/apache/hudi/client/functional/TestMetadataUtilRLIandSIRecordGeneration.java
index 0bf079b34279..9149de9ecfa7 100644
--- a/hudi-spark-datasource/hudi-spark/src/test/java/org/apache/hudi/client/functional/TestMetadataUtilRLIandSIRecordGeneration.java
+++ b/hudi-spark-datasource/hudi-spark/src/test/java/org/apache/hudi/client/functional/TestMetadataUtilRLIandSIRecordGeneration.java
@@ -245,7 +245,7 @@ public class TestMetadataUtilRLIandSIRecordGeneration extends HoodieClientTestBa
// poll into generateRLIMetadataHoodieRecordsForBaseFile to fetch MDT RLI records for inserts and deletes.
Iterator<HoodieRecord> rliRecordsItr = BaseFileRecordParsingUtils.generateRLIMetadataHoodieRecordsForBaseFile(metaClient.getBasePath().toString(),
- writeStatus.getStat(), writeConfig.getWritesFileIdEncoding(), finalCommitTime, metaClient.getStorage(), writeConfig.isPartitionedRecordIndexEnabled());
+ writeStatus.getStat(), writeConfig.getWritesFileIdEncoding(), finalCommitTime, metaClient.getStorage(), writeConfig.isRecordLevelIndexEnabled());
while (rliRecordsItr.hasNext()) {
HoodieRecord rliRecord = rliRecordsItr.next();
String key = rliRecord.getRecordKey();
@@ -657,7 +657,7 @@ public class TestMetadataUtilRLIandSIRecordGeneration extends HoodieClientTestBa
}
Iterator<HoodieRecord> rliRecordsItr = BaseFileRecordParsingUtils.generateRLIMetadataHoodieRecordsForBaseFile(metaClient.getBasePath().toString(), writeStatus.getStat(),
- writeConfig.getWritesFileIdEncoding(), commitTime, metaClient.getStorage(), writeConfig.isPartitionedRecordIndexEnabled());
+ writeConfig.getWritesFileIdEncoding(), commitTime, metaClient.getStorage(), writeConfig.isRecordLevelIndexEnabled());
while (rliRecordsItr.hasNext()) {
HoodieRecord rliRecord = rliRecordsItr.next();
String key = rliRecord.getRecordKey();
diff --git a/hudi-spark-datasource/hudi-spark/src/test/java/org/apache/hudi/functional/TestGlobalIndexEnableUpdatePartitions.java b/hudi-spark-datasource/hudi-spark/src/test/java/org/apache/hudi/functional/TestGlobalIndexEnableUpdatePartitions.java
index 295ded1eea7c..94e3fd9f2db1 100644
--- a/hudi-spark-datasource/hudi-spark/src/test/java/org/apache/hudi/functional/TestGlobalIndexEnableUpdatePartitions.java
+++ b/hudi-spark-datasource/hudi-spark/src/test/java/org/apache/hudi/functional/TestGlobalIndexEnableUpdatePartitions.java
@@ -383,7 +383,7 @@ public class TestGlobalIndexEnableUpdatePartitions extends SparkClientFunctional
private HoodieWriteConfig getWriteConfig(Class<?> payloadClass, IndexType indexType) {
HoodieMetadataConfig.Builder metadataConfigBuilder = HoodieMetadataConfig.newBuilder();
if (indexType == IndexType.RECORD_INDEX) {
- metadataConfigBuilder.enable(true).withEnableRecordIndex(true);
+ metadataConfigBuilder.enable(true).withEnableGlobalRecordLevelIndex(true);
} else {
metadataConfigBuilder.enable(false);
}
diff --git a/hudi-spark-datasource/hudi-spark/src/test/java/org/apache/hudi/functional/TestHoodieBackedMetadata.java b/hudi-spark-datasource/hudi-spark/src/test/java/org/apache/hudi/functional/TestHoodieBackedMetadata.java
index e20bb31abfb9..e4f74aba6521 100644
--- a/hudi-spark-datasource/hudi-spark/src/test/java/org/apache/hudi/functional/TestHoodieBackedMetadata.java
+++ b/hudi-spark-datasource/hudi-spark/src/test/java/org/apache/hudi/functional/TestHoodieBackedMetadata.java
@@ -1140,7 +1140,7 @@ public class TestHoodieBackedMetadata extends TestHoodieMetadataBase {
writeConfig = getWriteConfigBuilder(false, true, false)
.withMetadataConfig(HoodieMetadataConfig.newBuilder()
.enable(true)
- .withEnableRecordIndex(true)
+ .withEnableGlobalRecordLevelIndex(true)
// Disable the other two default index for this test because the test orchestrates
// the rollback with the assumption of init commits being in certain order
.withMetadataIndexColumnStats(false)
@@ -1721,7 +1721,7 @@ public class TestHoodieBackedMetadata extends TestHoodieMetadataBase {
.build())
.withMetadataConfig(HoodieMetadataConfig.newBuilder()
.enable(true)
- .withEnableRecordIndex(true)
+ .withEnableGlobalRecordLevelIndex(true)
.withRecordIndexFileGroupCount(5, 5)
.build())
.withClusteringConfig(HoodieClusteringConfig.newBuilder()
@@ -1746,7 +1746,7 @@ public class TestHoodieBackedMetadata extends TestHoodieMetadataBase {
HoodieWriteConfig writeConfig = getWriteConfigBuilder(true, true, false)
.withMetadataConfig(HoodieMetadataConfig.newBuilder()
.enable(true)
- .withEnableRecordIndex(true)
+ .withEnableGlobalRecordLevelIndex(true)
.withRecordIndexFileGroupCount(5, 5)
.build())
.build();
@@ -1793,7 +1793,7 @@ public class TestHoodieBackedMetadata extends TestHoodieMetadataBase {
writeConfig = getWriteConfigBuilder(true, true, false)
.withMetadataConfig(HoodieMetadataConfig.newBuilder()
.enable(true)
- .withEnableRecordIndex(true)
+ .withEnableGlobalRecordLevelIndex(true)
.withRecordIndexFileGroupCount(3, 3)
.build())
.build();
@@ -2849,7 +2849,7 @@ public class TestHoodieBackedMetadata extends TestHoodieMetadataBase {
init(HoodieTableType.COPY_ON_WRITE);
// Enable Record index and set index type to record index.
Properties props = new Properties();
- props.setProperty(HoodieMetadataConfig.RECORD_INDEX_ENABLE_PROP.key(), "true");
+ props.setProperty(HoodieMetadataConfig.GLOBAL_RECORD_LEVEL_INDEX_ENABLE_PROP.key(), "true");
props.setProperty(HoodieIndexConfig.INDEX_TYPE.key(), "RECORD_INDEX");
HoodieWriteConfig cfg = getWriteConfigBuilder(true, true, false)
.withProps(props).build();
@@ -3332,7 +3332,7 @@ public class TestHoodieBackedMetadata extends TestHoodieMetadataBase {
.enable(true)
.enableMetrics(false)
.ignoreSpuriousDeletes(false)
- .withEnableRecordIndex(true)
+ .withEnableGlobalRecordLevelIndex(true)
.build())
.build();
@@ -3591,7 +3591,7 @@ public class TestHoodieBackedMetadata extends TestHoodieMetadataBase {
init(HoodieTableType.COPY_ON_WRITE, true);
HoodieSparkEngineContext engineContext = new HoodieSparkEngineContext(jsc);
HoodieWriteConfig writeConfig = getWriteConfigBuilder(true, true, false)
- .withMetadataConfig(HoodieMetadataConfig.newBuilder().withEnableRecordIndex(true).withMaxNumDeltaCommitsBeforeCompaction(1).build())
+ .withMetadataConfig(HoodieMetadataConfig.newBuilder().withEnableGlobalRecordLevelIndex(true).withMaxNumDeltaCommitsBeforeCompaction(1).build())
.withIndexConfig(HoodieIndexConfig.newBuilder().withIndexType(HoodieIndex.IndexType.RECORD_INDEX).build())
.build();
diff --git a/hudi-spark-datasource/hudi-spark/src/test/java/org/apache/hudi/functional/TestHoodieIndex.java b/hudi-spark-datasource/hudi-spark/src/test/java/org/apache/hudi/functional/TestHoodieIndex.java
index 65a4d37aaa9a..2c4c0be4c9b1 100644
--- a/hudi-spark-datasource/hudi-spark/src/test/java/org/apache/hudi/functional/TestHoodieIndex.java
+++ b/hudi-spark-datasource/hudi-spark/src/test/java/org/apache/hudi/functional/TestHoodieIndex.java
@@ -148,7 +148,7 @@ public class TestHoodieIndex extends TestHoodieMetadataBase {
.withMetadataIndexBloomFilter(enableMetadataIndex)
.withMetadataIndexColumnStats(enableMetadataIndex);
if (indexType == IndexType.RECORD_INDEX) {
- metadataConfigBuilder.withEnableRecordIndex(true);
+ metadataConfigBuilder.withEnableGlobalRecordLevelIndex(true);
}
config = getConfigBuilder()
diff --git a/hudi-spark-datasource/hudi-spark/src/test/java/org/apache/hudi/io/TestAppendHandle.java b/hudi-spark-datasource/hudi-spark/src/test/java/org/apache/hudi/io/TestAppendHandle.java
index 6bef28173b76..16a980fd805a 100644
--- a/hudi-spark-datasource/hudi-spark/src/test/java/org/apache/hudi/io/TestAppendHandle.java
+++ b/hudi-spark-datasource/hudi-spark/src/test/java/org/apache/hudi/io/TestAppendHandle.java
@@ -61,7 +61,7 @@ public class TestAppendHandle extends BaseTestHandle {
.withFileSystemViewConfig(FileSystemViewStorageConfig.newBuilder().withRemoteServerPort(timelineServicePort).build())
.withMetadataConfig(HoodieMetadataConfig.newBuilder()
.enable(true)
- .withEnableRecordIndex(true)
+ .withEnableGlobalRecordLevelIndex(true)
.withStreamingWriteEnabled(true)
.withSecondaryIndexEnabled(true)
.withSecondaryIndexName("sec-rider")
diff --git a/hudi-spark-datasource/hudi-spark/src/test/java/org/apache/hudi/io/TestCreateHandle.java b/hudi-spark-datasource/hudi-spark/src/test/java/org/apache/hudi/io/TestCreateHandle.java
index df5f08bf6b40..b8109e56880f 100644
--- a/hudi-spark-datasource/hudi-spark/src/test/java/org/apache/hudi/io/TestCreateHandle.java
+++ b/hudi-spark-datasource/hudi-spark/src/test/java/org/apache/hudi/io/TestCreateHandle.java
@@ -58,7 +58,7 @@ public class TestCreateHandle extends BaseTestHandle {
.withFileSystemViewConfig(FileSystemViewStorageConfig.newBuilder().withRemoteServerPort(timelineServicePort).build())
.withMetadataConfig(HoodieMetadataConfig.newBuilder()
.enable(true)
- .withEnableRecordIndex(true)
+ .withEnableGlobalRecordLevelIndex(true)
.withStreamingWriteEnabled(true)
.withSecondaryIndexEnabled(true)
.withSecondaryIndexName("sec-rider")
diff --git a/hudi-spark-datasource/hudi-spark/src/test/java/org/apache/hudi/io/TestMergeHandle.java b/hudi-spark-datasource/hudi-spark/src/test/java/org/apache/hudi/io/TestMergeHandle.java
index c47927a92af3..343e7d35314b 100644
--- a/hudi-spark-datasource/hudi-spark/src/test/java/org/apache/hudi/io/TestMergeHandle.java
+++ b/hudi-spark-datasource/hudi-spark/src/test/java/org/apache/hudi/io/TestMergeHandle.java
@@ -557,7 +557,7 @@ public class TestMergeHandle extends BaseTestHandle {
.withFileSystemViewConfig(FileSystemViewStorageConfig.newBuilder().withRemoteServerPort(timelineServicePort).build())
.withMetadataConfig(HoodieMetadataConfig.newBuilder()
.enable(true)
- .withEnableRecordIndex(true)
+ .withEnableGlobalRecordLevelIndex(true)
.withStreamingWriteEnabled(true)
.withSecondaryIndexEnabled(true)
.withSecondaryIndexName("sec-rider")
diff --git a/hudi-spark-datasource/hudi-spark/src/test/java/org/apache/hudi/io/TestMetadataWriterCommit.java b/hudi-spark-datasource/hudi-spark/src/test/java/org/apache/hudi/io/TestMetadataWriterCommit.java
index 48d01e13768a..9dae84c22ff4 100644
--- a/hudi-spark-datasource/hudi-spark/src/test/java/org/apache/hudi/io/TestMetadataWriterCommit.java
+++ b/hudi-spark-datasource/hudi-spark/src/test/java/org/apache/hudi/io/TestMetadataWriterCommit.java
@@ -78,7 +78,7 @@ public class TestMetadataWriterCommit extends BaseTestHandle {
.withFileSystemViewConfig(FileSystemViewStorageConfig.newBuilder().withRemoteServerPort(timelineServicePort).build())
.withMetadataConfig(HoodieMetadataConfig.newBuilder()
.enable(true)
- .withEnableRecordIndex(true)
+ .withEnableGlobalRecordLevelIndex(true)
.withMetadataIndexColumnStats(false)
.withSecondaryIndexEnabled(false)
.withStreamingWriteEnabled(true)
@@ -181,7 +181,7 @@ public class TestMetadataWriterCommit extends BaseTestHandle {
.withFileSystemViewConfig(FileSystemViewStorageConfig.newBuilder().withRemoteServerPort(timelineServicePort).build())
.withMetadataConfig(HoodieMetadataConfig.newBuilder()
.enable(true)
- .withEnableRecordIndex(true)
+ .withEnableGlobalRecordLevelIndex(true)
.withMetadataIndexColumnStats(false)
.withSecondaryIndexEnabled(true)
.withSecondaryIndexName("sec-rider")
diff --git a/hudi-spark-datasource/hudi-spark/src/test/java/org/apache/hudi/table/upgrade/TestUpgradeDowngrade.java b/hudi-spark-datasource/hudi-spark/src/test/java/org/apache/hudi/table/upgrade/TestUpgradeDowngrade.java
index 6ce364a1557a..808e76dbd93c 100644
--- a/hudi-spark-datasource/hudi-spark/src/test/java/org/apache/hudi/table/upgrade/TestUpgradeDowngrade.java
+++ b/hudi-spark-datasource/hudi-spark/src/test/java/org/apache/hudi/table/upgrade/TestUpgradeDowngrade.java
@@ -417,7 +417,7 @@ public class TestUpgradeDowngrade extends SparkClientFunctionalTestHarness {
.withPath(metaClient.getBasePath())
.withWriteTableVersion(fromVersion.versionCode())
.withMetadataConfig(HoodieMetadataConfig.newBuilder()
- .withEnableRecordIndex(true).build())
+ .withEnableGlobalRecordLevelIndex(true).build())
.withProps(props)
.build();
@@ -440,7 +440,7 @@ public class TestUpgradeDowngrade extends SparkClientFunctionalTestHarness {
.withPath(metaClient.getBasePath())
.withProps(props);
if (mdtEnabled) {
- upgradeWriteConfig.withMetadataConfig(HoodieMetadataConfig.newBuilder().enable(true).withEnableRecordIndex(false).build());
+ upgradeWriteConfig.withMetadataConfig(HoodieMetadataConfig.newBuilder().enable(true).withEnableGlobalRecordLevelIndex(false).build());
} else {
upgradeWriteConfig.withMetadataConfig(HoodieMetadataConfig.newBuilder().enable(false).build());
}
diff --git a/hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/hudi/TestInsertDedupPolicy.scala b/hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/hudi/TestInsertDedupPolicy.scala
index 376b38d6812d..99b68a3bbd42 100644
--- a/hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/hudi/TestInsertDedupPolicy.scala
+++ b/hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/hudi/TestInsertDedupPolicy.scala
@@ -75,7 +75,7 @@ class TestInsertDedupPolicy extends SparkClientFunctionalTestHarness {
option(TABLE_TYPE.key, tableType).
option(DataSourceWriteOptions.TABLE_NAME.key, "test_table").
option(HoodieCompactionConfig.INLINE_COMPACT.key, "false").
- option(HoodieMetadataConfig.RECORD_INDEX_ENABLE_PROP.key, "true").
+ option(HoodieMetadataConfig.GLOBAL_RECORD_LEVEL_INDEX_ENABLE_PROP.key, "true").
options(opts).
mode(SaveMode.Overwrite).
save(basePath)
diff --git a/hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/hudi/functional/RecordLevelIndexTestBase.scala b/hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/hudi/functional/RecordLevelIndexTestBase.scala
index 3dcbce2186af..0d486e1ddcf8 100644
--- a/hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/hudi/functional/RecordLevelIndexTestBase.scala
+++ b/hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/hudi/functional/RecordLevelIndexTestBase.scala
@@ -38,7 +38,7 @@ import scala.util.Using
class RecordLevelIndexTestBase extends HoodieStatsIndexTestBase {
val metadataOpts: Map[String, String] = Map(
HoodieMetadataConfig.ENABLE.key -> "true",
- HoodieMetadataConfig.RECORD_INDEX_ENABLE_PROP.key -> "true",
+ HoodieMetadataConfig.GLOBAL_RECORD_LEVEL_INDEX_ENABLE_PROP.key -> "true",
HoodieMetadataConfig.ENABLE_METADATA_INDEX_COLUMN_STATS.key -> "false"
)
def commonOpts: Map[String, String] = Map(
diff --git a/hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/hudi/functional/TestRecordLevelIndex.scala b/hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/hudi/functional/TestGlobalRecordLevelIndex.scala
similarity index 94%
copy from hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/hudi/functional/TestRecordLevelIndex.scala
copy to hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/hudi/functional/TestGlobalRecordLevelIndex.scala
index a6b857952437..21960e4fe0ab 100644
--- a/hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/hudi/functional/TestRecordLevelIndex.scala
+++ b/hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/hudi/functional/TestGlobalRecordLevelIndex.scala
@@ -31,6 +31,7 @@ import org.apache.hudi.common.testutils.{HoodieTestDataGenerator, InProcessTimeG
import org.apache.hudi.common.testutils.HoodieTestDataGenerator.recordsToStrings
import org.apache.hudi.config._
import org.apache.hudi.exception.HoodieWriteConflictException
+import org.apache.hudi.index.HoodieIndex
import org.apache.hudi.index.record.HoodieRecordIndex
import org.apache.hudi.metadata.{HoodieBackedTableMetadata, HoodieTableMetadataUtil, MetadataPartitionType}
import org.apache.hudi.util.JavaConversions
@@ -56,7 +57,7 @@ import scala.language.postfixOps
import scala.util.Using
@Tag("functional-b")
-class TestRecordLevelIndex extends RecordLevelIndexTestBase {
+class TestGlobalRecordLevelIndex extends RecordLevelIndexTestBase {
@ParameterizedTest
@EnumSource(classOf[HoodieTableType])
@@ -75,9 +76,9 @@ class TestRecordLevelIndex extends RecordLevelIndexTestBase {
val hudiOpts = commonOpts + (DataSourceWriteOptions.TABLE_TYPE.key -> tableType.name()) +
(HoodieMetadataConfig.RECORD_INDEX_MIN_FILE_GROUP_COUNT_PROP.key -> "1") +
(HoodieMetadataConfig.RECORD_INDEX_MAX_FILE_GROUP_COUNT_PROP.key -> "1") +
- (HoodieIndexConfig.INDEX_TYPE.key -> "RECORD_INDEX") +
+ (HoodieIndexConfig.INDEX_TYPE.key -> HoodieIndex.IndexType.GLOBAL_RECORD_LEVEL_INDEX.name()) +
(HoodieIndexConfig.RECORD_INDEX_UPDATE_PARTITION_PATH_ENABLE.key -> "true") -
- HoodieMetadataConfig.RECORD_INDEX_ENABLE_PROP.key
+ HoodieMetadataConfig.GLOBAL_RECORD_LEVEL_INDEX_ENABLE_PROP.key
val dataGen1 = HoodieTestDataGenerator.createTestGeneratorFirstPartition()
val dataGen2 = HoodieTestDataGenerator.createTestGeneratorSecondPartition()
@@ -117,9 +118,9 @@ class TestRecordLevelIndex extends RecordLevelIndexTestBase {
val hudiOpts2 = commonOpts + (DataSourceWriteOptions.TABLE_TYPE.key -> tableType.name()) +
(HoodieMetadataConfig.RECORD_INDEX_MIN_FILE_GROUP_COUNT_PROP.key -> "1") +
(HoodieMetadataConfig.RECORD_INDEX_MAX_FILE_GROUP_COUNT_PROP.key -> "1") +
- (HoodieIndexConfig.INDEX_TYPE.key -> "RECORD_INDEX") +
+ (HoodieIndexConfig.INDEX_TYPE.key -> HoodieIndex.IndexType.GLOBAL_RECORD_LEVEL_INDEX.name()) +
(HoodieIndexConfig.RECORD_INDEX_UPDATE_PARTITION_PATH_ENABLE.key -> "true") +
- (HoodieMetadataConfig.RECORD_INDEX_ENABLE_PROP.key -> "true")
+ (HoodieMetadataConfig.GLOBAL_RECORD_LEVEL_INDEX_ENABLE_PROP.key -> "true")
val instantTime3 = getNewInstantTime()
// batch3. update 2 records from newly inserted records from commit 2 to partition2
@@ -144,8 +145,34 @@ class TestRecordLevelIndex extends RecordLevelIndexTestBase {
@ParameterizedTest
@EnumSource(classOf[HoodieTableType])
- def testRLIUpsert(tableType: HoodieTableType): Unit = {
- val hudiOpts = commonOpts + (DataSourceWriteOptions.TABLE_TYPE.key -> tableType.name())
+ def testRLIUpsertTableTypes(tableType: HoodieTableType): Unit = {
+ testRLIUpsert(tableType, "GLOBAL_RECORD_LEVEL_INDEX")
+ }
+
+ @ParameterizedTest
+ @CsvSource(value = Array(
+ "RECORD_INDEX",
+ "GLOBAL_RECORD_LEVEL_INDEX")
+ )
+ // tests b/w compatibility of configs for global RLI
+ def testRLIUpsertIndexTypes(indexType: String): Unit = {
+ testRLIUpsert(HoodieTableType.COPY_ON_WRITE, indexType)
+ }
+
+ @ParameterizedTest
+ @CsvSource(value = Array(
+ "hoodie.metadata.record.index.enable",
+ "hoodie.metadata.global.record.level.index.enable")
+ )
+ // tests b/w compatibility of configs for global RLI
+ def testRLIUpsertRecordKIndexWriteConfigVariants(recordIndexWriteConfigToEnable: String): Unit = {
+ testRLIUpsert(HoodieTableType.COPY_ON_WRITE, HoodieIndex.IndexType.GLOBAL_RECORD_LEVEL_INDEX.name(), recordIndexWriteConfigToEnable)
+ }
+
+ private def testRLIUpsert(tableType: HoodieTableType, indexType: String,
+ recordIndexWriteConfigToEnable : String = HoodieMetadataConfig.GLOBAL_RECORD_LEVEL_INDEX_ENABLE_PROP.key()): Unit = {
+ val hudiOpts = commonOpts + (DataSourceWriteOptions.TABLE_TYPE.key -> tableType.name()) +
+ (HoodieIndexConfig.INDEX_TYPE.key -> indexType) + (recordIndexWriteConfigToEnable -> "true")
doWriteAndValidateDataAndRecordIndex(hudiOpts,
operation = DataSourceWriteOptions.INSERT_OPERATION_OPT_VAL,
saveMode = SaveMode.Overwrite)
@@ -288,7 +315,7 @@ class TestRecordLevelIndex extends RecordLevelIndexTestBase {
@EnumSource(classOf[HoodieTableType])
def testRLIForDeletesWithHoodieIsDeletedColumn(tableType: HoodieTableType): Unit = {
val hudiOpts = commonOpts + (DataSourceWriteOptions.TABLE_TYPE.key -> tableType.name()) +
- (HoodieIndexConfig.INDEX_TYPE.key -> "RECORD_INDEX") +
+ (HoodieIndexConfig.INDEX_TYPE.key -> HoodieIndex.IndexType.GLOBAL_RECORD_LEVEL_INDEX.name()) +
(HoodieIndexConfig.RECORD_INDEX_UPDATE_PARTITION_PATH_ENABLE.key -> "true")
val insertDf = doWriteAndValidateDataAndRecordIndex(hudiOpts,
operation = DataSourceWriteOptions.INSERT_OPERATION_OPT_VAL,
@@ -324,7 +351,7 @@ class TestRecordLevelIndex extends RecordLevelIndexTestBase {
@EnumSource(classOf[HoodieTableType])
def testRLIForDeletesWithCommitTimeOrdering(tableType: HoodieTableType): Unit = {
val hudiOpts = commonOpts + (DataSourceWriteOptions.TABLE_TYPE.key -> tableType.name()) +
- (HoodieIndexConfig.INDEX_TYPE.key -> "RECORD_INDEX") +
+ (HoodieIndexConfig.INDEX_TYPE.key -> HoodieIndex.IndexType.GLOBAL_RECORD_LEVEL_INDEX.name()) +
(HoodieIndexConfig.RECORD_INDEX_UPDATE_PARTITION_PATH_ENABLE.key -> "true") +
(HoodieTableConfig.ORDERING_FIELDS.key -> "")
val insertDf = doWriteAndValidateDataAndRecordIndex(hudiOpts,
@@ -589,7 +616,7 @@ class TestRecordLevelIndex extends RecordLevelIndexTestBase {
operation = DataSourceWriteOptions.UPSERT_OPERATION_OPT_VAL,
saveMode = SaveMode.Append)
- hudiOpts += (HoodieMetadataConfig.RECORD_INDEX_ENABLE_PROP.key -> "false")
+ hudiOpts += (HoodieMetadataConfig.GLOBAL_RECORD_LEVEL_INDEX_ENABLE_PROP.key -> "false")
metaClient.getTableConfig.setMetadataPartitionState(metaClient, MetadataPartitionType.RECORD_INDEX.getPartitionPath, false)
doWriteAndValidateDataAndRecordIndex(hudiOpts,
@@ -605,7 +632,7 @@ class TestRecordLevelIndex extends RecordLevelIndexTestBase {
assertTrue(e.getMessage.contains("Record index is not initialized in MDT"))
}
- hudiOpts += (HoodieMetadataConfig.RECORD_INDEX_ENABLE_PROP.key -> "true")
+ hudiOpts += (HoodieMetadataConfig.GLOBAL_RECORD_LEVEL_INDEX_ENABLE_PROP.key -> "true")
doWriteAndValidateDataAndRecordIndex(hudiOpts,
operation = DataSourceWriteOptions.UPSERT_OPERATION_OPT_VAL,
saveMode = SaveMode.Append)
@@ -735,7 +762,7 @@ class TestRecordLevelIndex extends RecordLevelIndexTestBase {
}
}
-object TestRecordLevelIndex {
+object TestGlobalRecordLevelIndex {
def testEnableDisableRLIParams(): java.util.stream.Stream[Arguments] = {
java.util.stream.Stream.of(
diff --git a/hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/hudi/functional/TestRecordLevelIndexTableVersionSix.scala b/hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/hudi/functional/TestGlobalRecordLevelIndexTableVersionSix.scala
similarity index 93%
rename from hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/hudi/functional/TestRecordLevelIndexTableVersionSix.scala
rename to hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/hudi/functional/TestGlobalRecordLevelIndexTableVersionSix.scala
index 87782f6c9132..1b12bd99645b 100644
--- a/hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/hudi/functional/TestRecordLevelIndexTableVersionSix.scala
+++ b/hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/hudi/functional/TestGlobalRecordLevelIndexTableVersionSix.scala
@@ -24,7 +24,7 @@ import org.apache.hudi.config.HoodieWriteConfig
import org.junit.jupiter.api.Tag
@Tag("functional-b")
-class TestRecordLevelIndexTableVersionSix extends TestRecordLevelIndex {
+class TestGlobalRecordLevelIndexTableVersionSix extends TestGlobalRecordLevelIndex {
override def commonOpts: Map[String, String] = super.commonOpts ++ Map(
HoodieTableConfig.VERSION.key() -> "6",
HoodieWriteConfig.WRITE_TABLE_VERSION.key() -> "6"
diff --git a/hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/hudi/functional/TestRecordLevelIndexWithSQL.scala b/hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/hudi/functional/TestGlobalRecordLevelIndexWithSQL.scala
similarity index 99%
rename from hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/hudi/functional/TestRecordLevelIndexWithSQL.scala
rename to hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/hudi/functional/TestGlobalRecordLevelIndexWithSQL.scala
index 131da859edd0..78a3d74b6767 100644
--- a/hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/hudi/functional/TestRecordLevelIndexWithSQL.scala
+++ b/hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/hudi/functional/TestGlobalRecordLevelIndexWithSQL.scala
@@ -43,7 +43,7 @@ import java.util.Properties
import scala.util.Using
@Tag("functional")
-class TestRecordLevelIndexWithSQL extends RecordLevelIndexTestBase {
+class TestGlobalRecordLevelIndexWithSQL extends RecordLevelIndexTestBase {
val sqlTempTable = "tbl"
@ParameterizedTest
@@ -52,7 +52,7 @@ class TestRecordLevelIndexWithSQL extends RecordLevelIndexTestBase {
val hudiOpts = commonOpts ++ Map(
DataSourceWriteOptions.TABLE_TYPE.key -> HoodieTableType.MERGE_ON_READ.name(),
"hoodie.metadata.index.column.stats.enable" -> "false",
- HoodieMetadataConfig.RECORD_INDEX_ENABLE_PROP.key -> "false")
+ HoodieMetadataConfig.GLOBAL_RECORD_LEVEL_INDEX_ENABLE_PROP.key -> "false")
spark.sql("set hoodie.write.lock.provider = org.apache.hudi.client.transaction.lock.InProcessLockProvider")
doWriteAndValidateDataAndRecordIndex(hudiOpts,
diff --git a/hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/hudi/functional/TestMORDataSource.scala b/hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/hudi/functional/TestMORDataSource.scala
index 39179e966222..f98344df2d96 100644
--- a/hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/hudi/functional/TestMORDataSource.scala
+++ b/hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/hudi/functional/TestMORDataSource.scala
@@ -1629,7 +1629,7 @@ class TestMORDataSource extends HoodieSparkClientTestBase with SparkDatasetMixin
DataSourceWriteOptions.TABLE_TYPE.key -> DataSourceWriteOptions.MOR_TABLE_TYPE_OPT_VAL,
HoodieCompactionConfig.INLINE_COMPACT.key -> "false",
HoodieCompactionConfig.PARQUET_SMALL_FILE_LIMIT.key -> "0",
- HoodieMetadataConfig.RECORD_INDEX_ENABLE_PROP.key -> "true",
+ HoodieMetadataConfig.GLOBAL_RECORD_LEVEL_INDEX_ENABLE_PROP.key -> "true",
HoodieIndexConfig.INDEX_TYPE.key -> IndexType.RECORD_INDEX.name()
)
readOpts = readOpts ++ Map(
@@ -1710,7 +1710,7 @@ class TestMORDataSource extends HoodieSparkClientTestBase with SparkDatasetMixin
DataSourceWriteOptions.TABLE_TYPE.key -> DataSourceWriteOptions.MOR_TABLE_TYPE_OPT_VAL,
HoodieCompactionConfig.INLINE_COMPACT.key -> "false",
HoodieCompactionConfig.PARQUET_SMALL_FILE_LIMIT.key -> "0",
- HoodieMetadataConfig.RECORD_INDEX_ENABLE_PROP.key -> "true",
+ HoodieMetadataConfig.GLOBAL_RECORD_LEVEL_INDEX_ENABLE_PROP.key -> "true",
HoodieIndexConfig.INDEX_TYPE.key -> IndexType.RECORD_INDEX.name()
)
readOpts = readOpts ++ Map(
diff --git a/hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/hudi/functional/TestMetadataRecordIndex.scala b/hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/hudi/functional/TestMetadataRecordIndex.scala
index 331f306ba473..9806ca93ec93 100644
--- a/hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/hudi/functional/TestMetadataRecordIndex.scala
+++ b/hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/hudi/functional/TestMetadataRecordIndex.scala
@@ -48,7 +48,7 @@ class TestMetadataRecordIndex extends HoodieSparkClientTestBase {
var instantTime: AtomicInteger = _
val metadataOpts = Map(
HoodieMetadataConfig.ENABLE.key -> "true",
- HoodieMetadataConfig.RECORD_INDEX_ENABLE_PROP.key -> "true"
+ HoodieMetadataConfig.GLOBAL_RECORD_LEVEL_INDEX_ENABLE_PROP.key -> "true"
)
val commonOpts = Map(
"hoodie.insert.shuffle.parallelism" -> "4",
diff --git a/hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/hudi/functional/TestPartitionStatsIndex.scala b/hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/hudi/functional/TestPartitionStatsIndex.scala
index 1d9362769158..8b4ac6c5a3b1 100644
--- a/hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/hudi/functional/TestPartitionStatsIndex.scala
+++ b/hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/hudi/functional/TestPartitionStatsIndex.scala
@@ -393,7 +393,7 @@ class TestPartitionStatsIndex extends PartitionStatsIndexTestBase {
DataSourceWriteOptions.TABLE_TYPE.key -> HoodieTableType.MERGE_ON_READ.name(),
HoodieMetadataConfig.ENABLE.key -> "true",
HoodieMetadataConfig.ENABLE_METADATA_INDEX_COLUMN_STATS.key -> "true",
- HoodieMetadataConfig.RECORD_INDEX_ENABLE_PROP.key -> "true")
+ HoodieMetadataConfig.GLOBAL_RECORD_LEVEL_INDEX_ENABLE_PROP.key -> "true")
// First ingest.
doWriteAndValidateDataAndPartitionStats(
diff --git a/hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/hudi/functional/TestPartitionedRecordLevelIndex.scala b/hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/hudi/functional/TestPartitionedRecordLevelIndex.scala
deleted file mode 100644
index 184239c6d06a..000000000000
--- a/hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/hudi/functional/TestPartitionedRecordLevelIndex.scala
+++ /dev/null
@@ -1,494 +0,0 @@
-/*
- * 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.hudi.functional
-
-import org.apache.hudi.{DataSourceWriteOptions, SparkDatasetMixin}
-import org.apache.hudi.DataSourceWriteOptions._
-import org.apache.hudi.client.SparkRDDWriteClient
-import org.apache.hudi.client.common.HoodieSparkEngineContext
-import org.apache.hudi.common.config.{HoodieMetadataConfig, TypedProperties}
-import org.apache.hudi.common.data.HoodieListData
-import org.apache.hudi.common.fs.FSUtils
-import org.apache.hudi.common.model.{HoodieRecord, HoodieRecordGlobalLocation, HoodieTableType}
-import org.apache.hudi.common.table.{HoodieTableConfig, HoodieTableMetaClient, TableSchemaResolver}
-import org.apache.hudi.common.testutils.{HoodieTestDataGenerator, InProcessTimeGenerator}
-import org.apache.hudi.common.testutils.HoodieTestDataGenerator.recordsToStrings
-import org.apache.hudi.common.util.{Option => HOption}
-import org.apache.hudi.config.{HoodieCompactionConfig, HoodieIndexConfig, HoodieWriteConfig}
-import org.apache.hudi.functional.TestPartitionedRecordLevelIndex.TestPartitionedRecordLevelIndexTestCase
-import org.apache.hudi.index.HoodieIndex.IndexType.PARTITIONED_RECORD_INDEX
-import org.apache.hudi.index.record.HoodieRecordIndex
-import org.apache.hudi.metadata.{HoodieBackedTableMetadata, HoodieTableMetadataUtil}
-import org.apache.hudi.storage.StoragePath
-import org.apache.hudi.table.action.compact.strategy.UnBoundedCompactionStrategy
-
-import org.apache.spark.sql.{Row, SaveMode}
-import org.apache.spark.sql.functions.lit
-import org.junit.jupiter.api.Assertions.{assertEquals, assertFalse, assertTrue, fail}
-import org.junit.jupiter.api.Tag
-import org.junit.jupiter.params.ParameterizedTest
-import org.junit.jupiter.params.provider.{Arguments, EnumSource, MethodSource, ValueSource}
-
-import java.util
-import java.util.stream.Collectors
-
-import scala.collection.JavaConverters
-import scala.collection.JavaConverters._
-
-@Tag("functional")
-class TestPartitionedRecordLevelIndex extends RecordLevelIndexTestBase with SparkDatasetMixin {
- private class testPartitionedRecordLevelIndexHolder {
- var bulkRecordKeys: java.util.List[String] = null
- var options: Map[String, String] = null
- var recordKeys: java.util.List[String] = null
- var newRecordKeys: java.util.List[String] = null
- }
-
- def testPartitionedRecordLevelIndex(tableType: HoodieTableType, streamingWriteEnabled: Boolean, holder: testPartitionedRecordLevelIndexHolder): Unit = {
- val dataGen = new HoodieTestDataGenerator();
- val inserts = dataGen.generateInserts("001", 5)
- val latestBatchDf = toDataset(spark, inserts)
- val insertDf = latestBatchDf.withColumn("data_partition_path", lit("partition1")).union(latestBatchDf.withColumn("data_partition_path", lit("partition2")))
- val options = Map(HoodieWriteConfig.TBL_NAME.key -> "hoodie_test",
- DataSourceWriteOptions.TABLE_TYPE.key -> tableType.name(),
- RECORDKEY_FIELD.key -> "_row_key",
- PARTITIONPATH_FIELD.key -> "data_partition_path",
- HoodieTableConfig.ORDERING_FIELDS.key -> "timestamp",
- HoodieMetadataConfig.RECORD_INDEX_ENABLE_PROP.key()-> "false",
- HoodieMetadataConfig.PARTITIONED_RECORD_INDEX_ENABLE_PROP.key() -> "true",
- HoodieMetadataConfig.STREAMING_WRITE_ENABLED.key() -> streamingWriteEnabled.toString,
- HoodieCompactionConfig.INLINE_COMPACT.key() -> "false",
- HoodieIndexConfig.INDEX_TYPE.key() -> PARTITIONED_RECORD_INDEX.name())
- holder.options = options
- insertDf.write.format("hudi")
- .options(options)
- .mode(SaveMode.Overwrite)
- .save(basePath)
- assertEquals(10, spark.read.format("hudi").load(basePath).count())
- val props = TypedProperties.fromMap(JavaConverters.mapAsJavaMapConverter(options).asJava)
- val writeConfig = HoodieWriteConfig.newBuilder()
- .withProps(props)
- .withPath(basePath)
- .build()
- var metadata = metadataWriter(writeConfig).getTableMetadata
- val recordKeys = inserts.asScala.map(i => i.getRecordKey).asJava.stream().collect(Collectors.toList())
- holder.recordKeys = recordKeys
- var partition1Locations = readRecordIndex(metadata, recordKeys, HOption.of("partition1"))
- assertEquals(5, partition1Locations.size)
- var partition2Locations = readRecordIndex(metadata, recordKeys, HOption.of("partition2"))
- assertEquals(5, partition2Locations.size)
- var df = spark.read.format("hudi").load(basePath).collect()
- validateDFWithLocations(df, partition1Locations, "partition1")
- validateDFWithLocations(df, partition2Locations, "partition2")
-
- val newDeletes = dataGen.generateUpdates("004", 1)
- val updates = dataGen.generateUniqueUpdates("002", 3)
- val lowerOrderingValue = 1L
- updates.addAll(dataGen.generateUniqueDeleteRecords("002", 2, lowerOrderingValue))
- val nextBatchDf = toDataset(spark, updates)
- val updateDf = nextBatchDf.withColumn("data_partition_path", lit("partition1"))
-
- updateDf.write.format("hudi")
- .options(options)
- .option(DataSourceWriteOptions.OPERATION.key(), UPSERT_OPERATION_OPT_VAL)
- .mode(SaveMode.Append)
- .save(basePath)
- assertEquals(10, spark.read.format("hudi").load(basePath).count())
- partition1Locations = readRecordIndex(metadata, recordKeys, HOption.of("partition1"))
- assertEquals(5, partition1Locations.size)
- partition2Locations = readRecordIndex(metadata, recordKeys, HOption.of("partition2"))
- assertEquals(5, partition2Locations.size)
- df = spark.read.format("hudi").load(basePath).collect()
- validateDFWithLocations(df, partition1Locations, "partition1")
- validateDFWithLocations(df, partition2Locations, "partition2")
-
- val newInserts = dataGen.generateInserts("003", 3)
- val newInsertBatchDf = toDataset(spark, newInserts)
- val newInsertDf = newInsertBatchDf.withColumn("data_partition_path", lit("partition2")).union(newInsertBatchDf.withColumn("data_partition_path", lit("partition3")))
- newInsertDf.write.format("hudi")
- .options(options)
- .option(DataSourceWriteOptions.OPERATION.key(), UPSERT_OPERATION_OPT_VAL)
- .mode(SaveMode.Append)
- .save(basePath)
- assertEquals(16, spark.read.format("hudi").load(basePath).count())
- metadata = metadataWriter(writeConfig).getTableMetadata
- partition1Locations = readRecordIndex(metadata, recordKeys, HOption.of("partition1"))
- assertEquals(5, partition1Locations.size)
- partition2Locations = readRecordIndex(metadata, recordKeys, HOption.of("partition2"))
- assertEquals(5, partition2Locations.size)
- df = spark.read.format("hudi").load(basePath).collect()
- validateDFWithLocations(df, partition1Locations, "partition1")
- validateDFWithLocations(df, partition2Locations, "partition2")
-
- val newRecordKeys = newInserts.asScala.map(i => i.getRecordKey).asJava.stream().collect(Collectors.toList())
- holder.newRecordKeys = newRecordKeys
- partition1Locations = readRecordIndex(metadata, newRecordKeys, HOption.of("partition1"))
- assertEquals(0, partition1Locations.size)
- partition2Locations = readRecordIndex(metadata, newRecordKeys, HOption.of("partition2"))
- assertEquals(3, partition2Locations.size)
- var partition3Locations = readRecordIndex(metadata, newRecordKeys, HOption.of("partition3"))
- assertEquals(3, partition3Locations.size)
- validateDFWithLocations(df, partition3Locations, "partition3")
-
- val newDeletesBatchDf = toDataset(spark, newDeletes)
- val newDeletesDf = newDeletesBatchDf.withColumn("data_partition_path", lit("partition1"))
- newDeletesDf.write.format("hudi")
- .options(options)
- .option(DataSourceWriteOptions.OPERATION.key(), DELETE_OPERATION_OPT_VAL)
- .mode(SaveMode.Append)
- .save(basePath)
- assertEquals(15, spark.read.format("hudi").load(basePath).count())
- metadata = metadataWriter(writeConfig).getTableMetadata
- partition1Locations = readRecordIndex(metadata, recordKeys, HOption.of("partition1"))
- assertEquals(4, partition1Locations.size)
- partition2Locations = readRecordIndex(metadata, recordKeys, HOption.of("partition2"))
- assertEquals(5, partition2Locations.size)
- df = spark.read.format("hudi").load(basePath).collect()
- validateDFWithLocations(df, partition1Locations, "partition1")
- validateDFWithLocations(df, partition2Locations, "partition2")
-
- assertFalse(partition1Locations.contains(newDeletes.get(0).getRecordKey))
- assertTrue(partition2Locations.contains(newDeletes.get(0).getRecordKey))
- partition1Locations = readRecordIndex(metadata, newRecordKeys, HOption.of("partition1"))
- assertEquals(0, partition1Locations.size)
- partition2Locations = readRecordIndex(metadata, newRecordKeys, HOption.of("partition2"))
- assertEquals(3, partition2Locations.size)
- partition3Locations = readRecordIndex(metadata, newRecordKeys, HOption.of("partition3"))
- assertEquals(3, partition3Locations.size)
- validateDFWithLocations(df, partition2Locations, "partition2")
- validateDFWithLocations(df, partition3Locations, "partition3")
-
- val bulkInserts = dataGen.generateInserts("005", 5)
- val bulkInsertDf = toDataset(spark, bulkInserts)
- val bulkInsertPartitionedDf = bulkInsertDf.withColumn("data_partition_path", lit("partition0"))
-
- // Use bulk_insert operation explicitly
- bulkInsertPartitionedDf.write.format("hudi")
- .options(options)
- .option(DataSourceWriteOptions.OPERATION.key(), DataSourceWriteOptions.BULK_INSERT_OPERATION_OPT_VAL)
- .mode(SaveMode.Append)
- .save(basePath)
-
- val bulkRecordKeys = bulkInserts.asScala.map(_.getRecordKey).asJava
- holder.bulkRecordKeys = bulkRecordKeys
- metadata = metadataWriter(writeConfig).getTableMetadata
- val partition0Locations = readRecordIndex(metadata, bulkRecordKeys, HOption.of("partition0"))
- assertEquals(5, partition0Locations.size)
- df = spark.read.format("hudi").load(basePath).collect()
- validateDFWithLocations(df, partition0Locations, "partition0")
-
- metaClient = HoodieTableMetaClient.reload(metaClient)
- assertTrue(HoodieRecordIndex.isPartitioned(metaClient.getIndexMetadata.get().getIndexDefinitions.get(HoodieTableMetadataUtil.PARTITION_NAME_RECORD_INDEX)))
- }
-
- @ParameterizedTest
- @MethodSource(Array("testArgsForPartitionedRecordLevelIndex"))
- def testPartitionedRecordLevelIndexRollback(testCase: TestPartitionedRecordLevelIndexTestCase): Unit = {
- val holder = new testPartitionedRecordLevelIndexHolder
- testPartitionedRecordLevelIndex(testCase.tableType, testCase.streamingWriteEnabled, holder)
- val writeConfig = getWriteConfig(holder.options)
- new SparkRDDWriteClient(new HoodieSparkEngineContext(jsc), writeConfig)
- .rollback(metaClient.getActiveTimeline.lastInstant().get().requestedTime())
- val metadata = metadataWriter(writeConfig).getTableMetadata
- try {
- val partition0Locations = readRecordIndex(metadata, holder.bulkRecordKeys, HOption.of("partition0"))
- fail("rollback happened, so partition should be deleted")
- } catch {
- case t: Throwable => assertTrue(t.isInstanceOf[ArithmeticException])
- }
- }
-
- @ParameterizedTest
- @ValueSource(booleans = Array(true, false))
- def testPartitionedRecordLevelIndexCompact(streamingWriteEnabled: Boolean): Unit = {
- val holder = new testPartitionedRecordLevelIndexHolder
- testPartitionedRecordLevelIndex(HoodieTableType.MERGE_ON_READ, streamingWriteEnabled, holder)
- assertEquals("deltacommit", metaClient.getActiveTimeline.lastInstant().get().getAction)
- val writeConfig = getWriteConfig(holder.options)
- var metadata = metadataWriter(writeConfig).getTableMetadata
- doAllAssertions(holder, metadata)
- val writeClient = new SparkRDDWriteClient(new HoodieSparkEngineContext(jsc), writeConfig)
- val timeOpt = writeClient.scheduleCompaction(HOption.empty())
- assertTrue(timeOpt.isPresent)
- writeClient.compact(timeOpt.get())
- metaClient.reloadActiveTimeline()
- assertEquals("compaction", metaClient.getActiveTimeline.lastInstant().get().getAction)
- metadata = metadataWriter(writeConfig).getTableMetadata
- doAllAssertions(holder, metadata)
- }
-
- @ParameterizedTest
- @MethodSource(Array("testArgsForPartitionedRecordLevelIndex"))
- def testPartitionedRecordLevelIndexCluster(testCase: TestPartitionedRecordLevelIndexTestCase): Unit = {
- val holder = new testPartitionedRecordLevelIndexHolder
- testPartitionedRecordLevelIndex(testCase.tableType, testCase.streamingWriteEnabled, holder)
- assertEquals(if (testCase.tableType.equals(HoodieTableType.MERGE_ON_READ)) "deltacommit" else "commit",
- metaClient.getActiveTimeline.lastInstant().get().getAction)
- val writeConfig = getWriteConfig(holder.options ++ Map(HoodieWriteConfig.AVRO_SCHEMA_STRING.key() -> HoodieTestDataGenerator.AVRO_SCHEMA.toString))
- var metadata = metadataWriter(writeConfig).getTableMetadata
- doAllAssertions(holder, metadata)
- val writeClient = new SparkRDDWriteClient(new HoodieSparkEngineContext(jsc), writeConfig)
- val timeOpt = writeClient.scheduleClustering(HOption.empty())
- assertTrue(timeOpt.isPresent)
- writeClient.cluster(timeOpt.get())
- metaClient.reloadActiveTimeline()
- assertEquals("replacecommit", metaClient.getActiveTimeline.lastInstant().get().getAction)
- metadata = metadataWriter(writeConfig).getTableMetadata
- doAllAssertions(holder, metadata)
- }
-
- private def validateDFWithLocations(df: Array[Row], locations: Map[String, HoodieRecordGlobalLocation],
- partition: String): Unit = {
- var count: Int = 0
- for (row <- df) {
- val recordKey = row.getString(2)
- locations.get(recordKey).foreach { loc =>
- if (partition == row.getString(3)) {
- count += 1
- assertEquals(row.getString(3), loc.getPartitionPath)
- assertEquals(FSUtils.getFileId(row.getString(4)), loc.getFileId)
- }
- }
- }
- assertEquals(locations.size, count)
- }
-
- private def doAllAssertions(holder: testPartitionedRecordLevelIndexHolder, metadata: HoodieBackedTableMetadata): Unit = {
- val df = spark.read.format("hudi").load(basePath).collect()
- var partition0Locations = readRecordIndex(metadata, holder.recordKeys, HOption.of("partition0"))
- assertEquals(0, partition0Locations.size)
- var partition1Locations = readRecordIndex(metadata, holder.recordKeys, HOption.of("partition1"))
- assertEquals(4, partition1Locations.size)
- validateDFWithLocations(df, partition1Locations, "partition1")
- var partition2Locations = readRecordIndex(metadata, holder.recordKeys, HOption.of("partition2"))
- assertEquals(5, partition2Locations.size)
- validateDFWithLocations(df, partition2Locations, "partition2")
- var partition3Locations = readRecordIndex(metadata, holder.recordKeys, HOption.of("partition3"))
- assertEquals(0, partition3Locations.size)
-
- partition0Locations = readRecordIndex(metadata, holder.newRecordKeys, HOption.of("partition0"))
- assertEquals(0, partition0Locations.size)
- partition1Locations = readRecordIndex(metadata, holder.newRecordKeys, HOption.of("partition1"))
- assertEquals(0, partition1Locations.size)
- partition2Locations = readRecordIndex(metadata, holder.newRecordKeys, HOption.of("partition2"))
- assertEquals(3, partition2Locations.size)
- validateDFWithLocations(df, partition2Locations, "partition2")
- partition3Locations = readRecordIndex(metadata, holder.newRecordKeys, HOption.of("partition3"))
- assertEquals(3, partition3Locations.size)
- validateDFWithLocations(df, partition3Locations, "partition3")
-
- partition0Locations = readRecordIndex(metadata, holder.bulkRecordKeys, HOption.of("partition0"))
- assertEquals(5, partition0Locations.size)
- validateDFWithLocations(df, partition0Locations, "partition0")
- partition1Locations = readRecordIndex(metadata, holder.bulkRecordKeys, HOption.of("partition1"))
- assertEquals(0, partition1Locations.size)
- partition2Locations = readRecordIndex(metadata, holder.bulkRecordKeys, HOption.of("partition2"))
- assertEquals(0, partition2Locations.size)
- partition3Locations = readRecordIndex(metadata, holder.bulkRecordKeys, HOption.of("partition3"))
- assertEquals(0, partition3Locations.size)
- }
-
- @ParameterizedTest
- @MethodSource(Array("testArgsForPartitionedRecordLevelIndex"))
- def testPartitionedRecordLevelIndexInitializationBasic(testCase: TestPartitionedRecordLevelIndexTestCase): Unit = {
- testPartitionedRecordLevelIndexInitialization(testCase.tableType, testCase.streamingWriteEnabled, failAndDoRollback = false, compact = false, cluster = false)
- }
-
- @ParameterizedTest
- @MethodSource(Array("testArgsForPartitionedRecordLevelIndex"))
- def testPartitionedRecordLevelIndexInitializationRollback(testCase: TestPartitionedRecordLevelIndexTestCase): Unit = {
- testPartitionedRecordLevelIndexInitialization(testCase.tableType, testCase.streamingWriteEnabled, failAndDoRollback = true, compact = false, cluster = false)
- }
-
- @ParameterizedTest
- @ValueSource(booleans = Array(true, false))
- def testPartitionedRecordLevelIndexInitializationCompact(streamingWriteEnabled: Boolean): Unit = {
- testPartitionedRecordLevelIndexInitialization(HoodieTableType.MERGE_ON_READ, streamingWriteEnabled, failAndDoRollback = false, compact = true, cluster = false)
- }
-
- @ParameterizedTest
- @MethodSource(Array("testArgsForPartitionedRecordLevelIndex"))
- def testPartitionedRecordLevelIndexInitializationCluster(testCase: TestPartitionedRecordLevelIndexTestCase): Unit = {
- testPartitionedRecordLevelIndexInitialization(testCase.tableType, testCase.streamingWriteEnabled, failAndDoRollback = false, compact = false, cluster = true)
- }
-
- def testPartitionedRecordLevelIndexInitialization(tableType: HoodieTableType,
- streamingWriteEnabled: Boolean,
- failAndDoRollback: Boolean,
- compact: Boolean,
- cluster: Boolean): Unit = {
- initMetaClient(tableType)
- val dataGen = new HoodieTestDataGenerator()
- val inserts = dataGen.generateInserts("001", 5)
- val latestBatchDf = toDataset(spark, inserts)
- val insertDf = latestBatchDf.withColumn("data_partition_path", lit("partition1")).union(latestBatchDf.withColumn("data_partition_path", lit("partition2")))
- val options = Map(HoodieWriteConfig.TBL_NAME.key -> "hoodie_test",
- DataSourceWriteOptions.TABLE_TYPE.key -> tableType.name(),
- RECORDKEY_FIELD.key -> "_row_key",
- PARTITIONPATH_FIELD.key -> "data_partition_path",
- HoodieTableConfig.ORDERING_FIELDS.key -> "timestamp",
- HoodieMetadataConfig.RECORD_INDEX_ENABLE_PROP.key()-> "false",
- HoodieMetadataConfig.SECONDARY_INDEX_ENABLE_PROP.key() -> "false",
- HoodieMetadataConfig.STREAMING_WRITE_ENABLED.key() -> streamingWriteEnabled.toString,
- HoodieCompactionConfig.INLINE_COMPACT.key() -> "false",
- HoodieIndexConfig.INDEX_TYPE.key() -> PARTITIONED_RECORD_INDEX.name())
- insertDf.write.format("hudi")
- .options(options)
- .mode(SaveMode.Overwrite)
- .save(basePath)
-
- assertEquals(10, spark.read.format("hudi").load(basePath).count())
-
- val updates = dataGen.generateUniqueUpdates("002", 3)
- val nextBatchDf = toDataset(spark, updates)
- val updateDf = nextBatchDf.withColumn("data_partition_path", lit("partition1"))
- updateDf.write.format("hudi")
- .options(options)
- .option(DataSourceWriteOptions.OPERATION.key(), UPSERT_OPERATION_OPT_VAL)
- .mode(SaveMode.Append)
- .save(basePath)
- assertEquals(10, spark.read.format("hudi").load(basePath).count())
- metaClient.reloadActiveTimeline()
- val tableSchemaResolver = new TableSchemaResolver(metaClient)
- val latestTableSchemaFromCommitMetadata = tableSchemaResolver.getTableAvroSchemaFromLatestCommit(false)
-
- if (failAndDoRollback) {
- val updatesToFail = dataGen.generateUniqueUpdates("003", 3)
- val batchToFailDf = toDataset(spark, updatesToFail)
- val failDf = batchToFailDf.withColumn("data_partition_path", lit("partition1")).union(batchToFailDf.withColumn("data_partition_path", lit("partition3")))
- failDf.write.format("hudi")
- .options(options)
- .option(DataSourceWriteOptions.OPERATION.key(), UPSERT_OPERATION_OPT_VAL)
- .mode(SaveMode.Append)
- .save(basePath)
- assertEquals(13, spark.read.format("hudi").load(basePath).count())
-
- metaClient.reloadActiveTimeline()
- val lastInstant = metaClient.getActiveTimeline.lastInstant().get()
- assertTrue(storage.deleteFile(new StoragePath(metaClient.getTimelinePath, metaClient.getInstantFileNameGenerator.getFileName(lastInstant))))
- assertEquals(10, spark.read.format("hudi").load(basePath).count())
-
- // rollback
- val writeConfig = HoodieWriteConfig.newBuilder()
- .withProps(TypedProperties.fromMap(JavaConverters
- .mapAsJavaMapConverter(options ++ Map(HoodieWriteConfig.AVRO_SCHEMA_STRING.key() -> latestTableSchemaFromCommitMetadata.get().toString)).asJava))
- .withPath(basePath)
- .build()
- new SparkRDDWriteClient(new HoodieSparkEngineContext(jsc), writeConfig)
- .rollback(lastInstant.requestedTime())
- }
-
- if (compact) {
- assertEquals("deltacommit", metaClient.getActiveTimeline.lastInstant().get().getAction)
- val writeConfig = getWriteConfig(options ++
- Map(HoodieCompactionConfig.COMPACTION_STRATEGY.key() -> classOf[UnBoundedCompactionStrategy].getName,
- HoodieCompactionConfig.INLINE_COMPACT_NUM_DELTA_COMMITS.key() -> "1"))
- val writeClient = new SparkRDDWriteClient(new HoodieSparkEngineContext(jsc), writeConfig)
- val timeOpt = writeClient.scheduleCompaction(HOption.empty())
- assertTrue(timeOpt.isPresent)
- writeClient.compact(timeOpt.get())
- metaClient.reloadActiveTimeline()
- assertEquals("compaction", metaClient.getActiveTimeline.lastInstant().get().getAction)
- }
-
- if (cluster) {
- assertEquals(if (tableType.equals(HoodieTableType.MERGE_ON_READ)) "deltacommit" else "commit",
- metaClient.getActiveTimeline.lastInstant().get().getAction)
- val writeConfig = getWriteConfig(options ++ Map(HoodieWriteConfig.AVRO_SCHEMA_STRING.key() -> HoodieTestDataGenerator.AVRO_SCHEMA.toString))
- val writeClient = new SparkRDDWriteClient(new HoodieSparkEngineContext(jsc), writeConfig)
- val timeOpt = writeClient.scheduleClustering(HOption.empty())
- assertTrue(timeOpt.isPresent)
- writeClient.cluster(timeOpt.get())
- metaClient.reloadActiveTimeline()
- assertEquals("replacecommit", metaClient.getActiveTimeline.lastInstant().get().getAction)
- }
-
- //init mdt
- val updateOptions = options ++ Map(HoodieMetadataConfig.PARTITIONED_RECORD_INDEX_ENABLE_PROP.key() -> "true",
- HoodieWriteConfig.AVRO_SCHEMA_STRING.key() -> latestTableSchemaFromCommitMetadata.get().toString)
- val props = TypedProperties.fromMap(JavaConverters.mapAsJavaMapConverter(updateOptions).asJava)
- val writeConfig = HoodieWriteConfig.newBuilder()
- .withProps(props)
- .withPath(basePath)
- .build()
- val metadata = metadataWriter(writeConfig).getTableMetadata
- val recordKeys = inserts.asScala.map(i => i.getRecordKey).asJava.stream().collect(Collectors.toList())
- val partition1Locations = readRecordIndex(metadata, recordKeys, HOption.of("partition1"))
- assertEquals(5, partition1Locations.size)
- val partition2Locations = readRecordIndex(metadata, recordKeys, HOption.of("partition2"))
- assertEquals(5, partition2Locations.size)
- val df = spark.read.format("hudi").load(basePath).collect()
- validateDFWithLocations(df, partition1Locations, "partition1")
- validateDFWithLocations(df, partition2Locations, "partition2")
-
- metaClient = HoodieTableMetaClient.reload(metaClient)
- assertTrue(HoodieRecordIndex.isPartitioned(metaClient.getIndexMetadata.get().getIndexDefinitions.get(HoodieTableMetadataUtil.PARTITION_NAME_RECORD_INDEX)))
- }
-
- def readRecordIndex(metadata: HoodieBackedTableMetadata, recordKeys: java.util.List[String], dataTablePartition: HOption[String]): Map[String, HoodieRecordGlobalLocation] = {
- metadata.readRecordIndexLocationsWithKeys(HoodieListData.eager(recordKeys), dataTablePartition)
- .collectAsList().asScala.map(p => p.getKey -> p.getValue).toMap
- }
-
- @ParameterizedTest
- @EnumSource(classOf[HoodieTableType])
- def testRLIForDeletesWithHoodieIsDeletedColumn(tableType: HoodieTableType): Unit = {
- val hudiOpts = commonOpts + (DataSourceWriteOptions.TABLE_TYPE.key -> tableType.name()) +
- (HoodieIndexConfig.INDEX_TYPE.key -> "RECORD_INDEX") +
- (HoodieIndexConfig.RECORD_INDEX_UPDATE_PARTITION_PATH_ENABLE.key -> "false")
- val insertDf = doWriteAndValidateDataAndRecordIndex(hudiOpts,
- operation = DataSourceWriteOptions.INSERT_OPERATION_OPT_VAL,
- saveMode = SaveMode.Overwrite)
- insertDf.cache()
-
- val instantTime = InProcessTimeGenerator.createNewInstantTime()
- // Issue two deletes, where one has an older ordering value that should be ignored
- val deletedRecords = dataGen.generateUniqueDeleteRecords(instantTime, 1)
- val inputRecords = new util.ArrayList[HoodieRecord[_]](deletedRecords)
- val lowerOrderingValue = 1L
- inputRecords.addAll(dataGen.generateUniqueDeleteRecords(instantTime, 1, lowerOrderingValue))
- val deleteBatch = recordsToStrings(inputRecords).asScala
- val deleteDf = spark.read.json(spark.sparkContext.parallelize(deleteBatch.toSeq, 1))
- deleteDf.cache()
- val recordKeyToDelete = deleteDf.collectAsList().get(0).getAs("_row_key").asInstanceOf[String]
- deleteDf.write.format("hudi")
- .options(hudiOpts)
- .mode(SaveMode.Append)
- .save(basePath)
- val prevDf = mergedDfList.last
- mergedDfList = mergedDfList :+ prevDf.filter(row => row.getAs("_row_key").asInstanceOf[String] != recordKeyToDelete)
- validateDataAndRecordIndices(hudiOpts, spark.read.json(spark.sparkContext.parallelize(recordsToStrings(deletedRecords).asScala.toSeq, 1)))
- deleteDf.unpersist()
- }
-}
-
-object TestPartitionedRecordLevelIndex {
-
- case class TestPartitionedRecordLevelIndexTestCase(tableType: HoodieTableType, streamingWriteEnabled: Boolean)
-
- def testArgsForPartitionedRecordLevelIndex: java.util.stream.Stream[Arguments] = {
- java.util.stream.Stream.of(
- Arguments.arguments(TestPartitionedRecordLevelIndexTestCase(HoodieTableType.COPY_ON_WRITE, streamingWriteEnabled = true)),
- Arguments.arguments(TestPartitionedRecordLevelIndexTestCase(HoodieTableType.COPY_ON_WRITE, streamingWriteEnabled = false)),
- Arguments.arguments(TestPartitionedRecordLevelIndexTestCase(HoodieTableType.MERGE_ON_READ, streamingWriteEnabled = true)),
- Arguments.arguments(TestPartitionedRecordLevelIndexTestCase(HoodieTableType.MERGE_ON_READ, streamingWriteEnabled = false))
- )
- }
-}
diff --git a/hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/hudi/functional/TestRecordLevelIndex.scala b/hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/hudi/functional/TestRecordLevelIndex.scala
index a6b857952437..76685bf7f42b 100644
--- a/hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/hudi/functional/TestRecordLevelIndex.scala
+++ b/hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/hudi/functional/TestRecordLevelIndex.scala
@@ -7,281 +7,444 @@
* "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
+ * 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.
+ * 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.hudi.functional
-import org.apache.hudi.DataSourceWriteOptions
+import org.apache.hudi.{DataSourceWriteOptions, SparkDatasetMixin}
import org.apache.hudi.DataSourceWriteOptions._
import org.apache.hudi.client.SparkRDDWriteClient
import org.apache.hudi.client.common.HoodieSparkEngineContext
-import org.apache.hudi.client.transaction.PreferWriterConflictResolutionStrategy
-import org.apache.hudi.common.config.HoodieMetadataConfig
-import org.apache.hudi.common.model._
-import org.apache.hudi.common.table.{HoodieTableConfig, HoodieTableMetaClient}
-import org.apache.hudi.common.table.timeline.{HoodieInstant, HoodieTimeline}
+import org.apache.hudi.common.config.{HoodieMetadataConfig, TypedProperties}
+import org.apache.hudi.common.data.HoodieListData
+import org.apache.hudi.common.fs.FSUtils
+import org.apache.hudi.common.model.{HoodieRecord, HoodieRecordGlobalLocation, HoodieTableType}
+import org.apache.hudi.common.table.{HoodieTableConfig, HoodieTableMetaClient, TableSchemaResolver}
import org.apache.hudi.common.testutils.{HoodieTestDataGenerator, InProcessTimeGenerator}
import org.apache.hudi.common.testutils.HoodieTestDataGenerator.recordsToStrings
-import org.apache.hudi.config._
-import org.apache.hudi.exception.HoodieWriteConflictException
+import org.apache.hudi.common.util.{Option => HOption}
+import org.apache.hudi.config.{HoodieCompactionConfig, HoodieIndexConfig, HoodieWriteConfig}
+import org.apache.hudi.functional.TestRecordLevelIndex.TestPartitionedRecordLevelIndexTestCase
+import org.apache.hudi.index.HoodieIndex.IndexType.RECORD_LEVEL_INDEX
import org.apache.hudi.index.record.HoodieRecordIndex
-import org.apache.hudi.metadata.{HoodieBackedTableMetadata, HoodieTableMetadataUtil, MetadataPartitionType}
-import org.apache.hudi.util.JavaConversions
+import org.apache.hudi.metadata.{HoodieBackedTableMetadata, HoodieTableMetadataUtil}
+import org.apache.hudi.storage.StoragePath
+import org.apache.hudi.table.action.compact.strategy.UnBoundedCompactionStrategy
-import org.apache.spark.sql._
-import org.apache.spark.sql.catalyst.expressions.GenericRowWithSchema
+import org.apache.spark.sql.{Row, SaveMode}
import org.apache.spark.sql.functions.lit
-import org.apache.spark.sql.types.{StringType, StructField, StructType}
-import org.junit.jupiter.api._
-import org.junit.jupiter.api.Assertions.{assertEquals, assertFalse, assertTrue}
+import org.junit.jupiter.api.Assertions.{assertEquals, assertFalse, assertTrue, fail}
+import org.junit.jupiter.api.Tag
import org.junit.jupiter.params.ParameterizedTest
-import org.junit.jupiter.params.provider.{Arguments, CsvSource, EnumSource, MethodSource}
-import org.junit.jupiter.params.provider.Arguments.arguments
+import org.junit.jupiter.params.provider.{Arguments, EnumSource, MethodSource, ValueSource}
import java.util
-import java.util.{Collections, Properties}
-import java.util.concurrent.Executors
+import java.util.stream.Collectors
+import scala.collection.JavaConverters
import scala.collection.JavaConverters._
-import scala.concurrent.{Await, ExecutionContext, Future}
-import scala.concurrent.duration.Duration
-import scala.language.postfixOps
-import scala.util.Using
-@Tag("functional-b")
-class TestRecordLevelIndex extends RecordLevelIndexTestBase {
-
- @ParameterizedTest
- @EnumSource(classOf[HoodieTableType])
- def testRLIInitialization(tableType: HoodieTableType): Unit = {
- val hudiOpts = commonOpts + (DataSourceWriteOptions.TABLE_TYPE.key -> tableType.name())
- doWriteAndValidateDataAndRecordIndex(hudiOpts,
- operation = DataSourceWriteOptions.INSERT_OPERATION_OPT_VAL,
- saveMode = SaveMode.Overwrite)
- metaClient = HoodieTableMetaClient.reload(metaClient)
- assertFalse(HoodieRecordIndex.isPartitioned(metaClient.getIndexMetadata.get().getIndexDefinitions.get(HoodieTableMetadataUtil.PARTITION_NAME_RECORD_INDEX)))
+@Tag("functional")
+class TestRecordLevelIndex extends RecordLevelIndexTestBase with SparkDatasetMixin {
+ private class testRecordLevelIndexHolder {
+ var bulkRecordKeys: java.util.List[String] = null
+ var options: Map[String, String] = null
+ var recordKeys: java.util.List[String] = null
+ var newRecordKeys: java.util.List[String] = null
}
- @Test
- def testRLIInitializationForMorGlobalIndex(): Unit = {
- val tableType = HoodieTableType.MERGE_ON_READ
- val hudiOpts = commonOpts + (DataSourceWriteOptions.TABLE_TYPE.key -> tableType.name()) +
- (HoodieMetadataConfig.RECORD_INDEX_MIN_FILE_GROUP_COUNT_PROP.key -> "1") +
- (HoodieMetadataConfig.RECORD_INDEX_MAX_FILE_GROUP_COUNT_PROP.key -> "1") +
- (HoodieIndexConfig.INDEX_TYPE.key -> "RECORD_INDEX") +
- (HoodieIndexConfig.RECORD_INDEX_UPDATE_PARTITION_PATH_ENABLE.key -> "true") -
- HoodieMetadataConfig.RECORD_INDEX_ENABLE_PROP.key
-
- val dataGen1 = HoodieTestDataGenerator.createTestGeneratorFirstPartition()
- val dataGen2 = HoodieTestDataGenerator.createTestGeneratorSecondPartition()
-
- // batch1 inserts (5 records)
- val instantTime1 = getNewInstantTime()
- val latestBatch = recordsToStrings(dataGen1.generateInserts(instantTime1, 5)).asScala.toSeq
- var operation = INSERT_OPERATION_OPT_VAL
- val latestBatchDf = spark.read.json(spark.sparkContext.parallelize(latestBatch, 1))
- latestBatchDf.cache()
- latestBatchDf.write.format("hudi")
- .options(hudiOpts)
+ def testRecordLevelIndex(tableType: HoodieTableType, streamingWriteEnabled: Boolean, holder: testRecordLevelIndexHolder): Unit = {
+ val dataGen = new HoodieTestDataGenerator();
+ val inserts = dataGen.generateInserts("001", 5)
+ val latestBatchDf = toDataset(spark, inserts)
+ val insertDf = latestBatchDf.withColumn("data_partition_path", lit("partition1")).union(latestBatchDf.withColumn("data_partition_path", lit("partition2")))
+ val options = Map(HoodieWriteConfig.TBL_NAME.key -> "hoodie_test",
+ DataSourceWriteOptions.TABLE_TYPE.key -> tableType.name(),
+ RECORDKEY_FIELD.key -> "_row_key",
+ PARTITIONPATH_FIELD.key -> "data_partition_path",
+ HoodieTableConfig.ORDERING_FIELDS.key -> "timestamp",
+ HoodieMetadataConfig.GLOBAL_RECORD_LEVEL_INDEX_ENABLE_PROP.key()-> "false",
+ HoodieMetadataConfig.RECORD_LEVEL_INDEX_ENABLE_PROP.key() -> "true",
+ HoodieMetadataConfig.STREAMING_WRITE_ENABLED.key() -> streamingWriteEnabled.toString,
+ HoodieCompactionConfig.INLINE_COMPACT.key() -> "false",
+ HoodieIndexConfig.INDEX_TYPE.key() -> RECORD_LEVEL_INDEX.name())
+ holder.options = options
+ insertDf.write.format("hudi")
+ .options(options)
.mode(SaveMode.Overwrite)
.save(basePath)
- val deletedDf1 = calculateMergedDf(latestBatchDf, operation, true)
- deletedDf1.cache()
-
- // batch2. upsert. update few records to 2nd partition from partition1 and insert a few to partition2.
- val instantTime2 = getNewInstantTime()
-
- val latestBatch2_1 = recordsToStrings(dataGen1.generateUniqueUpdates(instantTime2, 3)).asScala.toSeq
- val latestBatchDf2_1 = spark.read.json(spark.sparkContext.parallelize(latestBatch2_1, 1))
- val latestBatchDf2_2 = latestBatchDf2_1.withColumn("partition", lit(HoodieTestDataGenerator.DEFAULT_SECOND_PARTITION_PATH))
- .withColumn("partition_path", lit(HoodieTestDataGenerator.DEFAULT_SECOND_PARTITION_PATH))
- val latestBatch2_3 = recordsToStrings(dataGen2.generateInserts(instantTime2, 2)).asScala.toSeq
- val latestBatchDf2_3 = spark.read.json(spark.sparkContext.parallelize(latestBatch2_3, 1))
- val latestBatchDf2Final = latestBatchDf2_3.union(latestBatchDf2_2)
- latestBatchDf2Final.cache()
- latestBatchDf2Final.write.format("hudi")
- .options(hudiOpts)
+ assertEquals(10, spark.read.format("hudi").load(basePath).count())
+ val props = TypedProperties.fromMap(JavaConverters.mapAsJavaMapConverter(options).asJava)
+ val writeConfig = HoodieWriteConfig.newBuilder()
+ .withProps(props)
+ .withPath(basePath)
+ .build()
+ var metadata = metadataWriter(writeConfig).getTableMetadata
+ val recordKeys = inserts.asScala.map(i => i.getRecordKey).asJava.stream().collect(Collectors.toList())
+ holder.recordKeys = recordKeys
+ var partition1Locations = readRecordIndex(metadata, recordKeys, HOption.of("partition1"))
+ assertEquals(5, partition1Locations.size)
+ var partition2Locations = readRecordIndex(metadata, recordKeys, HOption.of("partition2"))
+ assertEquals(5, partition2Locations.size)
+ var df = spark.read.format("hudi").load(basePath).collect()
+ validateDFWithLocations(df, partition1Locations, "partition1")
+ validateDFWithLocations(df, partition2Locations, "partition2")
+
+ val newDeletes = dataGen.generateUpdates("004", 1)
+ val updates = dataGen.generateUniqueUpdates("002", 3)
+ val lowerOrderingValue = 1L
+ updates.addAll(dataGen.generateUniqueDeleteRecords("002", 2, lowerOrderingValue))
+ val nextBatchDf = toDataset(spark, updates)
+ val updateDf = nextBatchDf.withColumn("data_partition_path", lit("partition1"))
+
+ updateDf.write.format("hudi")
+ .options(options)
+ .option(DataSourceWriteOptions.OPERATION.key(), UPSERT_OPERATION_OPT_VAL)
.mode(SaveMode.Append)
.save(basePath)
- operation = UPSERT_OPERATION_OPT_VAL
- val deletedDf2 = calculateMergedDf(latestBatchDf2Final, operation, true)
- deletedDf2.cache()
-
- val hudiOpts2 = commonOpts + (DataSourceWriteOptions.TABLE_TYPE.key -> tableType.name()) +
- (HoodieMetadataConfig.RECORD_INDEX_MIN_FILE_GROUP_COUNT_PROP.key -> "1") +
- (HoodieMetadataConfig.RECORD_INDEX_MAX_FILE_GROUP_COUNT_PROP.key -> "1") +
- (HoodieIndexConfig.INDEX_TYPE.key -> "RECORD_INDEX") +
- (HoodieIndexConfig.RECORD_INDEX_UPDATE_PARTITION_PATH_ENABLE.key -> "true") +
- (HoodieMetadataConfig.RECORD_INDEX_ENABLE_PROP.key -> "true")
-
- val instantTime3 = getNewInstantTime()
- // batch3. update 2 records from newly inserted records from commit 2 to partition2
- val latestBatch3 = recordsToStrings(dataGen2.generateUniqueUpdates(instantTime3, 2)).asScala.toSeq
- val latestBatchDf3 = spark.read.json(spark.sparkContext.parallelize(latestBatch3, 1))
- latestBatchDf3.cache()
- latestBatchDf3.write.format("hudi")
- .options(hudiOpts2)
+ assertEquals(10, spark.read.format("hudi").load(basePath).count())
+ partition1Locations = readRecordIndex(metadata, recordKeys, HOption.of("partition1"))
+ assertEquals(5, partition1Locations.size)
+ partition2Locations = readRecordIndex(metadata, recordKeys, HOption.of("partition2"))
+ assertEquals(5, partition2Locations.size)
+ df = spark.read.format("hudi").load(basePath).collect()
+ validateDFWithLocations(df, partition1Locations, "partition1")
+ validateDFWithLocations(df, partition2Locations, "partition2")
+
+ val newInserts = dataGen.generateInserts("003", 3)
+ val newInsertBatchDf = toDataset(spark, newInserts)
+ val newInsertDf = newInsertBatchDf.withColumn("data_partition_path", lit("partition2")).union(newInsertBatchDf.withColumn("data_partition_path", lit("partition3")))
+ newInsertDf.write.format("hudi")
+ .options(options)
+ .option(DataSourceWriteOptions.OPERATION.key(), UPSERT_OPERATION_OPT_VAL)
.mode(SaveMode.Append)
.save(basePath)
- val deletedDf3 = calculateMergedDf(latestBatchDf3, operation, true)
- deletedDf3.cache()
- metaClient = HoodieTableMetaClient.builder().setBasePath(basePath).setConf(storageConf).build()
- validateDataAndRecordIndices(hudiOpts, deletedDf3)
- deletedDf2.unpersist()
- deletedDf3.unpersist()
- }
+ assertEquals(16, spark.read.format("hudi").load(basePath).count())
+ metadata = metadataWriter(writeConfig).getTableMetadata
+ partition1Locations = readRecordIndex(metadata, recordKeys, HOption.of("partition1"))
+ assertEquals(5, partition1Locations.size)
+ partition2Locations = readRecordIndex(metadata, recordKeys, HOption.of("partition2"))
+ assertEquals(5, partition2Locations.size)
+ df = spark.read.format("hudi").load(basePath).collect()
+ validateDFWithLocations(df, partition1Locations, "partition1")
+ validateDFWithLocations(df, partition2Locations, "partition2")
+
+ val newRecordKeys = newInserts.asScala.map(i => i.getRecordKey).asJava.stream().collect(Collectors.toList())
+ holder.newRecordKeys = newRecordKeys
+ partition1Locations = readRecordIndex(metadata, newRecordKeys, HOption.of("partition1"))
+ assertEquals(0, partition1Locations.size)
+ partition2Locations = readRecordIndex(metadata, newRecordKeys, HOption.of("partition2"))
+ assertEquals(3, partition2Locations.size)
+ var partition3Locations = readRecordIndex(metadata, newRecordKeys, HOption.of("partition3"))
+ assertEquals(3, partition3Locations.size)
+ validateDFWithLocations(df, partition3Locations, "partition3")
+
+ val newDeletesBatchDf = toDataset(spark, newDeletes)
+ val newDeletesDf = newDeletesBatchDf.withColumn("data_partition_path", lit("partition1"))
+ newDeletesDf.write.format("hudi")
+ .options(options)
+ .option(DataSourceWriteOptions.OPERATION.key(), DELETE_OPERATION_OPT_VAL)
+ .mode(SaveMode.Append)
+ .save(basePath)
+ assertEquals(15, spark.read.format("hudi").load(basePath).count())
+ metadata = metadataWriter(writeConfig).getTableMetadata
+ partition1Locations = readRecordIndex(metadata, recordKeys, HOption.of("partition1"))
+ assertEquals(4, partition1Locations.size)
+ partition2Locations = readRecordIndex(metadata, recordKeys, HOption.of("partition2"))
+ assertEquals(5, partition2Locations.size)
+ df = spark.read.format("hudi").load(basePath).collect()
+ validateDFWithLocations(df, partition1Locations, "partition1")
+ validateDFWithLocations(df, partition2Locations, "partition2")
+
+ assertFalse(partition1Locations.contains(newDeletes.get(0).getRecordKey))
+ assertTrue(partition2Locations.contains(newDeletes.get(0).getRecordKey))
+ partition1Locations = readRecordIndex(metadata, newRecordKeys, HOption.of("partition1"))
+ assertEquals(0, partition1Locations.size)
+ partition2Locations = readRecordIndex(metadata, newRecordKeys, HOption.of("partition2"))
+ assertEquals(3, partition2Locations.size)
+ partition3Locations = readRecordIndex(metadata, newRecordKeys, HOption.of("partition3"))
+ assertEquals(3, partition3Locations.size)
+ validateDFWithLocations(df, partition2Locations, "partition2")
+ validateDFWithLocations(df, partition3Locations, "partition3")
+
+ val bulkInserts = dataGen.generateInserts("005", 5)
+ val bulkInsertDf = toDataset(spark, bulkInserts)
+ val bulkInsertPartitionedDf = bulkInsertDf.withColumn("data_partition_path", lit("partition0"))
+
+ // Use bulk_insert operation explicitly
+ bulkInsertPartitionedDf.write.format("hudi")
+ .options(options)
+ .option(DataSourceWriteOptions.OPERATION.key(), DataSourceWriteOptions.BULK_INSERT_OPERATION_OPT_VAL)
+ .mode(SaveMode.Append)
+ .save(basePath)
+
+ val bulkRecordKeys = bulkInserts.asScala.map(_.getRecordKey).asJava
+ holder.bulkRecordKeys = bulkRecordKeys
+ metadata = metadataWriter(writeConfig).getTableMetadata
+ val partition0Locations = readRecordIndex(metadata, bulkRecordKeys, HOption.of("partition0"))
+ assertEquals(5, partition0Locations.size)
+ df = spark.read.format("hudi").load(basePath).collect()
+ validateDFWithLocations(df, partition0Locations, "partition0")
- private def getNewInstantTime(): String = {
- InProcessTimeGenerator.createNewInstantTime();
+ metaClient = HoodieTableMetaClient.reload(metaClient)
+ assertTrue(HoodieRecordIndex.isPartitioned(metaClient.getIndexMetadata.get().getIndexDefinitions.get(HoodieTableMetadataUtil.PARTITION_NAME_RECORD_INDEX)))
}
@ParameterizedTest
- @EnumSource(classOf[HoodieTableType])
- def testRLIUpsert(tableType: HoodieTableType): Unit = {
- val hudiOpts = commonOpts + (DataSourceWriteOptions.TABLE_TYPE.key -> tableType.name())
- doWriteAndValidateDataAndRecordIndex(hudiOpts,
- operation = DataSourceWriteOptions.INSERT_OPERATION_OPT_VAL,
- saveMode = SaveMode.Overwrite)
- doWriteAndValidateDataAndRecordIndex(hudiOpts,
- operation = DataSourceWriteOptions.UPSERT_OPERATION_OPT_VAL,
- saveMode = SaveMode.Append)
+ @MethodSource(Array("testArgsForPartitionedRecordLevelIndex"))
+ def testPartitionedRecordLevelIndexRollback(testCase: TestPartitionedRecordLevelIndexTestCase): Unit = {
+ val holder = new testRecordLevelIndexHolder
+ testRecordLevelIndex(testCase.tableType, testCase.streamingWriteEnabled, holder)
+ val writeConfig = getWriteConfig(holder.options)
+ new SparkRDDWriteClient(new HoodieSparkEngineContext(jsc), writeConfig)
+ .rollback(metaClient.getActiveTimeline.lastInstant().get().requestedTime())
+ val metadata = metadataWriter(writeConfig).getTableMetadata
+ try {
+ val partition0Locations = readRecordIndex(metadata, holder.bulkRecordKeys, HOption.of("partition0"))
+ fail("rollback happened, so partition should be deleted")
+ } catch {
+ case t: Throwable => assertTrue(t.isInstanceOf[ArithmeticException])
+ }
}
@ParameterizedTest
- @EnumSource(classOf[HoodieTableType])
- def testRLIUpsertNonPartitioned(tableType: HoodieTableType): Unit = {
- val hudiOpts = commonOpts - PARTITIONPATH_FIELD.key + (DataSourceWriteOptions.TABLE_TYPE.key -> tableType.name())
- doWriteAndValidateDataAndRecordIndex(hudiOpts,
- operation = DataSourceWriteOptions.INSERT_OPERATION_OPT_VAL,
- saveMode = SaveMode.Overwrite)
- doWriteAndValidateDataAndRecordIndex(hudiOpts,
- operation = DataSourceWriteOptions.UPSERT_OPERATION_OPT_VAL,
- saveMode = SaveMode.Append)
+ @ValueSource(booleans = Array(true, false))
+ def testPartitionedRecordLevelIndexCompact(streamingWriteEnabled: Boolean): Unit = {
+ val holder = new testRecordLevelIndexHolder
+ testRecordLevelIndex(HoodieTableType.MERGE_ON_READ, streamingWriteEnabled, holder)
+ assertEquals("deltacommit", metaClient.getActiveTimeline.lastInstant().get().getAction)
+ val writeConfig = getWriteConfig(holder.options)
+ var metadata = metadataWriter(writeConfig).getTableMetadata
+ doAllAssertions(holder, metadata)
+ val writeClient = new SparkRDDWriteClient(new HoodieSparkEngineContext(jsc), writeConfig)
+ val timeOpt = writeClient.scheduleCompaction(HOption.empty())
+ assertTrue(timeOpt.isPresent)
+ writeClient.compact(timeOpt.get())
+ metaClient.reloadActiveTimeline()
+ assertEquals("compaction", metaClient.getActiveTimeline.lastInstant().get().getAction)
+ metadata = metadataWriter(writeConfig).getTableMetadata
+ doAllAssertions(holder, metadata)
}
@ParameterizedTest
- @CsvSource(Array("COPY_ON_WRITE,true", "COPY_ON_WRITE,false", "MERGE_ON_READ,true", "MERGE_ON_READ,false"))
- def testRLIBulkInsertThenInsertOverwrite(tableType: HoodieTableType, enableRowWriter: Boolean): Unit = {
- val hudiOpts = commonOpts ++ Map(
- DataSourceWriteOptions.TABLE_TYPE.key -> tableType.name(),
- DataSourceWriteOptions.ENABLE_ROW_WRITER.key -> enableRowWriter.toString
- )
- doWriteAndValidateDataAndRecordIndex(hudiOpts,
- operation = DataSourceWriteOptions.BULK_INSERT_OPERATION_OPT_VAL,
- saveMode = SaveMode.Overwrite)
- doWriteAndValidateDataAndRecordIndex(hudiOpts,
- operation = DataSourceWriteOptions.BULK_INSERT_OPERATION_OPT_VAL,
- saveMode = SaveMode.Append)
- doWriteAndValidateDataAndRecordIndex(hudiOpts,
- operation = DataSourceWriteOptions.INSERT_OVERWRITE_OPERATION_OPT_VAL,
- saveMode = SaveMode.Append)
- doWriteAndValidateDataAndRecordIndex(hudiOpts,
- operation = DataSourceWriteOptions.INSERT_OVERWRITE_TABLE_OPERATION_OPT_VAL,
- saveMode = SaveMode.Append)
+ @MethodSource(Array("testArgsForPartitionedRecordLevelIndex"))
+ def testPartitionedRecordLevelIndexCluster(testCase: TestPartitionedRecordLevelIndexTestCase): Unit = {
+ val holder = new testRecordLevelIndexHolder
+ testRecordLevelIndex(testCase.tableType, testCase.streamingWriteEnabled, holder)
+ assertEquals(if (testCase.tableType.equals(HoodieTableType.MERGE_ON_READ)) "deltacommit" else "commit",
+ metaClient.getActiveTimeline.lastInstant().get().getAction)
+ val writeConfig = getWriteConfig(holder.options ++ Map(HoodieWriteConfig.AVRO_SCHEMA_STRING.key() -> HoodieTestDataGenerator.AVRO_SCHEMA.toString))
+ var metadata = metadataWriter(writeConfig).getTableMetadata
+ doAllAssertions(holder, metadata)
+ val writeClient = new SparkRDDWriteClient(new HoodieSparkEngineContext(jsc), writeConfig)
+ val timeOpt = writeClient.scheduleClustering(HOption.empty())
+ assertTrue(timeOpt.isPresent)
+ writeClient.cluster(timeOpt.get())
+ metaClient.reloadActiveTimeline()
+ assertEquals("replacecommit", metaClient.getActiveTimeline.lastInstant().get().getAction)
+ metadata = metadataWriter(writeConfig).getTableMetadata
+ doAllAssertions(holder, metadata)
}
- @ParameterizedTest
- @EnumSource(classOf[HoodieTableType])
- def testRLIUpsertAndRollback(tableType: HoodieTableType): Unit = {
- val hudiOpts = commonOpts + (DataSourceWriteOptions.TABLE_TYPE.key -> tableType.name())
- doWriteAndValidateDataAndRecordIndex(hudiOpts,
- operation = DataSourceWriteOptions.INSERT_OPERATION_OPT_VAL,
- saveMode = SaveMode.Overwrite)
- doWriteAndValidateDataAndRecordIndex(hudiOpts,
- operation = DataSourceWriteOptions.UPSERT_OPERATION_OPT_VAL,
- saveMode = SaveMode.Append)
- doWriteAndValidateDataAndRecordIndex(hudiOpts,
- operation = DataSourceWriteOptions.UPSERT_OPERATION_OPT_VAL,
- saveMode = SaveMode.Append)
- rollbackLastInstant(hudiOpts)
- validateDataAndRecordIndices(hudiOpts)
+ private def validateDFWithLocations(df: Array[Row], locations: Map[String, HoodieRecordGlobalLocation],
+ partition: String): Unit = {
+ var count: Int = 0
+ for (row <- df) {
+ val recordKey = row.getString(2)
+ locations.get(recordKey).foreach { loc =>
+ if (partition == row.getString(3)) {
+ count += 1
+ assertEquals(row.getString(3), loc.getPartitionPath)
+ assertEquals(FSUtils.getFileId(row.getString(4)), loc.getFileId)
+ }
+ }
+ }
+ assertEquals(locations.size, count)
}
- @ParameterizedTest
- @EnumSource(classOf[HoodieTableType])
- def testRLIPartiallyFailedUpsertAndRollback(tableType: HoodieTableType): Unit = {
- val hudiOpts = commonOpts + (DataSourceWriteOptions.TABLE_TYPE.key -> tableType.name())
- doWriteAndValidateDataAndRecordIndex(hudiOpts,
- operation = DataSourceWriteOptions.INSERT_OPERATION_OPT_VAL,
- saveMode = SaveMode.Overwrite)
- doWriteAndValidateDataAndRecordIndex(hudiOpts,
- operation = DataSourceWriteOptions.UPSERT_OPERATION_OPT_VAL,
- saveMode = SaveMode.Append)
+ private def doAllAssertions(holder: testRecordLevelIndexHolder, metadata: HoodieBackedTableMetadata): Unit = {
+ val df = spark.read.format("hudi").load(basePath).collect()
+ var partition0Locations = readRecordIndex(metadata, holder.recordKeys, HOption.of("partition0"))
+ assertEquals(0, partition0Locations.size)
+ var partition1Locations = readRecordIndex(metadata, holder.recordKeys, HOption.of("partition1"))
+ assertEquals(4, partition1Locations.size)
+ validateDFWithLocations(df, partition1Locations, "partition1")
+ var partition2Locations = readRecordIndex(metadata, holder.recordKeys, HOption.of("partition2"))
+ assertEquals(5, partition2Locations.size)
+ validateDFWithLocations(df, partition2Locations, "partition2")
+ var partition3Locations = readRecordIndex(metadata, holder.recordKeys, HOption.of("partition3"))
+ assertEquals(0, partition3Locations.size)
+
+ partition0Locations = readRecordIndex(metadata, holder.newRecordKeys, HOption.of("partition0"))
+ assertEquals(0, partition0Locations.size)
+ partition1Locations = readRecordIndex(metadata, holder.newRecordKeys, HOption.of("partition1"))
+ assertEquals(0, partition1Locations.size)
+ partition2Locations = readRecordIndex(metadata, holder.newRecordKeys, HOption.of("partition2"))
+ assertEquals(3, partition2Locations.size)
+ validateDFWithLocations(df, partition2Locations, "partition2")
+ partition3Locations = readRecordIndex(metadata, holder.newRecordKeys, HOption.of("partition3"))
+ assertEquals(3, partition3Locations.size)
+ validateDFWithLocations(df, partition3Locations, "partition3")
+
+ partition0Locations = readRecordIndex(metadata, holder.bulkRecordKeys, HOption.of("partition0"))
+ assertEquals(5, partition0Locations.size)
+ validateDFWithLocations(df, partition0Locations, "partition0")
+ partition1Locations = readRecordIndex(metadata, holder.bulkRecordKeys, HOption.of("partition1"))
+ assertEquals(0, partition1Locations.size)
+ partition2Locations = readRecordIndex(metadata, holder.bulkRecordKeys, HOption.of("partition2"))
+ assertEquals(0, partition2Locations.size)
+ partition3Locations = readRecordIndex(metadata, holder.bulkRecordKeys, HOption.of("partition3"))
+ assertEquals(0, partition3Locations.size)
+ }
- deleteLastCompletedCommitFromTimeline(hudiOpts)
+ @ParameterizedTest
+ @MethodSource(Array("testArgsForPartitionedRecordLevelIndex"))
+ def testPartitionedRecordLevelIndexInitializationBasic(testCase: TestPartitionedRecordLevelIndexTestCase): Unit = {
+ testPartitionedRecordLevelIndexInitialization(testCase.tableType, testCase.streamingWriteEnabled, failAndDoRollback = false, compact = false, cluster = false)
+ }
- doWriteAndValidateDataAndRecordIndex(hudiOpts,
- operation = DataSourceWriteOptions.UPSERT_OPERATION_OPT_VAL,
- saveMode = SaveMode.Append)
+ @ParameterizedTest
+ @MethodSource(Array("testArgsForPartitionedRecordLevelIndex"))
+ def testPartitionedRecordLevelIndexInitializationRollback(testCase: TestPartitionedRecordLevelIndexTestCase): Unit = {
+ testPartitionedRecordLevelIndexInitialization(testCase.tableType, testCase.streamingWriteEnabled, failAndDoRollback = true, compact = false, cluster = false)
}
@ParameterizedTest
- @EnumSource(classOf[HoodieTableType])
- def testRLIPartiallyFailedMetadataTableCommitAndRollback(tableType: HoodieTableType): Unit = {
- val hudiOpts = commonOpts + (DataSourceWriteOptions.TABLE_TYPE.key -> tableType.name())
- doWriteAndValidateDataAndRecordIndex(hudiOpts,
- operation = DataSourceWriteOptions.INSERT_OPERATION_OPT_VAL,
- saveMode = SaveMode.Overwrite)
- doWriteAndValidateDataAndRecordIndex(hudiOpts,
- operation = DataSourceWriteOptions.UPSERT_OPERATION_OPT_VAL,
- saveMode = SaveMode.Append)
-
- deleteLastCompletedCommitFromDataAndMetadataTimeline(hudiOpts)
- doWriteAndValidateDataAndRecordIndex(hudiOpts,
- operation = DataSourceWriteOptions.UPSERT_OPERATION_OPT_VAL,
- saveMode = SaveMode.Append)
+ @ValueSource(booleans = Array(true, false))
+ def testPartitionedRecordLevelIndexInitializationCompact(streamingWriteEnabled: Boolean): Unit = {
+ testPartitionedRecordLevelIndexInitialization(HoodieTableType.MERGE_ON_READ, streamingWriteEnabled, failAndDoRollback = false, compact = true, cluster = false)
}
@ParameterizedTest
- @EnumSource(classOf[HoodieTableType])
- def testRLIWithDelete(tableType: HoodieTableType): Unit = {
- val hudiOpts = commonOpts + (DataSourceWriteOptions.TABLE_TYPE.key -> tableType.name())
- val props = new Properties()
- for ((k, v) <- hudiOpts) {
- props.put(k, v)
- }
- initMetaClient(tableType, props)
+ @MethodSource(Array("testArgsForPartitionedRecordLevelIndex"))
+ def testPartitionedRecordLevelIndexInitializationCluster(testCase: TestPartitionedRecordLevelIndexTestCase): Unit = {
+ testPartitionedRecordLevelIndexInitialization(testCase.tableType, testCase.streamingWriteEnabled, failAndDoRollback = false, compact = false, cluster = true)
+ }
- val insertDf = doWriteAndValidateDataAndRecordIndex(hudiOpts,
- operation = DataSourceWriteOptions.INSERT_OPERATION_OPT_VAL,
- saveMode = SaveMode.Overwrite)
- val deleteDf = insertDf.limit(1)
- deleteDf.write.format("hudi")
- .options(hudiOpts)
- .option(DataSourceWriteOptions.OPERATION.key, DELETE_OPERATION_OPT_VAL)
- .mode(SaveMode.Append)
+ def testPartitionedRecordLevelIndexInitialization(tableType: HoodieTableType,
+ streamingWriteEnabled: Boolean,
+ failAndDoRollback: Boolean,
+ compact: Boolean,
+ cluster: Boolean): Unit = {
+ initMetaClient(tableType)
+ val dataGen = new HoodieTestDataGenerator()
+ val inserts = dataGen.generateInserts("001", 5)
+ val latestBatchDf = toDataset(spark, inserts)
+ val insertDf = latestBatchDf.withColumn("data_partition_path", lit("partition1")).union(latestBatchDf.withColumn("data_partition_path", lit("partition2")))
+ val options = Map(HoodieWriteConfig.TBL_NAME.key -> "hoodie_test",
+ DataSourceWriteOptions.TABLE_TYPE.key -> tableType.name(),
+ RECORDKEY_FIELD.key -> "_row_key",
+ PARTITIONPATH_FIELD.key -> "data_partition_path",
+ HoodieTableConfig.ORDERING_FIELDS.key -> "timestamp",
+ HoodieMetadataConfig.GLOBAL_RECORD_LEVEL_INDEX_ENABLE_PROP.key()-> "false",
+ HoodieMetadataConfig.SECONDARY_INDEX_ENABLE_PROP.key() -> "false",
+ HoodieMetadataConfig.STREAMING_WRITE_ENABLED.key() -> streamingWriteEnabled.toString,
+ HoodieCompactionConfig.INLINE_COMPACT.key() -> "false",
+ HoodieIndexConfig.INDEX_TYPE.key() -> RECORD_LEVEL_INDEX.name())
+ insertDf.write.format("hudi")
+ .options(options)
+ .mode(SaveMode.Overwrite)
.save(basePath)
- val prevDf = mergedDfList.last
- mergedDfList = mergedDfList :+ prevDf.except(deleteDf)
- validateDataAndRecordIndices(hudiOpts, deleteDf)
- }
- @Test
- def testRLIWithEmptyPayload(): Unit = {
- val hudiOpts = commonOpts ++ Map(
- DataSourceWriteOptions.TABLE_TYPE.key -> HoodieTableType.MERGE_ON_READ.name(),
- HoodieWriteConfig.MERGE_SMALL_FILE_GROUP_CANDIDATES_LIMIT.key -> "0")
- val insertDf = doWriteAndValidateDataAndRecordIndex(hudiOpts,
- operation = DataSourceWriteOptions.INSERT_OPERATION_OPT_VAL,
- saveMode = SaveMode.Overwrite)
+ assertEquals(10, spark.read.format("hudi").load(basePath).count())
- val deleteDf = insertDf.limit(2)
- deleteDf.cache()
- deleteDf.write.format("hudi")
- .options(hudiOpts)
- .option(DataSourceWriteOptions.OPERATION.key(), DataSourceWriteOptions.DELETE_OPERATION_OPT_VAL)
+ val updates = dataGen.generateUniqueUpdates("002", 3)
+ val nextBatchDf = toDataset(spark, updates)
+ val updateDf = nextBatchDf.withColumn("data_partition_path", lit("partition1"))
+ updateDf.write.format("hudi")
+ .options(options)
+ .option(DataSourceWriteOptions.OPERATION.key(), UPSERT_OPERATION_OPT_VAL)
.mode(SaveMode.Append)
.save(basePath)
- val prevDf = mergedDfList.last
- mergedDfList = mergedDfList :+ prevDf.except(deleteDf)
- validateDataAndRecordIndices(hudiOpts, deleteDf)
+ assertEquals(10, spark.read.format("hudi").load(basePath).count())
+ metaClient.reloadActiveTimeline()
+ val tableSchemaResolver = new TableSchemaResolver(metaClient)
+ val latestTableSchemaFromCommitMetadata = tableSchemaResolver.getTableAvroSchemaFromLatestCommit(false)
+
+ if (failAndDoRollback) {
+ val updatesToFail = dataGen.generateUniqueUpdates("003", 3)
+ val batchToFailDf = toDataset(spark, updatesToFail)
+ val failDf = batchToFailDf.withColumn("data_partition_path", lit("partition1")).union(batchToFailDf.withColumn("data_partition_path", lit("partition3")))
+ failDf.write.format("hudi")
+ .options(options)
+ .option(DataSourceWriteOptions.OPERATION.key(), UPSERT_OPERATION_OPT_VAL)
+ .mode(SaveMode.Append)
+ .save(basePath)
+ assertEquals(13, spark.read.format("hudi").load(basePath).count())
+
+ metaClient.reloadActiveTimeline()
+ val lastInstant = metaClient.getActiveTimeline.lastInstant().get()
+ assertTrue(storage.deleteFile(new StoragePath(metaClient.getTimelinePath, metaClient.getInstantFileNameGenerator.getFileName(lastInstant))))
+ assertEquals(10, spark.read.format("hudi").load(basePath).count())
+
+ // rollback
+ val writeConfig = HoodieWriteConfig.newBuilder()
+ .withProps(TypedProperties.fromMap(JavaConverters
+ .mapAsJavaMapConverter(options ++ Map(HoodieWriteConfig.AVRO_SCHEMA_STRING.key() -> latestTableSchemaFromCommitMetadata.get().toString)).asJava))
+ .withPath(basePath)
+ .build()
+ new SparkRDDWriteClient(new HoodieSparkEngineContext(jsc), writeConfig)
+ .rollback(lastInstant.requestedTime())
+ }
+
+ if (compact) {
+ assertEquals("deltacommit", metaClient.getActiveTimeline.lastInstant().get().getAction)
+ val writeConfig = getWriteConfig(options ++
+ Map(HoodieCompactionConfig.COMPACTION_STRATEGY.key() -> classOf[UnBoundedCompactionStrategy].getName,
+ HoodieCompactionConfig.INLINE_COMPACT_NUM_DELTA_COMMITS.key() -> "1"))
+ val writeClient = new SparkRDDWriteClient(new HoodieSparkEngineContext(jsc), writeConfig)
+ val timeOpt = writeClient.scheduleCompaction(HOption.empty())
+ assertTrue(timeOpt.isPresent)
+ writeClient.compact(timeOpt.get())
+ metaClient.reloadActiveTimeline()
+ assertEquals("compaction", metaClient.getActiveTimeline.lastInstant().get().getAction)
+ }
+
+ if (cluster) {
+ assertEquals(if (tableType.equals(HoodieTableType.MERGE_ON_READ)) "deltacommit" else "commit",
+ metaClient.getActiveTimeline.lastInstant().get().getAction)
+ val writeConfig = getWriteConfig(options ++ Map(HoodieWriteConfig.AVRO_SCHEMA_STRING.key() -> HoodieTestDataGenerator.AVRO_SCHEMA.toString))
+ val writeClient = new SparkRDDWriteClient(new HoodieSparkEngineContext(jsc), writeConfig)
+ val timeOpt = writeClient.scheduleClustering(HOption.empty())
+ assertTrue(timeOpt.isPresent)
+ writeClient.cluster(timeOpt.get())
+ metaClient.reloadActiveTimeline()
+ assertEquals("replacecommit", metaClient.getActiveTimeline.lastInstant().get().getAction)
+ }
+
+ //init mdt
+ val updateOptions = options ++ Map(HoodieMetadataConfig.RECORD_LEVEL_INDEX_ENABLE_PROP.key() -> "true",
+ HoodieWriteConfig.AVRO_SCHEMA_STRING.key() -> latestTableSchemaFromCommitMetadata.get().toString)
+ val props = TypedProperties.fromMap(JavaConverters.mapAsJavaMapConverter(updateOptions).asJava)
+ val writeConfig = HoodieWriteConfig.newBuilder()
+ .withProps(props)
+ .withPath(basePath)
+ .build()
+ val metadata = metadataWriter(writeConfig).getTableMetadata
+ val recordKeys = inserts.asScala.map(i => i.getRecordKey).asJava.stream().collect(Collectors.toList())
+ val partition1Locations = readRecordIndex(metadata, recordKeys, HOption.of("partition1"))
+ assertEquals(5, partition1Locations.size)
+ val partition2Locations = readRecordIndex(metadata, recordKeys, HOption.of("partition2"))
+ assertEquals(5, partition2Locations.size)
+ val df = spark.read.format("hudi").load(basePath).collect()
+ validateDFWithLocations(df, partition1Locations, "partition1")
+ validateDFWithLocations(df, partition2Locations, "partition2")
+
+ metaClient = HoodieTableMetaClient.reload(metaClient)
+ assertTrue(HoodieRecordIndex.isPartitioned(metaClient.getIndexMetadata.get().getIndexDefinitions.get(HoodieTableMetadataUtil.PARTITION_NAME_RECORD_INDEX)))
+ }
+
+ def readRecordIndex(metadata: HoodieBackedTableMetadata, recordKeys: java.util.List[String], dataTablePartition: HOption[String]): Map[String, HoodieRecordGlobalLocation] = {
+ metadata.readRecordIndexLocationsWithKeys(HoodieListData.eager(recordKeys), dataTablePartition)
+ .collectAsList().asScala.map(p => p.getKey -> p.getValue).toMap
}
@ParameterizedTest
@@ -289,460 +452,43 @@ class TestRecordLevelIndex extends RecordLevelIndexTestBase {
def testRLIForDeletesWithHoodieIsDeletedColumn(tableType: HoodieTableType): Unit = {
val hudiOpts = commonOpts + (DataSourceWriteOptions.TABLE_TYPE.key -> tableType.name()) +
(HoodieIndexConfig.INDEX_TYPE.key -> "RECORD_INDEX") +
- (HoodieIndexConfig.RECORD_INDEX_UPDATE_PARTITION_PATH_ENABLE.key -> "true")
+ (HoodieIndexConfig.RECORD_INDEX_UPDATE_PARTITION_PATH_ENABLE.key -> "false")
val insertDf = doWriteAndValidateDataAndRecordIndex(hudiOpts,
operation = DataSourceWriteOptions.INSERT_OPERATION_OPT_VAL,
saveMode = SaveMode.Overwrite)
insertDf.cache()
- val instantTime = getNewInstantTime
- // Issue four deletes, one with the original partition, one with an updated partition,
- // and two with an older ordering value that should be ignored
+ val instantTime = InProcessTimeGenerator.createNewInstantTime()
+ // Issue two deletes, where one has an older ordering value that should be ignored
val deletedRecords = dataGen.generateUniqueDeleteRecords(instantTime, 1)
- deletedRecords.addAll(dataGen.generateUniqueDeleteRecordsWithUpdatedPartition(instantTime, 1))
val inputRecords = new util.ArrayList[HoodieRecord[_]](deletedRecords)
val lowerOrderingValue = 1L
inputRecords.addAll(dataGen.generateUniqueDeleteRecords(instantTime, 1, lowerOrderingValue))
- inputRecords.addAll(dataGen.generateUniqueDeleteRecordsWithUpdatedPartition(instantTime, 1, lowerOrderingValue))
val deleteBatch = recordsToStrings(inputRecords).asScala
val deleteDf = spark.read.json(spark.sparkContext.parallelize(deleteBatch.toSeq, 1))
deleteDf.cache()
- val recordKeyToDelete1 = deleteDf.collectAsList().get(0).getAs("_row_key").asInstanceOf[String]
- val recordKeyToDelete2 = deleteDf.collectAsList().get(1).getAs("_row_key").asInstanceOf[String]
+ val recordKeyToDelete = deleteDf.collectAsList().get(0).getAs("_row_key").asInstanceOf[String]
deleteDf.write.format("hudi")
.options(hudiOpts)
.mode(SaveMode.Append)
.save(basePath)
val prevDf = mergedDfList.last
- mergedDfList = mergedDfList :+ prevDf.filter(row => row.getAs("_row_key").asInstanceOf[String] != recordKeyToDelete1 &&
- row.getAs("_row_key").asInstanceOf[String] != recordKeyToDelete2)
+ mergedDfList = mergedDfList :+ prevDf.filter(row => row.getAs("_row_key").asInstanceOf[String] != recordKeyToDelete)
validateDataAndRecordIndices(hudiOpts, spark.read.json(spark.sparkContext.parallelize(recordsToStrings(deletedRecords).asScala.toSeq, 1)))
deleteDf.unpersist()
}
-
- @ParameterizedTest
- @EnumSource(classOf[HoodieTableType])
- def testRLIForDeletesWithCommitTimeOrdering(tableType: HoodieTableType): Unit = {
- val hudiOpts = commonOpts + (DataSourceWriteOptions.TABLE_TYPE.key -> tableType.name()) +
- (HoodieIndexConfig.INDEX_TYPE.key -> "RECORD_INDEX") +
- (HoodieIndexConfig.RECORD_INDEX_UPDATE_PARTITION_PATH_ENABLE.key -> "true") +
- (HoodieTableConfig.ORDERING_FIELDS.key -> "")
- val insertDf = doWriteAndValidateDataAndRecordIndex(hudiOpts,
- operation = DataSourceWriteOptions.INSERT_OPERATION_OPT_VAL,
- saveMode = SaveMode.Overwrite)
- insertDf.cache()
-
- val instantTime = getNewInstantTime
- val lowerOrderingValue = 1L
- // Issue two deletes, one with the original partition, one with an updated partition,
- // Both have an older ordering value but that is ignored since the table uses commit time ordering
- val deletedRecords = dataGen.generateUniqueDeleteRecords(instantTime, 1, lowerOrderingValue)
- deletedRecords.addAll(dataGen.generateUniqueDeleteRecordsWithUpdatedPartition(instantTime, 1, lowerOrderingValue))
- val deleteBatch = recordsToStrings(deletedRecords).asScala
- val deleteDf = spark.read.json(spark.sparkContext.parallelize(deleteBatch.toSeq, 1))
- deleteDf.cache()
- val recordKeyToDelete1 = deleteDf.collectAsList().get(0).getAs("_row_key").asInstanceOf[String]
- val recordKeyToDelete2 = deleteDf.collectAsList().get(1).getAs("_row_key").asInstanceOf[String]
- deleteDf.write.format("hudi")
- .options(hudiOpts)
- .mode(SaveMode.Append)
- .save(basePath)
- val prevDf = mergedDfList.last
- mergedDfList = mergedDfList :+ prevDf.filter(row => row.getAs("_row_key").asInstanceOf[String] != recordKeyToDelete1 &&
- row.getAs("_row_key").asInstanceOf[String] != recordKeyToDelete2)
- validateDataAndRecordIndices(hudiOpts, deleteDf)
- deleteDf.unpersist()
- }
-
- @ParameterizedTest
- @EnumSource(classOf[HoodieTableType])
- def testRLIForDeletesWithSQLDelete(tableType: HoodieTableType): Unit = {
- val hudiOpts = commonOpts + (DataSourceWriteOptions.TABLE_TYPE.key -> tableType.name())
- val insertDf = doWriteAndValidateDataAndRecordIndex(hudiOpts,
- operation = DataSourceWriteOptions.INSERT_OPERATION_OPT_VAL,
- saveMode = SaveMode.Overwrite)
- insertDf.cache()
-
- spark.sql(s"SET hoodie.hfile.block.cache.size = 200")
- spark.sql(s"CREATE TABLE IF NOT EXISTS hudi_indexed_table USING hudi OPTIONS (hoodie.metadata.enable = 'true', hoodie.metadata.record.index.enable = 'true', hoodie.write.merge.handle.class = 'org.apache.hudi.io.FileGroupReaderBasedMergeHandle') LOCATION '$basePath'")
- val existingKeys = dataGen.getExistingKeys
- spark.sql(s"DELETE FROM hudi_indexed_table WHERE _row_key IN ('${existingKeys.get(0)}', '${existingKeys.get(1)}')")
-
- val prevDf = mergedDfList.last
- mergedDfList = mergedDfList :+ prevDf.filter(row => row.getAs("_row_key").asInstanceOf[String] != existingKeys.get(0) &&
- row.getAs("_row_key").asInstanceOf[String] != existingKeys.get(1))
- val structType = new StructType(Array(StructField("_row_key", StringType)))
- val convertToRow: Function[String, Row] = key => new GenericRowWithSchema(Array(key), structType)
- val rows: java.util.List[Row] = util.Arrays.asList(convertToRow.apply(existingKeys.get(0)), convertToRow.apply(existingKeys.get(1)))
- val deleteDf = spark.createDataFrame(rows, structType)
- validateDataAndRecordIndices(hudiOpts, deleteDf)
- deleteDf.unpersist()
- }
-
- @ParameterizedTest
- @EnumSource(classOf[HoodieTableType])
- def testRLIWithDeletePartition(tableType: HoodieTableType): Unit = {
- val hudiOpts = commonOpts + (DataSourceWriteOptions.TABLE_TYPE.key -> tableType.name())
- val latestSnapshot = doWriteAndValidateDataAndRecordIndex(hudiOpts,
- operation = DataSourceWriteOptions.BULK_INSERT_OPERATION_OPT_VAL,
- saveMode = SaveMode.Overwrite)
-
- Using(getHoodieWriteClient(getWriteConfig(hudiOpts))) { client =>
- val commitTime = client.startCommit(HoodieTimeline.REPLACE_COMMIT_ACTION)
- val deletingPartition = dataGen.getPartitionPaths.last
- val partitionList = Collections.singletonList(deletingPartition)
- val result = client.deletePartitions(partitionList, commitTime)
- client.commit(commitTime, result.getWriteStatuses, org.apache.hudi.common.util.Option.empty(), HoodieTimeline.REPLACE_COMMIT_ACTION,
- result.getPartitionToReplaceFileIds, org.apache.hudi.common.util.Option.empty());
-
- val deletedDf = latestSnapshot.filter(s"partition = $deletingPartition")
- validateDataAndRecordIndices(hudiOpts, deletedDf)
- }
- }
-
- @ParameterizedTest
- @EnumSource(classOf[HoodieTableType])
- def testRLIUpsertAndDropIndex(tableType: HoodieTableType): Unit = {
- val hudiOpts = commonOpts ++ Map(DataSourceWriteOptions.TABLE_TYPE.key -> tableType.name(),
- HoodieMetadataConfig.ENABLE_METADATA_INDEX_COLUMN_STATS.key -> "true")
- doWriteAndValidateDataAndRecordIndex(hudiOpts,
- operation = DataSourceWriteOptions.INSERT_OPERATION_OPT_VAL,
- saveMode = SaveMode.Overwrite)
-
- val writeConfig = getWriteConfig(hudiOpts)
- writeConfig.setSchema(HoodieTestDataGenerator.TRIP_EXAMPLE_SCHEMA)
- getHoodieWriteClient(writeConfig).dropIndex(Collections.singletonList(MetadataPartitionType.RECORD_INDEX.getPartitionPath))
- assertEquals(0, getFileGroupCountForRecordIndex(writeConfig))
- metaClient = HoodieTableMetaClient.reload(metaClient)
- assertEquals(0, metaClient.getTableConfig.getMetadataPartitionsInflight.size())
- // only files, col stats, partition stats partition should be present.
- assertEquals(3, metaClient.getTableConfig.getMetadataPartitions.size())
-
- doWriteAndValidateDataAndRecordIndex(hudiOpts,
- operation = DataSourceWriteOptions.UPSERT_OPERATION_OPT_VAL,
- saveMode = SaveMode.Append)
- }
-
- @ParameterizedTest
- @EnumSource(classOf[HoodieTableType])
- def testRLIWithDTCleaning(tableType: HoodieTableType): Unit = {
- var hudiOpts = commonOpts ++ Map(
- DataSourceWriteOptions.TABLE_TYPE.key -> tableType.name(),
- HoodieCleanConfig.CLEANER_COMMITS_RETAINED.key() -> "1")
- if (tableType == HoodieTableType.MERGE_ON_READ) {
- hudiOpts = hudiOpts ++ Map(
- HoodieCompactionConfig.INLINE_COMPACT.key() -> "true",
- HoodieCompactionConfig.INLINE_COMPACT_NUM_DELTA_COMMITS.key() -> "2",
- HoodieMetadataConfig.COMPACT_NUM_DELTA_COMMITS.key() -> "15"
- )
- }
-
- doWriteAndValidateDataAndRecordIndex(hudiOpts,
- operation = DataSourceWriteOptions.INSERT_OPERATION_OPT_VAL,
- saveMode = SaveMode.Overwrite)
- doWriteAndValidateDataAndRecordIndex(hudiOpts,
- operation = DataSourceWriteOptions.UPSERT_OPERATION_OPT_VAL,
- saveMode = SaveMode.Append)
- doWriteAndValidateDataAndRecordIndex(hudiOpts,
- operation = DataSourceWriteOptions.UPSERT_OPERATION_OPT_VAL,
- saveMode = SaveMode.Append)
-
- val lastCleanInstant = getLatestMetaClient(false).getActiveTimeline.getCleanerTimeline.lastInstant()
- assertTrue(lastCleanInstant.isPresent)
- val writeConfig = getWriteConfig(hudiOpts)
- val client = new SparkRDDWriteClient(new HoodieSparkEngineContext(jsc), writeConfig)
- client.savepoint("user", "note")
-
- doWriteAndValidateDataAndRecordIndex(hudiOpts,
- operation = DataSourceWriteOptions.UPSERT_OPERATION_OPT_VAL,
- saveMode = SaveMode.Append)
- assertTrue(getLatestMetaClient(false).getActiveTimeline.getCleanerTimeline.lastInstant().get().requestedTime
- .compareTo(lastCleanInstant.get().requestedTime) > 0)
-
- client.restoreToSavepoint()
- client.close()
- // last commit is no longer present so remove it from the mergedDfList
- mergedDfList = mergedDfList.take(mergedDfList.size - 1)
- validateDataAndRecordIndices(hudiOpts)
- }
-
- @Test
- def testRLIWithDTCompaction(): Unit = {
- val hudiOpts = commonOpts ++ Map(
- DataSourceWriteOptions.TABLE_TYPE.key -> HoodieTableType.MERGE_ON_READ.name(),
- HoodieCompactionConfig.INLINE_COMPACT.key() -> "true",
- HoodieCompactionConfig.INLINE_COMPACT_NUM_DELTA_COMMITS.key() -> "2",
- HoodieCompactionConfig.PARQUET_SMALL_FILE_LIMIT.key() -> "0"
- )
-
- doWriteAndValidateDataAndRecordIndex(hudiOpts,
- operation = DataSourceWriteOptions.INSERT_OPERATION_OPT_VAL,
- saveMode = SaveMode.Overwrite)
- doWriteAndValidateDataAndRecordIndex(hudiOpts,
- operation = DataSourceWriteOptions.UPSERT_OPERATION_OPT_VAL,
- saveMode = SaveMode.Append)
- doWriteAndValidateDataAndRecordIndex(hudiOpts,
- operation = DataSourceWriteOptions.UPSERT_OPERATION_OPT_VAL,
- saveMode = SaveMode.Append)
-
- var lastCompactionInstant = getLatestCompactionInstant()
- assertTrue(lastCompactionInstant.isPresent)
-
- doWriteAndValidateDataAndRecordIndex(hudiOpts,
- operation = DataSourceWriteOptions.UPSERT_OPERATION_OPT_VAL,
- saveMode = SaveMode.Append)
- assertTrue(getLatestCompactionInstant().get().requestedTime.compareTo(lastCompactionInstant.get().requestedTime) > 0)
- lastCompactionInstant = getLatestCompactionInstant()
-
- var rollbackedInstant: Option[HoodieInstant] = Option.empty
- while (rollbackedInstant.isEmpty || rollbackedInstant.get.requestedTime != lastCompactionInstant.get().requestedTime) {
- // rollback compaction instant
- rollbackedInstant = Option.apply(rollbackLastInstant(hudiOpts))
- }
- validateDataAndRecordIndices(hudiOpts)
- }
-
- @ParameterizedTest
- @EnumSource(classOf[HoodieTableType])
- def testRLIWithDTClustering(tableType: HoodieTableType): Unit = {
- val hudiOpts = commonOpts ++ Map(
- DataSourceWriteOptions.TABLE_TYPE.key -> tableType.name(),
- HoodieClusteringConfig.INLINE_CLUSTERING.key() -> "true",
- HoodieClusteringConfig.INLINE_CLUSTERING_MAX_COMMITS.key() -> "2"
- )
- val props = new Properties()
- for ((k, v) <- hudiOpts) {
- props.put(k, v)
- }
- initMetaClient(tableType, props)
-
- doWriteAndValidateDataAndRecordIndex(hudiOpts,
- operation = DataSourceWriteOptions.INSERT_OPERATION_OPT_VAL,
- saveMode = SaveMode.Overwrite)
- doWriteAndValidateDataAndRecordIndex(hudiOpts,
- operation = DataSourceWriteOptions.UPSERT_OPERATION_OPT_VAL,
- saveMode = SaveMode.Append)
-
- val lastClusteringInstant = getLatestClusteringInstant()
- assertTrue(lastClusteringInstant.isPresent)
-
- doWriteAndValidateDataAndRecordIndex(hudiOpts,
- operation = DataSourceWriteOptions.UPSERT_OPERATION_OPT_VAL,
- saveMode = SaveMode.Append)
- doWriteAndValidateDataAndRecordIndex(hudiOpts,
- operation = DataSourceWriteOptions.UPSERT_OPERATION_OPT_VAL,
- saveMode = SaveMode.Append)
-
- assertTrue(getLatestClusteringInstant().get().requestedTime.compareTo(lastClusteringInstant.get().requestedTime) > 0)
- assertEquals(getLatestClusteringInstant(), metaClient.getActiveTimeline.lastInstant())
- validateDataAndRecordIndices(hudiOpts)
- // We are validating rollback of a DT clustering instant here
- rollbackLastInstant(hudiOpts)
- validateDataAndRecordIndices(hudiOpts)
- }
-
- @ParameterizedTest
- @CsvSource(value = Array(
- "COPY_ON_WRITE,COLUMN_STATS",
- "COPY_ON_WRITE,BLOOM_FILTERS",
- "COPY_ON_WRITE,COLUMN_STATS:BLOOM_FILTERS",
- "MERGE_ON_READ,COLUMN_STATS",
- "MERGE_ON_READ,BLOOM_FILTERS",
- "MERGE_ON_READ,COLUMN_STATS:BLOOM_FILTERS")
- )
- def testRLIWithOtherMetadataPartitions(tableType: String, metadataPartitionTypes: String): Unit = {
- var hudiOpts = commonOpts
- val metadataPartitions = metadataPartitionTypes.split(":").toStream.map(p => MetadataPartitionType.valueOf(p)).toList
- for (metadataPartition <- metadataPartitions) {
- if (metadataPartition == MetadataPartitionType.COLUMN_STATS) {
- hudiOpts += (HoodieMetadataConfig.ENABLE_METADATA_INDEX_COLUMN_STATS.key -> "true")
- } else if (metadataPartition == MetadataPartitionType.BLOOM_FILTERS) {
- hudiOpts += (HoodieMetadataConfig.ENABLE_METADATA_INDEX_BLOOM_FILTER.key() -> "true")
- }
- }
-
- hudiOpts = hudiOpts + (DataSourceWriteOptions.TABLE_TYPE.key -> tableType)
- doWriteAndValidateDataAndRecordIndex(hudiOpts,
- operation = DataSourceWriteOptions.INSERT_OPERATION_OPT_VAL,
- saveMode = SaveMode.Overwrite)
- doWriteAndValidateDataAndRecordIndex(hudiOpts,
- operation = DataSourceWriteOptions.UPSERT_OPERATION_OPT_VAL,
- saveMode = SaveMode.Append)
- assertTrue(metadataWriter(getWriteConfig(hudiOpts)).getEnabledPartitionTypes.containsAll(metadataPartitions.asJava))
- }
-
- @ParameterizedTest
- @MethodSource(Array("testEnableDisableRLIParams"))
- def testEnableDisableRLI(tableType: HoodieTableType, isPartitioned: Boolean): Unit = {
- var hudiOpts = commonOpts ++ Map(
- DataSourceWriteOptions.TABLE_TYPE.key -> tableType.name()
- )
-
- if (!isPartitioned) {
- hudiOpts = hudiOpts - PARTITIONPATH_FIELD.key
- }
-
- doWriteAndValidateDataAndRecordIndex(hudiOpts,
- operation = DataSourceWriteOptions.INSERT_OPERATION_OPT_VAL,
- saveMode = SaveMode.Overwrite)
- doWriteAndValidateDataAndRecordIndex(hudiOpts,
- operation = DataSourceWriteOptions.UPSERT_OPERATION_OPT_VAL,
- saveMode = SaveMode.Append)
-
- hudiOpts += (HoodieMetadataConfig.RECORD_INDEX_ENABLE_PROP.key -> "false")
- metaClient.getTableConfig.setMetadataPartitionState(metaClient, MetadataPartitionType.RECORD_INDEX.getPartitionPath, false)
-
- doWriteAndValidateDataAndRecordIndex(hudiOpts,
- operation = DataSourceWriteOptions.UPSERT_OPERATION_OPT_VAL,
- saveMode = SaveMode.Append,
- validate = false)
-
- try {
- validateDataAndRecordIndices(hudiOpts)
- } catch {
- case e: Exception =>
- assertTrue(e.isInstanceOf[IllegalStateException])
- assertTrue(e.getMessage.contains("Record index is not initialized in MDT"))
- }
-
- hudiOpts += (HoodieMetadataConfig.RECORD_INDEX_ENABLE_PROP.key -> "true")
- doWriteAndValidateDataAndRecordIndex(hudiOpts,
- operation = DataSourceWriteOptions.UPSERT_OPERATION_OPT_VAL,
- saveMode = SaveMode.Append)
- validateDataAndRecordIndices(hudiOpts)
- }
-
- @ParameterizedTest
- @EnumSource(classOf[HoodieTableType])
- def testRLIWithMDTCompaction(tableType: HoodieTableType): Unit = {
- val hudiOpts = commonOpts ++ Map(
- DataSourceWriteOptions.TABLE_TYPE.key -> tableType.name(),
- HoodieMetadataConfig.COMPACT_NUM_DELTA_COMMITS.key() -> "1"
- )
-
- doWriteAndValidateDataAndRecordIndex(hudiOpts,
- operation = DataSourceWriteOptions.INSERT_OPERATION_OPT_VAL,
- saveMode = SaveMode.Overwrite)
- doWriteAndValidateDataAndRecordIndex(hudiOpts,
- operation = DataSourceWriteOptions.UPSERT_OPERATION_OPT_VAL,
- saveMode = SaveMode.Append)
- doWriteAndValidateDataAndRecordIndex(hudiOpts,
- operation = DataSourceWriteOptions.UPSERT_OPERATION_OPT_VAL,
- saveMode = SaveMode.Append)
- val metadataTableFSView = getHoodieTable(metaClient, getWriteConfig(hudiOpts)).getMetadataTable
- .asInstanceOf[HoodieBackedTableMetadata].getMetadataFileSystemView
- val compactionTimeline = metadataTableFSView.getVisibleCommitsAndCompactionTimeline.filterCompletedAndCompactionInstants()
- val lastCompactionInstant = compactionTimeline
- .filter(JavaConversions.getPredicate((instant: HoodieInstant) =>
- compactionTimeline.readCommitMetadata(instant)
- .getOperationType == WriteOperationType.COMPACT))
- .lastInstant()
- val compactionBaseFile = metadataTableFSView.getAllBaseFiles(MetadataPartitionType.RECORD_INDEX.getPartitionPath)
- .filter(JavaConversions.getPredicate((f: HoodieBaseFile) => f.getCommitTime.equals(lastCompactionInstant.get().requestedTime)))
- .findAny()
- assertTrue(compactionBaseFile.isPresent)
- }
-
- @ParameterizedTest
- @EnumSource(classOf[HoodieTableType])
- def testRLIWithMDTCleaning(tableType: HoodieTableType): Unit = {
- var hudiOpts = commonOpts ++ Map(
- DataSourceWriteOptions.TABLE_TYPE.key -> tableType.name(),
- HoodieMetadataConfig.COMPACT_NUM_DELTA_COMMITS.key() -> "1")
- doWriteAndValidateDataAndRecordIndex(hudiOpts,
- operation = DataSourceWriteOptions.INSERT_OPERATION_OPT_VAL,
- saveMode = SaveMode.Overwrite)
-
- hudiOpts = hudiOpts + (
- HoodieCleanConfig.CLEANER_FILE_VERSIONS_RETAINED.key() -> "1",
- HoodieMetadataConfig.COMPACT_NUM_DELTA_COMMITS.key() -> "4"
- )
- val function = () => doWriteAndValidateDataAndRecordIndex(hudiOpts,
- operation = DataSourceWriteOptions.UPSERT_OPERATION_OPT_VAL,
- saveMode = SaveMode.Append)
- executeFunctionNTimes(function, 3)
-
- // create a savepoint on the data table before the metadata table clean operation
- assertFalse(getMetadataMetaClient(hudiOpts).getActiveTimeline.getCleanerTimeline.lastInstant().isPresent)
- val writeConfig = getWriteConfig(hudiOpts)
- val client = new SparkRDDWriteClient(new HoodieSparkEngineContext(jsc), writeConfig)
- client.savepoint("user", "note")
-
- // validate that the clean is present in the metadata table timeline
- var iterations = 0
- while (getMetadataMetaClient(hudiOpts).getActiveTimeline.getCleanerTimeline.lastInstant().isEmpty) {
- doWriteAndValidateDataAndRecordIndex(hudiOpts,
- operation = DataSourceWriteOptions.UPSERT_OPERATION_OPT_VAL,
- saveMode = SaveMode.Append)
- iterations += 1
- }
- assertTrue(getMetadataMetaClient(hudiOpts).getActiveTimeline.getCleanerTimeline.lastInstant().isPresent)
- // restore to the savepoint to force the metadata table state to roll back to before the clean
- client.restoreToSavepoint()
- client.close()
- // remove the commits that were created after the savepoint
- mergedDfList = mergedDfList.take(mergedDfList.size - iterations)
- validateDataAndRecordIndices(hudiOpts)
- }
-
- @ParameterizedTest
- @EnumSource(classOf[HoodieTableType])
- def testRLIWithMultiWriter(tableType: HoodieTableType): Unit = {
- val hudiOpts = commonOpts ++ Map(
- DataSourceWriteOptions.TABLE_TYPE.key -> tableType.name(),
- HoodieWriteConfig.WRITE_CONCURRENCY_MODE.key() -> "optimistic_concurrency_control",
- HoodieCleanConfig.FAILED_WRITES_CLEANER_POLICY.key() -> "LAZY",
- HoodieLockConfig.LOCK_PROVIDER_CLASS_NAME.key() -> "org.apache.hudi.client.transaction.lock.FileSystemBasedLockProvider",
- HoodieLockConfig.WRITE_CONFLICT_RESOLUTION_STRATEGY_CLASS_NAME.key() -> classOf[PreferWriterConflictResolutionStrategy].getName
- )
-
- doWriteAndValidateDataAndRecordIndex(hudiOpts,
- operation = DataSourceWriteOptions.INSERT_OPERATION_OPT_VAL,
- saveMode = SaveMode.Overwrite,
- validate = false)
-
- val executor = Executors.newFixedThreadPool(2)
- implicit val executorContext: ExecutionContext = ExecutionContext.fromExecutor(executor)
- val timestamp = System.currentTimeMillis()
- val function = new Function0[Boolean] {
- override def apply(): Boolean = {
- try {
- doWriteAndValidateDataAndRecordIndex(hudiOpts,
- operation = DataSourceWriteOptions.UPSERT_OPERATION_OPT_VAL,
- saveMode = SaveMode.Append,
- validate = false,
- timestamp = timestamp)
- true
- } catch {
- case _: HoodieWriteConflictException => false
- case e => throw new Exception("Multi write failed", e)
- }
- }
- }
- val f1 = Future[Boolean] {
- function.apply()
- }
- val f2 = Future[Boolean] {
- function.apply()
- }
-
- Await.result(f1, Duration("5 minutes"))
- Await.result(f2, Duration("5 minutes"))
-
- assertTrue(f1.value.get.get || f2.value.get.get)
- executor.shutdownNow()
- validateDataAndRecordIndices(hudiOpts)
- }
}
object TestRecordLevelIndex {
- def testEnableDisableRLIParams(): java.util.stream.Stream[Arguments] = {
+ case class TestPartitionedRecordLevelIndexTestCase(tableType: HoodieTableType, streamingWriteEnabled: Boolean)
+
+ def testArgsForPartitionedRecordLevelIndex: java.util.stream.Stream[Arguments] = {
java.util.stream.Stream.of(
- arguments(HoodieTableType.COPY_ON_WRITE, new java.lang.Boolean(false)),
- arguments(HoodieTableType.COPY_ON_WRITE, new java.lang.Boolean(true)),
- arguments(HoodieTableType.MERGE_ON_READ, new java.lang.Boolean(false)),
- arguments(HoodieTableType.MERGE_ON_READ, new java.lang.Boolean(true))
+ Arguments.arguments(TestPartitionedRecordLevelIndexTestCase(HoodieTableType.COPY_ON_WRITE, streamingWriteEnabled = true)),
+ Arguments.arguments(TestPartitionedRecordLevelIndexTestCase(HoodieTableType.COPY_ON_WRITE, streamingWriteEnabled = false)),
+ Arguments.arguments(TestPartitionedRecordLevelIndexTestCase(HoodieTableType.MERGE_ON_READ, streamingWriteEnabled = true)),
+ Arguments.arguments(TestPartitionedRecordLevelIndexTestCase(HoodieTableType.MERGE_ON_READ, streamingWriteEnabled = false))
)
}
}
diff --git a/hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/hudi/functional/TestSecondaryIndexPruning.scala b/hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/hudi/functional/TestSecondaryIndexPruning.scala
index 79ade67dc3fa..ee4d094ab17b 100644
--- a/hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/hudi/functional/TestSecondaryIndexPruning.scala
+++ b/hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/hudi/functional/TestSecondaryIndexPruning.scala
@@ -67,7 +67,7 @@ class TestSecondaryIndexPruning extends SparkClientFunctionalTestHarness {
val metadataOpts: Map[String, String] = Map(
HoodieMetadataConfig.ENABLE.key -> "true",
- HoodieMetadataConfig.RECORD_INDEX_ENABLE_PROP.key -> "true"
+ HoodieMetadataConfig.GLOBAL_RECORD_LEVEL_INDEX_ENABLE_PROP.key -> "true"
)
val commonOpts: Map[String, String] = Map(
"hoodie.insert.shuffle.parallelism" -> "4",
diff --git a/hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/hudi/functional/TestSevenToEightUpgrade.scala b/hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/hudi/functional/TestSevenToEightUpgrade.scala
index 52963958a079..43e603543e0d 100644
--- a/hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/hudi/functional/TestSevenToEightUpgrade.scala
+++ b/hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/hudi/functional/TestSevenToEightUpgrade.scala
@@ -143,7 +143,7 @@ class TestSevenToEightUpgrade extends RecordLevelIndexTestBase {
PAYLOAD_CLASS_NAME.key -> classOf[DefaultHoodieRecordPayload].getName,
HoodieMetadataConfig.ENABLE_METADATA_INDEX_COLUMN_STATS.key -> "true",
HoodieMetadataConfig.COLUMN_STATS_INDEX_FOR_COLUMNS.key -> "price",
- HoodieMetadataConfig.RECORD_INDEX_ENABLE_PROP.key -> "true",
+ HoodieMetadataConfig.GLOBAL_RECORD_LEVEL_INDEX_ENABLE_PROP.key -> "true",
// Ensure MDT compaction does not run before downgrade.
HoodieMetadataConfig.COMPACT_NUM_DELTA_COMMITS.key -> "100"
)
diff --git a/hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/spark/sql/hudi/feature/index/TestSecondaryIndex.scala b/hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/spark/sql/hudi/feature/index/TestSecondaryIndex.scala
index f31d92d6c753..48231f6272a3 100644
--- a/hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/spark/sql/hudi/feature/index/TestSecondaryIndex.scala
+++ b/hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/spark/sql/hudi/feature/index/TestSecondaryIndex.scala
@@ -46,7 +46,7 @@ class TestSecondaryIndex extends HoodieSparkSqlTestBase {
var instantTime: AtomicInteger = new AtomicInteger(1)
val metadataOpts: Map[String, String] = Map(
HoodieMetadataConfig.ENABLE.key -> "true",
- HoodieMetadataConfig.RECORD_INDEX_ENABLE_PROP.key -> "true"
+ HoodieMetadataConfig.GLOBAL_RECORD_LEVEL_INDEX_ENABLE_PROP.key -> "true"
)
val commonOpts: Map[String, String] = Map(
"hoodie.insert.shuffle.parallelism" -> "4",
diff --git a/hudi-utilities/src/main/java/org/apache/hudi/utilities/HoodieIndexer.java b/hudi-utilities/src/main/java/org/apache/hudi/utilities/HoodieIndexer.java
index c6be8990e56f..2e1c5c9a1a20 100644
--- a/hudi-utilities/src/main/java/org/apache/hudi/utilities/HoodieIndexer.java
+++ b/hudi-utilities/src/main/java/org/apache/hudi/utilities/HoodieIndexer.java
@@ -51,7 +51,7 @@ import java.util.stream.Collectors;
import static org.apache.hudi.common.config.HoodieMetadataConfig.ENABLE_METADATA_INDEX_BLOOM_FILTER;
import static org.apache.hudi.common.config.HoodieMetadataConfig.ENABLE_METADATA_INDEX_COLUMN_STATS;
-import static org.apache.hudi.common.config.HoodieMetadataConfig.RECORD_INDEX_ENABLE_PROP;
+import static org.apache.hudi.common.config.HoodieMetadataConfig.GLOBAL_RECORD_LEVEL_INDEX_ENABLE_PROP;
import static org.apache.hudi.common.util.StringUtils.isNullOrEmpty;
import static org.apache.hudi.common.util.ValidationUtils.checkArgument;
import static org.apache.hudi.metadata.HoodieTableMetadataUtil.PARTITION_NAME_BLOOM_FILTERS;
@@ -185,7 +185,7 @@ public class HoodieIndexer {
props.setProperty(ENABLE_METADATA_INDEX_BLOOM_FILTER.key(), "true");
}
if (PARTITION_NAME_RECORD_INDEX.equals(p)) {
- props.setProperty(RECORD_INDEX_ENABLE_PROP.key(), "true");
+ props.setProperty(GLOBAL_RECORD_LEVEL_INDEX_ENABLE_PROP.key(), "true");
}
});
diff --git a/hudi-utilities/src/main/java/org/apache/hudi/utilities/HoodieMetadataTableValidator.java b/hudi-utilities/src/main/java/org/apache/hudi/utilities/HoodieMetadataTableValidator.java
index deb45f0b377b..f8924fbf82a7 100644
--- a/hudi-utilities/src/main/java/org/apache/hudi/utilities/HoodieMetadataTableValidator.java
+++ b/hudi-utilities/src/main/java/org/apache/hudi/utilities/HoodieMetadataTableValidator.java
@@ -1835,7 +1835,7 @@ public class HoodieMetadataTableValidator implements Serializable {
.enable(enableMetadataTable)
.withMetadataIndexBloomFilter(enableMetadataTable)
.withMetadataIndexColumnStats(enableMetadataTable)
- .withEnableRecordIndex(enableMetadataTable)
+ .withEnableGlobalRecordLevelIndex(enableMetadataTable)
.build();
props.put(FileSystemViewStorageConfig.VIEW_TYPE.key(), viewStorageType);
FileSystemViewStorageConfig viewConf = FileSystemViewStorageConfig.newBuilder().fromProperties(props).build();
diff --git a/hudi-utilities/src/test/java/org/apache/hudi/utilities/TestHoodieIndexer.java b/hudi-utilities/src/test/java/org/apache/hudi/utilities/TestHoodieIndexer.java
index aa0165348381..40c73c77154d 100644
--- a/hudi-utilities/src/test/java/org/apache/hudi/utilities/TestHoodieIndexer.java
+++ b/hudi-utilities/src/test/java/org/apache/hudi/utilities/TestHoodieIndexer.java
@@ -231,7 +231,7 @@ public class TestHoodieIndexer extends SparkClientFunctionalTestHarness implemen
assertTrue(metadataPartitionExists(basePath(), context(), RECORD_INDEX.getPartitionPath()));
// Step 3: writer upsert with metadata enabled with RECORD_INDEX enabled
- upsertToTable(metadataConfigBuilder.withEnableRecordIndex(true).build(), tableName);
+ upsertToTable(metadataConfigBuilder.withEnableGlobalRecordLevelIndex(true).build(), tableName);
// Step 4: validate RECORD_INDEX partition is not deleted
assertTrue(reload(metaClient).getTableConfig().getMetadataPartitions().contains(RECORD_INDEX.getPartitionPath()));
diff --git a/hudi-utilities/src/test/java/org/apache/hudi/utilities/TestHoodieMetadataTableValidator.java b/hudi-utilities/src/test/java/org/apache/hudi/utilities/TestHoodieMetadataTableValidator.java
index 7cc016463ead..24894d4ae512 100644
--- a/hudi-utilities/src/test/java/org/apache/hudi/utilities/TestHoodieMetadataTableValidator.java
+++ b/hudi-utilities/src/test/java/org/apache/hudi/utilities/TestHoodieMetadataTableValidator.java
@@ -210,7 +210,7 @@ public class TestHoodieMetadataTableValidator extends HoodieSparkClientTestBase
Dataset<Row> inserts = makeInsertDf("000", 5).cache();
inserts.write().format("hudi").options(writeOptions)
.option(DataSourceWriteOptions.OPERATION().key(), WriteOperationType.BULK_INSERT.value())
- .option(HoodieMetadataConfig.RECORD_INDEX_ENABLE_PROP.key(), "true")
+ .option(HoodieMetadataConfig.GLOBAL_RECORD_LEVEL_INDEX_ENABLE_PROP.key(), "true")
.option(HoodieMetadataConfig.RECORD_INDEX_MIN_FILE_GROUP_COUNT_PROP.key(), "1")
.option(HoodieMetadataConfig.RECORD_INDEX_MAX_FILE_GROUP_COUNT_PROP.key(), "1")
.mode(SaveMode.Overwrite)
@@ -219,7 +219,7 @@ public class TestHoodieMetadataTableValidator extends HoodieSparkClientTestBase
Dataset<Row> updates = makeUpdateDf("001", 5).cache();
updates.write().format("hudi").options(writeOptions)
.option(DataSourceWriteOptions.OPERATION().key(), WriteOperationType.UPSERT.value())
- .option(HoodieMetadataConfig.RECORD_INDEX_ENABLE_PROP.key(), "true")
+ .option(HoodieMetadataConfig.GLOBAL_RECORD_LEVEL_INDEX_ENABLE_PROP.key(), "true")
.option(HoodieMetadataConfig.RECORD_INDEX_MIN_FILE_GROUP_COUNT_PROP.key(), "1")
.option(HoodieMetadataConfig.RECORD_INDEX_MAX_FILE_GROUP_COUNT_PROP.key(), "1")
.mode(SaveMode.Append)
@@ -269,7 +269,7 @@ public class TestHoodieMetadataTableValidator extends HoodieSparkClientTestBase
Dataset<Row> inserts = makeInsertDf("000", 5).cache();
inserts.write().format("hudi").options(writeOptions)
.option(DataSourceWriteOptions.OPERATION().key(), WriteOperationType.BULK_INSERT.value())
- .option(HoodieMetadataConfig.RECORD_INDEX_ENABLE_PROP.key(), "true")
+ .option(HoodieMetadataConfig.GLOBAL_RECORD_LEVEL_INDEX_ENABLE_PROP.key(), "true")
.option(HoodieMetadataConfig.RECORD_INDEX_MIN_FILE_GROUP_COUNT_PROP.key(), "1")
.option(HoodieMetadataConfig.RECORD_INDEX_MAX_FILE_GROUP_COUNT_PROP.key(), "1")
.mode(SaveMode.Overwrite)
@@ -284,7 +284,7 @@ public class TestHoodieMetadataTableValidator extends HoodieSparkClientTestBase
Dataset<Row> updates = makeUpdateDf("001", 5).cache();
updates.write().format("hudi").options(writeOptions)
.option(DataSourceWriteOptions.OPERATION().key(), WriteOperationType.UPSERT.value())
- .option(HoodieMetadataConfig.RECORD_INDEX_ENABLE_PROP.key(), "true")
+ .option(HoodieMetadataConfig.GLOBAL_RECORD_LEVEL_INDEX_ENABLE_PROP.key(), "true")
.option(HoodieMetadataConfig.RECORD_INDEX_MIN_FILE_GROUP_COUNT_PROP.key(), "1")
.option(HoodieMetadataConfig.RECORD_INDEX_MAX_FILE_GROUP_COUNT_PROP.key(), "1")
.mode(SaveMode.Append)
@@ -1296,7 +1296,7 @@ public class TestHoodieMetadataTableValidator extends HoodieSparkClientTestBase
writeOptions.put(DataSourceWriteOptions.RECORDKEY_FIELD().key(), "_row_key");
writeOptions.put(HoodieTableConfig.ORDERING_FIELDS.key(), "timestamp");
writeOptions.put(DataSourceWriteOptions.OPERATION().key(),"bulk_insert");
- writeOptions.put(HoodieMetadataConfig.RECORD_INDEX_ENABLE_PROP.key(), "true");
+ writeOptions.put(HoodieMetadataConfig.GLOBAL_RECORD_LEVEL_INDEX_ENABLE_PROP.key(), "true");
Dataset<Row> inserts = makeInsertDf("000", 50).cache();
inserts.write().format("hudi").options(writeOptions)
@@ -1397,7 +1397,7 @@ public class TestHoodieMetadataTableValidator extends HoodieSparkClientTestBase
Dataset<Row> inserts = makeInsertDf("000", 5).cache();
inserts.write().format("hudi").options(writeOptions)
.option(DataSourceWriteOptions.OPERATION().key(), WriteOperationType.BULK_INSERT.value())
- .option(HoodieMetadataConfig.RECORD_INDEX_ENABLE_PROP.key(), "true")
+ .option(HoodieMetadataConfig.GLOBAL_RECORD_LEVEL_INDEX_ENABLE_PROP.key(), "true")
.option(HoodieMetadataConfig.RECORD_INDEX_MIN_FILE_GROUP_COUNT_PROP.key(), "1")
.option(HoodieMetadataConfig.RECORD_INDEX_MAX_FILE_GROUP_COUNT_PROP.key(), "1")
.mode(SaveMode.Overwrite)
@@ -1406,7 +1406,7 @@ public class TestHoodieMetadataTableValidator extends HoodieSparkClientTestBase
Dataset<Row> updates = makeUpdateDf("001", 5).cache();
updates.write().format("hudi").options(writeOptions)
.option(DataSourceWriteOptions.OPERATION().key(), WriteOperationType.UPSERT.value())
- .option(HoodieMetadataConfig.RECORD_INDEX_ENABLE_PROP.key(), "true")
+ .option(HoodieMetadataConfig.GLOBAL_RECORD_LEVEL_INDEX_ENABLE_PROP.key(), "true")
.option(HoodieMetadataConfig.RECORD_INDEX_MIN_FILE_GROUP_COUNT_PROP.key(), "1")
.option(HoodieMetadataConfig.RECORD_INDEX_MAX_FILE_GROUP_COUNT_PROP.key(), "1")
.mode(SaveMode.Append)
@@ -1416,7 +1416,7 @@ public class TestHoodieMetadataTableValidator extends HoodieSparkClientTestBase
Dataset<Row> inserts2 = makeInsertDf("002", 5).cache();
inserts2.write().format("hudi").options(writeOptions)
.option(DataSourceWriteOptions.OPERATION().key(), WriteOperationType.BULK_INSERT.value())
- .option(HoodieMetadataConfig.RECORD_INDEX_ENABLE_PROP.key(), "true")
+ .option(HoodieMetadataConfig.GLOBAL_RECORD_LEVEL_INDEX_ENABLE_PROP.key(), "true")
.option(HoodieMetadataConfig.RECORD_INDEX_MIN_FILE_GROUP_COUNT_PROP.key(), "1")
.option(HoodieMetadataConfig.RECORD_INDEX_MAX_FILE_GROUP_COUNT_PROP.key(), "1")
.mode(SaveMode.Append)
diff --git a/hudi-utilities/src/test/java/org/apache/hudi/utilities/deltastreamer/TestHoodieDeltaStreamer.java b/hudi-utilities/src/test/java/org/apache/hudi/utilities/deltastreamer/TestHoodieDeltaStreamer.java
index 9556d70b8602..2dc9d4da67ac 100644
--- a/hudi-utilities/src/test/java/org/apache/hudi/utilities/deltastreamer/TestHoodieDeltaStreamer.java
+++ b/hudi-utilities/src/test/java/org/apache/hudi/utilities/deltastreamer/TestHoodieDeltaStreamer.java
@@ -1572,7 +1572,7 @@ public class TestHoodieDeltaStreamer extends HoodieDeltaStreamerTestBase {
// Schedule an indexing instant
HoodieIndexer scheduleIndexingJob = new HoodieIndexer(jsc,
buildIndexerConfig(tableBasePath, ds.getConfig().targetTableName, null, UtilHelpers.SCHEDULE, "RECORD_INDEX",
- Arrays.asList(HoodieMetadataConfig.RECORD_INDEX_ENABLE_PROP.key() + "=true", HoodieWriteConfig.MARKERS_TYPE.key() + "=DIRECT")));
+ Arrays.asList(HoodieMetadataConfig.GLOBAL_RECORD_LEVEL_INDEX_ENABLE_PROP.key() + "=true", HoodieWriteConfig.MARKERS_TYPE.key() + "=DIRECT")));
scheduleIndexInstantTime = scheduleIndexingJob.doSchedule();
TestHelpers.assertPendingIndexCommit(tableBasePath);
LOG.info("Schedule indexing success, now build index with instant time " + scheduleIndexInstantTime.get());
@@ -1584,7 +1584,7 @@ public class TestHoodieDeltaStreamer extends HoodieDeltaStreamerTestBase {
});
HoodieIndexer runIndexingJob = new HoodieIndexer(jsc,
buildIndexerConfig(tableBasePath, ds.getConfig().targetTableName, scheduleIndexInstantTime.get(), UtilHelpers.EXECUTE, "RECORD_INDEX",
- Arrays.asList(HoodieMetadataConfig.RECORD_INDEX_ENABLE_PROP.key() + "=true", HoodieWriteConfig.MARKERS_TYPE.key() + "=DIRECT")));
+ Arrays.asList(HoodieMetadataConfig.GLOBAL_RECORD_LEVEL_INDEX_ENABLE_PROP.key() + "=true", HoodieWriteConfig.MARKERS_TYPE.key() + "=DIRECT")));
runIndexingJob.start(0);
LOG.info("Metadata indexing success");
TestHelpers.assertCompletedIndexCommit(tableBasePath);
@@ -1644,7 +1644,7 @@ public class TestHoodieDeltaStreamer extends HoodieDeltaStreamerTestBase {
try {
HoodieIndexer runIndexingJob = new HoodieIndexer(jsc,
buildIndexerConfig(tableBasePath, ds.getConfig().targetTableName, scheduleIndexInstantTime.get(), UtilHelpers.EXECUTE, "RECORD_INDEX",
- Arrays.asList(HoodieMetadataConfig.RECORD_INDEX_ENABLE_PROP.key() + "=true", HoodieMetadataConfig.METADATA_INDEX_CHECK_TIMEOUT_SECONDS.key() + "=20")));
+ Arrays.asList(HoodieMetadataConfig.GLOBAL_RECORD_LEVEL_INDEX_ENABLE_PROP.key() + "=true", HoodieMetadataConfig.METADATA_INDEX_CHECK_TIMEOUT_SECONDS.key() + "=20")));
runIndexingJob.start(0);
// Clustering commit fails because of conflict with indexing commit
fail("Indexing should fail with catchup failure");