Skip to content

Commit

Permalink
Revert allowing tag override with upserts (apache#12311)
Browse files Browse the repository at this point in the history
Co-authored-by: Saurabh Dubey <saurabh.dubey@Saurabhs-MacBook-Pro.local>
  • Loading branch information
saurabhd336 and Saurabh Dubey authored Jan 23, 2024
1 parent eeaf1f0 commit 35faeb6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -706,10 +705,10 @@ static void validateUpsertAndDedupConfig(TableConfig tableConfig, Schema schema)
Preconditions.checkState(
tableConfig.getRoutingConfig() != null && isRoutingStrategyAllowedForUpsert(tableConfig.getRoutingConfig()),
"Upsert/Dedup table must use strict replica-group (i.e. strictReplicaGroup) based routing");
Preconditions.checkState(tableConfig.getTenantConfig().getTagOverrideConfig() == null || (Objects.equals(
tableConfig.getTenantConfig().getTagOverrideConfig().getRealtimeConsuming(),
tableConfig.getTenantConfig().getTagOverrideConfig().getRealtimeCompleted())),
"Invalid tenant tag override used for Upsert/Dedup table");
Preconditions.checkState(tableConfig.getTenantConfig().getTagOverrideConfig() == null || (
tableConfig.getTenantConfig().getTagOverrideConfig().getRealtimeConsuming() == null
&& tableConfig.getTenantConfig().getTagOverrideConfig().getRealtimeCompleted()
== null), "Invalid tenant tag override used for Upsert/Dedup table");

// specifically for upsert
UpsertConfig upsertConfig = tableConfig.getUpsertConfig();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1678,13 +1678,19 @@ public void testValidateUpsertConfig() {
Assert.assertEquals(e.getMessage(), "Invalid tenant tag override used for Upsert/Dedup table");
}

// valid tag override with upsert
// tag override even with same tag for CONSUMING and COMPLETED with upsert should fail
tableConfig = new TableConfigBuilder(TableType.REALTIME).setTableName(TABLE_NAME).setTimeColumnName(TIME_COLUMN)
.setUpsertConfig(new UpsertConfig(UpsertConfig.Mode.FULL)).setStreamConfigs(getStreamConfigs())
.setRoutingConfig(
new RoutingConfig(null, null, RoutingConfig.STRICT_REPLICA_GROUP_INSTANCE_SELECTOR_TYPE, false))
.setTagOverrideConfig(new TagOverrideConfig("T1_REALTIME", "T1_REALTIME")).build();
TableConfigUtils.validateUpsertAndDedupConfig(tableConfig, schema);

try {
TableConfigUtils.validateUpsertAndDedupConfig(tableConfig, schema);
Assert.fail("Tag override must not be allowed with upsert");
} catch (IllegalStateException e) {
Assert.assertEquals(e.getMessage(), "Invalid tenant tag override used for Upsert/Dedup table");
}

// empty tag override with upsert should pass
tableConfig = new TableConfigBuilder(TableType.REALTIME).setTableName(TABLE_NAME).setTimeColumnName(TIME_COLUMN)
Expand Down

0 comments on commit 35faeb6

Please sign in to comment.