From 97d343fe0042a322f72f5d61ee94cc0ae2d4c2cc Mon Sep 17 00:00:00 2001 From: Jingsong Date: Mon, 26 Aug 2024 13:39:12 +0800 Subject: [PATCH] [hotfix] Remove customPredicate in CastRulePredicate --- .../casting/BinaryToStringCastRule.java | 2 +- .../paimon/casting/CastRulePredicate.java | 28 ++----------------- ...ava => AppendOnlyTableCompactionTest.java} | 4 +-- 3 files changed, 5 insertions(+), 29 deletions(-) rename paimon-core/src/test/java/org/apache/paimon/append/{AppendOnlyTableCompactionITTest.java => AppendOnlyTableCompactionTest.java} (98%) diff --git a/paimon-core/src/main/java/org/apache/paimon/casting/BinaryToStringCastRule.java b/paimon-core/src/main/java/org/apache/paimon/casting/BinaryToStringCastRule.java index 503ec9480771..bea2590b6a3d 100644 --- a/paimon-core/src/main/java/org/apache/paimon/casting/BinaryToStringCastRule.java +++ b/paimon-core/src/main/java/org/apache/paimon/casting/BinaryToStringCastRule.java @@ -37,6 +37,6 @@ private BinaryToStringCastRule() { @Override public CastExecutor create(DataType inputType, DataType targetType) { - return value -> BinaryString.fromBytes(value); + return BinaryString::fromBytes; } } diff --git a/paimon-core/src/main/java/org/apache/paimon/casting/CastRulePredicate.java b/paimon-core/src/main/java/org/apache/paimon/casting/CastRulePredicate.java index 8530808c2d17..dd37c889386b 100644 --- a/paimon-core/src/main/java/org/apache/paimon/casting/CastRulePredicate.java +++ b/paimon-core/src/main/java/org/apache/paimon/casting/CastRulePredicate.java @@ -24,9 +24,7 @@ import java.util.Collections; import java.util.HashSet; -import java.util.Optional; import java.util.Set; -import java.util.function.BiPredicate; /** * In order to apply a {@link CastRule}, the runtime checks if a particular rule matches the tuple @@ -46,13 +44,7 @@ *
  • {@link #getInputTypeFamilies()} includes one of the {@link DataTypeFamily} of input * type * - *
  • Or, if {@link #getCustomPredicate()} is not null, the input {@link DataType} and target - * {@link DataType} matches the predicate. * - * - *

    The {@code customPredicate} should be used in cases where {@link DataTypeRoot} and {@link - * DataTypeFamily} are not enough to identify whether a rule is applicable or not, for example when - * the matching depends on a field of the provided input {@link DataType} instance. */ public class CastRulePredicate { @@ -64,21 +56,17 @@ public class CastRulePredicate { private final Set inputTypeFamilies; private final Set targetTypeFamilies; - private final BiPredicate customPredicate; - private CastRulePredicate( Set targetTypes, Set inputTypeRoots, Set targetTypeRoots, Set inputTypeFamilies, - Set targetTypeFamilies, - BiPredicate customPredicate) { + Set targetTypeFamilies) { this.targetTypes = targetTypes; this.inputTypeRoots = inputTypeRoots; this.targetTypeRoots = targetTypeRoots; this.inputTypeFamilies = inputTypeFamilies; this.targetTypeFamilies = targetTypeFamilies; - this.customPredicate = customPredicate; } public Set getTargetTypes() { @@ -101,10 +89,6 @@ public Set getTargetTypeFamilies() { return targetTypeFamilies; } - public Optional> getCustomPredicate() { - return Optional.ofNullable(customPredicate); - } - public static Builder builder() { return new Builder(); } @@ -118,8 +102,6 @@ public static class Builder { private final Set inputTypeFamilies = new HashSet<>(); private final Set targetTypeFamilies = new HashSet<>(); - private BiPredicate customPredicate; - public Builder input(DataTypeRoot inputTypeRoot) { inputTypeRoots.add(inputTypeRoot); return this; @@ -145,19 +127,13 @@ public Builder target(DataTypeFamily outputTypeFamily) { return this; } - public Builder predicate(BiPredicate customPredicate) { - this.customPredicate = customPredicate; - return this; - } - public CastRulePredicate build() { return new CastRulePredicate( Collections.unmodifiableSet(targetTypes), Collections.unmodifiableSet(inputTypeRoots), Collections.unmodifiableSet(targetTypeRoots), Collections.unmodifiableSet(inputTypeFamilies), - Collections.unmodifiableSet(targetTypeFamilies), - customPredicate); + Collections.unmodifiableSet(targetTypeFamilies)); } } } diff --git a/paimon-core/src/test/java/org/apache/paimon/append/AppendOnlyTableCompactionITTest.java b/paimon-core/src/test/java/org/apache/paimon/append/AppendOnlyTableCompactionTest.java similarity index 98% rename from paimon-core/src/test/java/org/apache/paimon/append/AppendOnlyTableCompactionITTest.java rename to paimon-core/src/test/java/org/apache/paimon/append/AppendOnlyTableCompactionTest.java index 82ce2e45a3df..9f57e3507417 100644 --- a/paimon-core/src/test/java/org/apache/paimon/append/AppendOnlyTableCompactionITTest.java +++ b/paimon-core/src/test/java/org/apache/paimon/append/AppendOnlyTableCompactionTest.java @@ -49,8 +49,8 @@ import static org.assertj.core.api.Assertions.assertThat; -/** Test for {@link UnawareAppendTableCompactionCoordinator}. */ -public class AppendOnlyTableCompactionITTest { +/** Test for append table compaction. */ +public class AppendOnlyTableCompactionTest { @TempDir private Path tempDir; private FileStoreTable appendOnlyFileStoreTable;