icefury71 commented on a change in pull request #6149: URL: https://github.com/apache/incubator-pinot/pull/6149#discussion_r505828804
########## File path: pinot-core/src/main/java/org/apache/pinot/core/util/TableConfigUtils.java ########## @@ -230,6 +234,38 @@ private static void validateIngestionConfig(@Nullable IngestionConfig ingestionC } } + /** + * Validates the upsert-related configurations + * + */ + private static void validateUpsertConfig(TableConfig tableConfig, Schema schema) { + if (tableConfig.getUpsertMode() == UpsertConfig.Mode.NONE) { + return; + } + // primary key exists + if (schema.getPrimaryKeyColumns() == null || schema.getPrimaryKeyColumns().isEmpty()) { + throw new IllegalStateException("Upsert table must have primary key columns in the schema."); + } + // replica group is configured for routing + if (tableConfig.getRoutingConfig() == null || !tableConfig.getRoutingConfig().getInstanceSelectorType() + .equalsIgnoreCase(RoutingConfig.REPLICA_GROUP_INSTANCE_SELECTOR_TYPE)) { + throw new IllegalStateException("Upsert table must use replicaGroup as the routing config."); + } + // consumer type must be low-level + if (tableConfig.getIndexingConfig() != null && tableConfig.getIndexingConfig().getStreamConfigs() != null) { + StreamConfig streamConfig = + new StreamConfig(tableConfig.getTableName(), tableConfig.getIndexingConfig().getStreamConfigs()); + if (streamConfig.getConsumerTypes().size() != 1 + || streamConfig.getConsumerTypes().get(0) != StreamConfig.ConsumerType.LOWLEVEL) { + throw new IllegalStateException("Upsert table must use low-level streaming consumer type."); + } + } + // check type type is realtime + if (tableConfig.getTableType() != TableType.REALTIME) { Review comment: nit: do this in the beginning ? ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For additional commands, e-mail: commits-h...@pinot.apache.org