ryanmeowy opened a new pull request, #12746:
URL: https://github.com/apache/seatunnel/pull/12746
### Purpose of this pull request
Related #11007
Migrate the Vitess CDC source validation from the imperative checks in
`VitessSourceFactory` to declarative `OptionRule` validation.
Vitess does not provide a SeaTunnel catalog yet, so a source has to describe
its tables explicitly through `schema` / `tables_configs`, and the rule cannot
look inside those structures. The new guards cover that gap:
- Add `VitessSchemaMetadataGuards` in the connector's `config` package,
holding the guards plus the shared predicate and messages.
- Reject a `schema` that declares neither `columns` nor `metadata_table_id`.
- Reject an empty `tables_configs` with `Conditions.notEmpty`.
- Reject a `tables_configs` entry that carries no `schema` block, or whose
nested schema declares neither `columns` nor `metadata_table_id`; the message
names the offending entry, for example `tables_configs[0].schema`.
- Reject `table-names` together with `table-pattern`. The framework has no
"at most one" operator (`exclusive` means "exactly one"), so this one is a
`ConditionExtension`, and `table-names` moved out of the plain optional list so
it can carry the condition.
- The runtime checks in `VitessSourceFactory` are kept as a second line of
defence for callers that build the source without running the rule. They now
call the shared predicate and message helpers, so both layers report the same
wording and there is no behaviour change.
### Does this PR introduce _any_ user-facing change?
Only the validation timing and the error reporting path change.
- Option names, defaults and accepted values are unchanged; no previously
valid configuration becomes invalid.
- A configuration that was previously rejected while the job was being built
is now rejected by `ConfigValidator` with `OptionValidationException` during
standard configuration validation.
- Checks that need the source metadata, such as a declared table without
schema metadata or a pattern that matches nothing, still run when the source is
built; they cannot be expressed in the rule.
### How was this patch tested?
Added rule-level cases to `VitessSourceFactoryTest` (8 to 19 tests), driving
`ConfigValidator.of(ReadonlyConfig.fromMap(options)).validate(optionRule())`: a
valid root schema with `columns`, one with `metadata_table_id`, valid
`tables_configs`, the negative cases (missing schema metadata, empty
`tables_configs`, an entry without a schema block, a nested schema without
metadata, both selectors set together), the still-valid single-selector cases,
and one case asserting the rule and the source path report the same message.
```bash
./mvnw -pl seatunnel-connectors-v2/connector-cdc/connector-cdc-vitess \
-Dtest=VitessSourceFactoryTest \
-Dsurefire.failIfNoSpecifiedTests=false test
```
Full module suite: 19 tests, 0 failures (JDK 11). `spotless:check` passes.
--
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]