nzw921rx opened a new issue, #13232:
URL: https://github.com/apache/seatunnel/issues/13232

   ### Search before asking
   
   - [x] I had searched in the 
[feature](https://github.com/apache/seatunnel/issues?q=is%3Aissue+label%3A%22Feature%22)
 and found no similar feature requirement.
   
   ### Description
   
   `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.
   
   #### Code 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)
   
   ### Usage Scenario
   
   When a multi-table sink is initialized from job configuration, reject 
`multi_table_sink_replica = 0` and negative values through the factory's 
declarative validation before constructing the sink. Valid configurations, 
including an omitted option using the default `1`, continue to work.
   
   ### Related issues
   
   - #11007 — Declarative OptionRule validation migration.
   - #12569 — Original invalid replica-count diagnostics issue, fixed by #12568.
   
   ### Are you willing to submit a PR?
   
   - [ ] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [ ] I agree to follow this project's [Code of 
Conduct](https://www.apache.org/foundation/policies/conduct)
   


-- 
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]

Reply via email to