Skip to content

[Improve][API] Add Map condition validators for configuration option … - #11010

Merged
davidzollo merged 4 commits into
apache:devfrom
nzw921rx:feature/api-map-condition
Jun 7, 2026
Merged

[Improve][API] Add Map condition validators for configuration option …#11010
davidzollo merged 4 commits into
apache:devfrom
nzw921rx:feature/api-map-condition

Conversation

@nzw921rx

@nzw921rx nzw921rx commented Jun 4, 2026

Copy link
Copy Markdown
Collaborator

Purpose of this pull request

Add Map-type condition validators for the configuration option validation framework.

New operators:

  • Add mapNotEmpty(option) — validates that the Map value is not empty
  • Add mapContainsKey(option, key) — validates that the Map contains a specific key
  • Add mapContainsKeys(option, key1, key2, ...) — validates that the Map contains all specified keys

Documentation:

  • Update docs/en/architecture/configuration-and-option-system.md — add Map category to operator table and pattern guide
  • Update docs/zh/architecture/configuration-and-option-system.md — same for Chinese version

Does this PR introduce any user-facing change?

No.

How was this patch tested?

Unit tests added in ConfigValidatorTest.java:

  • testMapNotEmpty — verifies empty map fails, non-empty passes
  • testMapContainsKey — verifies missing key fails, present key passes
  • testMapContainsKeys — verifies partial keys fail, all keys pass, extra keys still pass
  • testMapContainsKeyWithNullValue — verifies key presence check (not value check)
  • testMapNotEmptyAndContainsKeyCombined — verifies AND-chaining of map conditions
./mvnw -pl seatunnel-api test

@DanielLeens DanielLeens left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this. I reviewed the latest head from the API entry points down to the evaluator registry.

Runtime path checked:
OptionRule -> Condition -> ConditionEvaluators.evaluate(...) -> the new MAP_* operators in ConditionEvaluators.

The implementation is straightforward and the tests in ConfigValidatorTest cover the main user-facing cases well enough for this change: non-empty maps, single required key, multiple required keys, and composition with and(...).

I did not find a blocker in the code itself.

Merge conclusion: can merge after CI is green

  1. Blocking items
  • No code blocker found in the latest diff.
  • The current red CI does not look caused by this PR. The failing check is connector-jdbc-e2e-ddl, and the failure is in SqlServerSchemaChangeIT (expected: 9, actual: 0 in the schema-evolution assertion path), which is outside the API validator surface changed here.
  1. Suggested follow-ups
  • Please rerun or resync once the unrelated CI issue is cleared.

Overall, the map-condition addition itself looks sound to me.

davidzollo
davidzollo previously approved these changes Jun 6, 2026

@davidzollo davidzollo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1
LGTM

@dybyte dybyte left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 I fixed the minor Javadoc naming inconsistency directly since it was a small cleanup, and the rest of the PR looks good to me.

@nzw921rx

nzw921rx commented Jun 6, 2026

Copy link
Copy Markdown
Collaborator Author

@davidzollo Could you please help review it again? Thank you very much.

@DanielLeens DanielLeens left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the update. I re-reviewed the latest head ae30eada271af4f6b9611488ce924f560f3f5e30 from the API entry points down to the evaluator registry again.

I noticed @davidzollo and @dybyte already rechecked the latest head. After my own rereview, I agree with that conclusion: the API-side map validators still look sound, and the follow-up Javadoc cleanup keeps the public docs aligned with the actual factory methods.

What this PR solves

  • User pain: today OptionRule can validate scalars, strings, and collections, but there is no built-in way to say that a map must be non-empty or contain required keys.
  • Fix approach: add MAP_NOT_EMPTY, MAP_CONTAINS_KEY, and MAP_CONTAINS_KEYS operators, expose them through Conditions, and document them in EN/ZH architecture docs.
  • One-line summary: this gives plugin authors a first-class way to validate map-shaped config without custom ad hoc checks.

Simple example:

  • Before this PR, a connector author who wanted to require bootstrap.servers inside a map had to write custom validation outside the shared condition system.
  • After this PR, the same rule can be expressed directly as Conditions.mapContainsKey(...) and runs through the same validator pipeline as the existing numeric/string/collection checks.

Full runtime chain I checked

option validation
  -> OptionRule.builder().required(...)
  -> Condition created by Conditions.mapNotEmpty / mapContainsKey / mapContainsKeys
  -> ConfigValidator validates the configured option
  -> ConditionEvaluators.evaluate(...)
      -> dispatches to MAP_NOT_EMPTY / MAP_CONTAINS_KEY / MAP_CONTAINS_KEYS
      -> returns pass/fail for the user-facing validation error path

Findings

  • The new operators are wired through the full validator chain consistently.
  • The added ConfigValidatorTest cases cover empty-map, required-key, multi-key, and composed-condition scenarios.
  • The EN and ZH architecture docs were updated together.
  • I did not find a code blocker on the current head.

CI

I also checked the current failed Build on this head. One concrete failing job is:

  • unit-test (11, ubuntu-latest): SeaTunnelClientTest.testSetJobIdDuplicate

The broader Build also includes unrelated E2E failures outside the API validation surface. I do not see evidence that those failures are caused by this map-condition change.

Merge conclusion: can merge

  1. Blocking items
  • No blocking code issue from my side on the latest revision.
  1. Suggested follow-up
  • Please rerun or resync once the unrelated CI failures are cleared so the branch has a green merge signal.

Thanks for keeping the API and documentation updates together here.

@davidzollo
davidzollo merged commit 6b9075f into apache:dev Jun 7, 2026
6 of 7 checks passed
@nzw921rx
nzw921rx deleted the feature/api-map-condition branch June 13, 2026 17:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants