nzw921rx opened a new issue, #13230:
URL: https://github.com/apache/seatunnel/issues/13230
## Background
Related to #11007. Follow-up to #12568, which fixed #12569.
`MultiTableSink` currently checks `multi_table_sink_replica < 1` in its
constructor and throws an `IllegalArgumentException` with the option name and
rejected value. The range is already enforced, but the rule is not declared in
`MultiTableSinkFactory.optionRule()`.
`FactoryUtil.createMultiTableSink()` already runs `ConfigValidator` against
the factory's option rules before constructing the sink. The positive
replica-count constraint can therefore use the existing declarative validation
mechanism.
## Proposed change
Declare the option and its lower bound in
`MultiTableSinkFactory.optionRule()`:
```java
@Override
public OptionRule optionRule() {
return OptionRule.builder()
.optional(
SinkConnectorCommonOptions.MULTI_TABLE_SINK_REPLICA,
Conditions.greaterThan(
SinkConnectorCommonOptions.MULTI_TABLE_SINK_REPLICA, 0))
.build();
}
```
Remove the duplicated `replicaNum < 1` check and its explanatory comment
from the `MultiTableSink` constructor. Move the existing replica-count boundary
tests to the factory validation entry so they exercise the production
initialization path. Invalid values must fail before sink construction.
Keep the option optional, with type `int`, default `1` and valid range `>=
1`.
## Acceptance criteria
- [ ] Declare `MULTI_TABLE_SINK_REPLICA` with `Conditions.greaterThan(...,
0)` in the factory's `OptionRule`.
- [ ] Extend existing tests to cover declarative validation and
`FactoryUtil.createMultiTableSink()`: reject `0` and `-1`; accept `1`, a larger
value such as `4`, and an omitted option using the default.
- [ ] Keep diagnostics identifying the option and invalid value; account for
the factory's exception wrapping when updating assertions.
- [ ] Remove the duplicated constructor check and its explanatory comment.
- [ ] Preserve valid create/restore behavior, the option type, default value
and accepted range.
## References
- [Factory validation
entry](https://github.com/apache/seatunnel/blob/f5374addb396b3515fc2aff358b110ad35fe7874/seatunnel-api/src/main/java/org/apache/seatunnel/api/table/factory/FactoryUtil.java#L268-L286)
-
[MultiTableSinkFactory](https://github.com/apache/seatunnel/blob/f5374addb396b3515fc2aff358b110ad35fe7874/seatunnel-api/src/main/java/org/apache/seatunnel/api/sink/multitablesink/MultiTableSinkFactory.java)
- [Existing replica-count
tests](https://github.com/apache/seatunnel/blob/f5374addb396b3515fc2aff358b110ad35fe7874/seatunnel-api/src/test/java/org/apache/seatunnel/api/sink/multitablesink/MultiTableSinkWriterTest.java#L1024-L1089)
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]