[Feature][API] Simplify condition chain model by removing (Expression)
Search before asking
- [x] I had searched in the feature and found no similar feature requirement.
Description
Problem statement
Today we maintain two abstractions for the same concept:
Condition<?>already supports linked condition chains via.and()/.or()Expressionwraps aCondition<?>and re-implements chain composition
As a result, internal code frequently does:
- build a
Conditionchain - wrap it as
Expression - immediately unwrap it again (
getExpression()) before evaluation or rendering
This indirection increases API surface and maintenance cost without adding semantics.
Goal
Use Condition<?> as the single representation of condition chains.
Non-goals
- No new precedence rule is introduced (reuse
Condition's existing AND/OR evaluation logic) - No behavior change in error messages
- No behavior change in REST metadata rendering
- No change to connector-facing
OptionRule.builder()usage patterns
Proposed API model
| Current | Proposed |
|---|---|
Expression.of(Condition.of(option, value)) |
Condition.of(option, value) |
Expression::or / Expression::and |
Condition::or / Condition::and |
ConditionRule.expression: Expression |
ConditionRule.condition: Condition<?> |
ConditionalRequiredOptions.expression: Expression |
ConditionalRequiredOptions.condition: Condition<?> |
Map<Expression, OptionRule> |
Map<Condition<?>, OptionRule> |
ConfigValidator.validate(Expression) |
ConfigValidator.validate(Condition<?>) |
Compatibility strategy
Two rollout options:
Option 1: Deprecate first, remove later
- Keep
Expressionin the current release and mark it as@Deprecated - Migrate all in-repo usages to
Condition<?> - Remove
Expressionin the next API cleanup window
When to use: if maintainers want a transition window for potential downstream usage.
Option 2: Remove directly in this PR
- Delete
Expression.javadirectly - Replace all in-repo usages with
Condition<?> - Remove all
Expressionentrypoints inConfigValidatorin the same PR
When to use: if maintainers confirm external usage is minimal and want to reduce model complexity immediately.
Impact scope (direct changes)
Expression.java: deleteOptionRule.java: removeExpressionconstruction path, useCondition<?>directlyConditionRule.java: field type changes fromExpressiontoCondition<?>RequiredOption.java:ConditionalRequiredOptionschanges fromExpressiontoCondition<?>ConfigValidator.java: remove allExpressionentrypoints (including constructor/overload), evaluate viaCondition<?>onlyOptionRulesService.java: replacegetExpression()withgetCondition()MetadataExportCommand.java: switch export path fromExpressiontoCondition- tests: replace all
Expression-related assertions and builders
Questions to confirm
- Should we choose Option 1 (deprecate first) or Option 2 (direct removal in this PR)?
- Is it acceptable to update
seatunnel-engineandseatunnel-corecall paths in this PR (OptionRulesService/MetadataExportCommand)? - Can we remove all
Expression-typed constructors/overloads inConfigValidatorwithout keeping compatibility shims? - Should this change be treated as API cleanup and explicitly called out in PR notes/changelog for downstream users that may import `Expression
Usage Scenario
No response
Related issues
No response
Are you willing to submit a PR?
- [x] Yes I am willing to submit a PR!
Code of Conduct
- [x] I agree to follow this project's Code of Conduct
@davidzollo PTAL and please help confirm. Thanks in advance😄
Thanks for writing this up so concretely.
I agree this is a larger API-cleanup / compatibility topic, not just a local refactor.
I would not remove Expression directly in the first PR. My preference is Option 1: deprecate first, migrate in-repo usages, and keep compatibility shims for one release cycle.
The main reason is that Expression is still a public seatunnel-api type today, and it is not only an internal wrapper. RequiredOption.ConditionalRequiredOptions still stores an Expression, and ConfigValidator still validates through Expression. Even if all in-repo call sites are migrated in one PR, deleting it immediately would still be a source-level breaking change for downstream extensions that may already import it.
My suggested scope is:
- keep
Condition<?>as the long-term single model - migrate the internal evaluation / rendering path toward
Condition<?> - keep deprecated
Expressionentrypoints / constructors / accessors as forwarding compatibility shims for now - keep behavior and error-message rendering unchanged in this step
It is fine to update the seatunnel-engine and seatunnel-core call paths in the same PR if the observable behavior stays identical. What I would avoid in the first change is removing all Expression-typed APIs from ConfigValidator and RequiredOption at once.
So from my side: yes to the cleanup direction, but deprecate-first is the safer path here.
I think your point makes sense. Let's hear from the other guys
Thanks for the well-structured proposal. Since Expression is part of the public API in seatunnel-api, Option 1 (deprecate first, remove in a later API cleanup window) seems safer for potential downstream/connector authors. Could a committer confirm the preferred rollout path before implementation starts?
Please confirm the scope of in-repo migration: a quick audit of all usages of Expression (e.g., ConditionRule, ConditionalRequiredOptions, ConfigValidator, REST metadata rendering, Map<Expression, OptionRule> keys) with a checklist in this issue would help track the change and verify the stated non-goals (no behavior/message/rendering changes).
If you plan to work on this, please note that Condition> will be used as a map key after the change — verify its equals/hashCode semantics match what Expression provided today, and add tests covering AND/OR chain equality to avoid subtle regressions.
Thanks @DanielLeens for the detailed analysis, and @davidzollo for confirming the direction.
I agree with Option 1 (deprecate-first) rather than removing Expression outright. Since Expression is still a public seatunnel-api type — stored in RequiredOption.ConditionalRequiredOptions and validated through ConfigValidator — deleting it immediately would be a source-level breaking change for downstream extensions, even if all in-repo usages are migrated in one PR.
So let's lock the first PR's scope to what @DanielLeens outlined:
- Keep
Condition<?>as the long-term single model. - Migrate the internal evaluation / rendering path toward
Condition<?>. - Keep deprecated
Expressionentrypoints / constructors / accessors as forwarding compatibility shims for one release cycle. - Keep behavior and error-message rendering unchanged in this step.
Updating the seatunnel-engine and seatunnel-core call paths in the same PR is fine as long as observable behavior stays identical, and the Expression-typed APIs in ConfigValidator and RequiredOption should not be removed in this first change.
@nzw921rx, can you confirm you're OK taking this on with the deprecate-first scope above? Thanks all — looking forward to the PR.