Repository navigation
[Improve][Connector-V2][Clickhouse] Declarative option rule for file_fields_delimiter - #12512
TianHengZhuang wants to merge 4 commits into
Conversation
…idation to declarative optionRule The single-character constraint on file_fields_delimiter was enforced by an imperative check inside ClickhouseFileSinkFactory.createSink, so it only ran once a sink writer was created. Move it into optionRule() via Conditions.extension so the same constraint is evaluated during option-rule validation. Also add factory tests covering single-character, absent, empty and multi-character values, document the check-time behavior, and record the user-visible change in incompatible-changes.
|
put up #12512 for this one - just the @DanielLeens whenever you get a sec 🙏 |
DanielLeens
left a comment
There was a problem hiding this comment.
Hi @TianHengZhuang, thank you for this contribution and for tracking it against the declarative OptionRule migration in #11007. I did a full review of the current head (11c2194), re-deriving everything from the source rather than the PR description. The change is small, well-scoped and semantically sound. The one thing that has to be fixed before merge is a formatting failure that stopped CI before any test ran.
What Problem Does This PR Solve?
The ClickhouseFile sink requires file_fields_delimiter to be exactly one character, because it becomes the csv separator for the temporary files that clickhouse-local reads. Before this PR that rule lived as an imperative if (...length() != 1) throw ... at the end of ClickhouseFileSinkFactory.createSink, after the factory had already opened a ClickhouseProxy connection and resolved shard metadata. The PR moves the rule into optionRule() using Conditions.extension(...), so it is part of the declarative option metadata and is evaluated by ConfigValidator before any connection is made.
Example: a config with file_fields_delimiter = ",," used to be rejected only after the sink connected to ClickHouse. Now it is rejected by option-rule validation before createSink runs.
1. Code Change Review
1.1 Core Logic Analysis
Changes in ClickhouseFileSinkFactory (PR head):
FILE_FIELDS_DELIMITERis removed from the plainoptional(...)list and re-declared asoptional(FILE_FIELDS_DELIMITER, Conditions.extension(FILE_FIELDS_DELIMITER, new SingleCharacterValidator()))(lines ~84-86).- A package-private
SingleCharacterValidator implements ConditionExtension<String>returnsvalue != null && value.length() == 1(lines ~92-102). - The old imperative check and its two now-unused imports were removed from
createSink.
Runtime path, traced on the PR head:
FactoryUtil.createAndPrepareSink(...) FactoryUtil.java:252
-> ConfigValidator.of(context.getOptions()).validate(tableSinkFactory.optionRule())
-> for each valueConstraint in rule ConfigValidator.java:230-247
skip if head option absent (isConstraintApplicable -> hasOption -> getOptional().isPresent(), ConfigValidator.java:412)
evaluate EXTENSION -> ext.evaluate(cfg, v) ConditionEvaluators.java:167-172
-> tableSinkFactory.createSink(context) (no length check any more)
Findings:
- Semantics are preserved exactly. The old check ran on
readonlyConfig.get(FILE_FIELDS_DELIMITER), i.e. the explicit value or the default"\t"(ClickhouseFileSinkOptions.java:73-79). The new rule runs only when the key is explicitly present (getOptionalignores defaults), and the default is one character, so an absent key is equivalent to the old behavior. Both an empty string and a multi-character string are still rejected. No valid config is newly rejected. - The extension operator is a good choice over
Conditions.matches:matchesusesString.matches, so a regex such as^.$would wrongly reject a newline delimiter. Countinglength()accepts every value the old check accepted. Theevaluateimplementation does no I/O, which matches theConditionExtensioncontract. - One subtle point about what "the same" means: because
FactoryUtilvalidates the option rule immediately beforecreateSink(FactoryUtil.java:252), the runtime protection is not lost. The check now fires earlier, before the ClickHouse connection and shard lookup, which is strictly better. It also means the claim in the PR docs that the value is rejected "at--checkinstead of at runtime" is not accurate (see Issue 2).
1.2 Compatibility Impact
Fully compatible for valid configs. For invalid configs (empty or longer than one character) the job still fails, but earlier and with a different exception type: the old code threw ClickhouseConnectorException with CONFIG_VALIDATION_FAILED; the new one throws OptionValidationException from the option-rule validator (wrapped by FactoryException in FactoryUtil). I searched the E2E resources and tests on the PR head and found nothing that depends on the old message or on file_fields_delimiter, so there is no in-repo consumer of the old error type. Jobs that omit the option or use a single character behave identically. No option key, default, serialization or checkpoint format changes.
1.3 Performance / Side-Effect Analysis
Negligible. One String.length() per sink creation, no I/O, no threads, no state. Failing before the ClickHouse connection is opened is a small side-effect improvement (no proxy connection is opened and closed for a config that can never work).
1.4 Error Handling and Logging
Issue 1: spotless:check fails on two files, so the whole Build is red and no test ran
- Location:
ClickhouseFactoryTest.java(validateFileSink, ~lines 56-58, andemptyDelimiterIsRejected, ~lines 85-90) andClickhouseFileSinkFactory.java(optionRule(), ~lines 84-86). - Problem: The fork's "Run / Code style" job runs
./mvnw clean spotless:checkand reports format violations in both files: theConfigValidator.of(...).validate(...)chain and theAssertions.assertThrows(...)call are wrapped although they fit in 100 columns, and theConditions.extension(call is wrapped although it fits on one line. The apache-side Build check is only a pointer to that run, and the other jobs in it did not run, so the new unit tests have never executed on this head. - Potential risk: The PR cannot merge, and the correctness of the four new tests is unverified.
- Best improvement: Run
./mvnw spotless:apply -pl seatunnel-connectors-v2/connector-clickhouse -nsu, commit the result, and push. No functional change is needed. - Severity: High (blocks merge; PR-caused)
- Raised by another reviewer: No
Issue 2: The documentation and incompatible-changes entry overstate the behavior change
- Location:
docs/en/introduction/concepts/incompatible-changes.mdand the zh counterpart (the new ClickhouseFile entry),docs/en/connectors/sink/ClickhouseFile.md(file_fields_delimitersection) and its zh counterpart. - Problem: The entry says the value "now fails ... at
--check/--dry-runtime instead of later at runtime" and that it was previously enforced "only when a job actually started a sink writer". In the source,FactoryUtil.createAndPrepareSink(FactoryUtil.java:252) runs the same option-rule validation at real job start as well, so runtime rejection was never removed; what actually changed is that the failure moves before the ClickHouse connection/shard lookup and the exception type changes fromClickhouseConnectorException(CONFIG_VALIDATION_FAILED)toOptionValidationException. The connector doc sentence "rejected at job submission (--check) instead of at runtime" has the same imprecision. - Potential risk: Misleading migration guidance; users or operators who match on the old error type get no warning.
- Best improvement: Reword the entry to say the constraint is now part of the declared option rule, is enforced before the sink connects to ClickHouse (and by
--check/ option-rule validation), and that the error is now an option-validation error instead of aClickhouseConnectorException. Keep the zh text consistent with the en text. - Severity: Medium
- Raised by another reviewer: No
Issue 3: Small test gaps
- Location:
ClickhouseFactoryTest.emptyDelimiterIsRejected(~lines 85-90). - Problem: The multi-character case asserts that the message contains
file_fields_delimiter, but the empty-string case only asserts the exception type. The required-options in the helper (passwordis set to an empty string) rely on required-option presence semantics; that is probably fine but it has not been run on CI yet. - Potential risk: Very low; a regression that rejects the wrong option in the empty case would still pass.
- Best improvement: Assert the same message content in the empty case, for example through a small shared assertion helper.
- Severity: Low
- Raised by another reviewer: No
2. Code Quality Assessment
2.1 Coding Standards
Good. The new nested class has a short Javadoc explaining why the constraint exists, imports are ordinary imports, and no wildcard or shaded-package problems. The only standards defect is the formatting failure in Issue 1. Note that a wrong optional/required split is not introduced here: the option keeps its optional status and its default.
2.2 Test Coverage and Test Stability
Four tests were added to ClickhouseFactoryTest running the real ConfigValidator against the factory optionRule(): single character passes, absent key passes, empty is rejected, multi-character is rejected with the option key in the message. They map to the right regression points (deleting the extension breaks the two reject tests; making the extension apply to absent keys or the default breaks the absent test). Stability: Stable. There are no sleeps, no static mutable state (the shared factory is stateless), no containers and no timing. I did not treat the missing E2E as a gap: the change is confined to option validation, which is fully covered by the unit-level validator call. The tests have not been executed on CI yet (Issue 1).
2.3 Documentation Updates
en and zh were both updated and are structurally consistent with each other (the zh files carry a Chinese translation of the same content). The content needs the accuracy fix in Issue 2.
3. Architectural Soundness
3.1 Elegance of the Solution
Precise fix. It stays entirely inside the connector factory, uses an existing public API, and does not touch shared classes.
3.2 Maintainability
Good. The constraint is now discoverable through option-rule metadata instead of buried in createSink. The validator's description ("must be a single character") is also what the REST/CLI option-rule metadata will show.
3.3 Extensibility
Fine. The validator is a small reusable class; if other file/csv-style connectors adopt the same rule it could be lifted into a shared helper later, but that is not needed for this PR.
3.4 Historical-Version Compatibility
No job JSON, option key, default or state format changes, so existing job configs, checkpoints and savepoints are unaffected. The only observable difference is the failure timing and exception type for configs that were already invalid (see 1.2).
4. Issue Summary
| # | Issue | Location | Severity |
|---|---|---|---|
| 1 | spotless:check fails; Build red; unit tests never ran | ClickhouseFactoryTest.java, ClickhouseFileSinkFactory.java | High |
| 2 | Docs and incompatible-changes text overstate the change (runtime validation still exists; exception type changes) | incompatible-changes.md (en, zh), ClickhouseFile.md (en, zh) | Medium |
| 3 | Empty-value test does not assert the message | ClickhouseFactoryTest.java ~85-90 | Low |
5. Merge Recommendation
Conclusion: Ready to merge after fixes
- Blockers - must be fixed
- Issue 1: run spotless on the connector-clickhouse module, commit and push so the Build can run the tests.
- Recommended fixes - non-blocking
- Issue 2: make the incompatible-changes and connector doc wording match what the source does.
- Issue 3: assert the message in the empty-value test.
Overall assessment: the rule is semantically equivalent to the old check for every value, is not reachable differently on the normal path (it is evaluated by FactoryUtil before createSink), and is a clean example of the extension operator. No better alternative is needed; a plain regex operator would wrongly reject a newline delimiter.
Existing reviews: there were no prior human reviews on this PR, so nothing to reconcile. CI/sync status: the Build check is red solely because of the spotless Code style job in the fork run, which is PR-caused; the branch is 0 behind dev with no conflicts, so no sync is needed. Next step: apply spotless, push, and let the unit tests run; I am happy to re-review right after.
davidzollo
left a comment
There was a problem hiding this comment.
+1 if CI passes.
LGTM
Thanks for your contribution! This is a solid addition to the project, and your attention to detail really shows. Contributors like you are what keep this community moving forward. Feel free to keep the PRs coming — we're always glad to have you here!
Please ignore the following message if you have joined in the Slack~
To facilitate focused communication among contributors, we’ve created a brand-new dedicated #contributors channel in official Slack workspace.
Slack workspace link: https://s.apache.org/seatunnel-slack
This channel is designed for technical discussions, feature design brainstorming, roadmap sync and direct communication with project core Contributors. Everyone who contributes code, docs, test cases or community ideas is warmly invited to join, share thoughts and collaborate together under The Apache Way. Welcome to join 😄
|
Thanks for the approval, @davidzollo — but I want to flag before anyone merges this: Issue 1 from my review (High, blocking) is still open. I checked the fork's latest run at the current head ( @TianHengZhuang — could you run |
Collapse the Conditions.extension call and the ConfigValidator / Assertions calls back onto single lines to match the google-java-format (AOSP) output expected by spotless. No behavior change.
DanielLeens
left a comment
There was a problem hiding this comment.
Hi @TianHengZhuang, thank you for the quick follow-up commit. I re-read the whole PR from scratch at the new head (9484364) and checked every point from my earlier review against source and the fork's CI run. Thank you also to @davidzollo for the earlier look. My earlier note that the spotless job was blocking is now resolved.
What Problem Does This PR Solve?
The ClickhouseFile sink requires file_fields_delimiter to be exactly one character, because it becomes the csv separator for the temporary files that clickhouse-local reads. Before this PR the rule was an imperative length check at the end of ClickhouseFileSinkFactory.createSink, evaluated after the ClickHouse proxy connection had already been opened. The PR declares the rule in optionRule() with Conditions.extension(...), so ConfigValidator evaluates it before any connection is made.
Example: file_fields_delimiter = ",," used to fail only after the sink connected to ClickHouse. Now it fails during option-rule validation, before createSink runs.
1. Code Change Review
1.1 Core Logic Analysis
The changes are the same as in the round I reviewed, plus a formatting-only commit:
FILE_FIELDS_DELIMITERis declared asoptional(FILE_FIELDS_DELIMITER, Conditions.extension(FILE_FIELDS_DELIMITER, new SingleCharacterValidator())).- A package-private
SingleCharacterValidatorimplementsConditionExtension<String>and returnsvalue != null && value.length() == 1. - The old imperative check and its two unused imports were removed from
createSink.
Delta since my review (11c2194a to 94843645): only whitespace. Conditions.extension(...) is joined onto one line in ClickhouseFileSinkFactory.optionRule(). In ClickhouseFactoryTest, the ConfigValidator.of(...).validate(...) chain and the assertThrows call are also joined onto one line. There is no functional change.
Runtime path (unchanged from my earlier trace, and still true at this head):
FactoryUtil.createAndPrepareSink(...) FactoryUtil.java:252
-> ConfigValidator.of(options).validate(factory.optionRule())
-> value constraints loop ConfigValidator.java:230-247
skipped when the option key is absent
EXTENSION -> ext.evaluate(cfg, v) ConditionEvaluators.java:167-172
-> factory.createSink(context) (no length check any more)
Semantics match the old check for every value. An absent key means the one-character default "\t" applies. An empty string or a value longer than one character is still rejected. A newline delimiter is still accepted, which a regex matches operator would have broken.
1.2 Compatibility Impact
Fully compatible for valid configs. Invalid configs still fail, but earlier and with OptionValidationException instead of ClickhouseConnectorException(CONFIG_VALIDATION_FAILED). No option key, default, serialization or checkpoint format changes.
1.3 Performance / Side-Effect Analysis
Negligible: one String.length() per sink creation and no I/O. Failing before the ClickHouse connection is opened is a small improvement.
1.4 Error Handling and Logging
Status of my earlier items at head 9484364:
- Earlier Issue 1 (spotless failure, High): Fixed. The fork run 36509320110 for this head shows
Run / Code styleas success. Every job after it now ran, includingupdated-modules-integration-testparts 1 to 8.
Issue 1: Docs and incompatible-changes entry still overstate the behavior change (carried over from my earlier Issue 2, not fixed)
- Location:
docs/en/introduction/concepts/incompatible-changes.md(new ClickhouseFile entry, the Description and Impact bullets) and the zh counterpart. Alsodocs/en/connectors/sink/ClickhouseFile.md(file_fields_delimitersection) and the zh counterpart. - Problem: The text says the value now fails "at
--check/--dry-runtime instead of later at runtime" and that it was previously enforced "only when a job actually started a sink writer".FactoryUtil.createAndPrepareSink(FactoryUtil.java:252) already ran the same option-rule validation at real job start, right beforecreateSink. Runtime rejection was never removed. What changed is that the failure now happens before the ClickHouse connection and shard lookup, and the exception type is nowOptionValidationExceptioninstead ofClickhouseConnectorException. The connector doc sentence "rejected at job submission (--check) instead of at runtime" has the same imprecision. The diff between the two heads did not touch any docs. - Potential risk: Misleading migration guidance. Operators who match on the old error type get no hint that it changed.
- Best improvement: Reword the entry to say the constraint is now part of the declared option rule, enforced before the sink connects to ClickHouse and by
--check, and that the error is now an option-validation error. Keep the zh text consistent. - Severity: Medium (non-blocking)
- Raised by another reviewer: No
Issue 2: Empty-value test does not assert the message (carried over from my earlier Issue 3, not fixed)
- Location:
ClickhouseFactoryTest.emptyDelimiterIsRejected(about lines 85-88). - Problem: The multi-character case checks that the message mentions
file_fields_delimiter. The empty-string case only checks the exception type. - Potential risk: Very low. An unrelated option-validation failure in the empty case would still pass.
- Best improvement: Assert the same message content in the empty case.
- Severity: Low
- Raised by another reviewer: No
2. Code Quality Assessment
2.1 Coding Standards
Good. The nested validator has a short Javadoc explaining why the constraint exists, imports are ordinary, and the Code style job is now green. The joined lines are exactly 100 columns, which matches the Spotless pass.
2.2 Test Coverage and Test Stability
ClickhouseFactoryTest now runs on CI. Both ubuntu and windows report Tests run: 5, Failures: 0, Errors: 0 for it (four new tests plus one existing). The tests exercise the real ConfigValidator against the factory rule: single character passes, absent key passes, empty is rejected, multi-character is rejected. Deleting the extension turns the two reject tests red. Applying the rule to absent keys turns the absent-key test red. Stability: Stable, with no sleeps, no static mutable state, no containers and no timing.
2.3 Documentation Updates
The en and zh docs are consistent with each other, but the wording is inaccurate as described in Issue 1.
3. Architectural Soundness
3.1 Elegance of the Solution
Precise fix. It stays inside the connector factory and uses an existing public API.
3.2 Maintainability
Good. The constraint is now visible in option-rule metadata instead of buried in createSink.
3.3 Extensibility
Fine. The validator could later be lifted into a shared helper if other csv-style connectors adopt the rule.
3.4 Historical-Version Compatibility
No job JSON, option key, default or state format changes. Existing configs, checkpoints and savepoints are unaffected. The only observable difference is the failure timing and exception type for configs that were already invalid.
4. Issue Summary
| # | Issue | Location | Severity |
|---|---|---|---|
| 1 | Docs and incompatible-changes text still overstate the change (runtime validation already existed; exception type changes) | incompatible-changes.md (en, zh), ClickhouseFile.md (en, zh) | Medium |
| 2 | Empty-value test does not assert the message | ClickhouseFactoryTest.java ~85-88 | Low |
5. Merge Recommendation
Conclusion: Ready to merge
- Blockers - must be fixed
- None. The earlier High blocker (spotless) is resolved and verified on CI.
- Recommended fixes - non-blocking
- Issue 1: correct the incompatible-changes and connector doc wording, en and zh. I recommend doing this in this PR, since the incompatible-changes page is migration guidance.
- Issue 2: assert the message in the empty-value test.
Overall assessment: the logic is correct, is semantically equivalent to the old check, and sits on the normal path because FactoryUtil validates the option rule before createSink. There is no better alternative.
Existing approvals: I agree with @davidzollo's LGTM on the code. That approval was dismissed, and my earlier CHANGES_REQUESTED is superseded by this review. My only remaining point is the docs accuracy above.
CI and sync: on head 9484364 the unit-test (11, ubuntu) job failed on RestApiHttpsForTruststoreTest, a 300 second engine-server test unrelated to Clickhouse. The unit-test (11, windows) job failed on PayPalClientTest.closeWakesRetryWait, a known Windows timing flake. The Dead links job failed on deepwiki.com returning HTTP 429. I found no PR-caused failure. Next step: a job-level rerun of the two unit-test jobs should turn the run green. The branch is 14 commits behind dev with no conflicts, so no sync is needed.
…case The old text said the check moved from runtime to `--check` time, which is not what happened: FactoryUtil already ran option-rule validation at job start, so an invalid delimiter was rejected before this change too. What moved is where in that flow it fires (before the ClickHouse connection and shard lookup) and the exception type, which is now OptionValidationException instead of ClickhouseConnectorException. Both pages now say the constraint is declared in the option rule, is enforced before the sink connects, and that --check runs it; the migration guide mentions the new exception type. emptyDelimiterIsRejected now checks the message mentions file_fields_delimiter, same as the multi-character case, so an unrelated option failure cannot make it pass.
|
Both points taken, thanks. Issue 1 (docs wording): reworded all four places. You are right that runtime rejection never went away, Issue 2 (empty-value test): On CI: agreed those three are unrelated ( |
DanielLeens
left a comment
There was a problem hiding this comment.
Hi @TianHengZhuang, thank you for the quick and careful follow-up. Both points I raised in my previous round are addressed in commit db574a3f. I re-read the whole PR at this head from scratch rather than only the delta.
What Problem Does This PR Solve?
The ClickhouseFile sink requires file_fields_delimiter to be exactly one character, because it becomes the csv separator for the temporary files read by clickhouse-local. Before this PR the rule was an imperative length check at the end of ClickhouseFileSinkFactory.createSink, evaluated after the ClickHouse proxy connection had been opened. The PR declares the rule in optionRule() with Conditions.extension(...), so ConfigValidator evaluates it before any connection is made.
Example: file_fields_delimiter = ",," used to fail only after the sink connected to ClickHouse. Now it fails during option-rule validation, before createSink runs.
1. Code Change Review
1.1 Core Logic Analysis
Production code is identical to the head I approved (94843645); the new commit only touches docs and one test.
ClickhouseFileSinkFactory.optionRule()declaresoptional(FILE_FIELDS_DELIMITER, Conditions.extension(FILE_FIELDS_DELIMITER, new SingleCharacterValidator())).- Package-private
SingleCharacterValidator implements ConditionExtension<String>returnsvalue != null && value.length() == 1, with a short Javadoc explaining why. - The imperative check and its two unused imports are gone from
createSink.
Runtime path (verified again):
FactoryUtil.createAndPrepareSink(...) FactoryUtil.java:252
-> ConfigValidator.of(options).validate(factory.optionRule())
-> value constraints loop ConfigValidator.java:230-247
skipped when the option key is absent
EXTENSION -> ext.evaluate(cfg, v) ConditionEvaluators.java:167-172
-> factory.createSink(context) (no length check any more)
This is the normal job path, not a recovery or edge path. Semantics match the old check: an absent key means the one-character default applies, while an empty string or a multi-character value is rejected. A newline delimiter stays valid, which a regex matches operator would have broken.
1.2 Compatibility Impact
Fully compatible for valid configs. Invalid configs still fail, earlier, with OptionValidationException instead of ClickhouseConnectorException(CONFIG_VALIDATION_FAILED). No option key, default, serialization or checkpoint format changes. The exception type change is now documented accurately (see 2.3).
1.3 Performance / Side-Effect Analysis
Negligible: one String.length() per sink creation, no I/O, no threads, no state. Failing before the ClickHouse connection is opened is a small improvement.
1.4 Error Handling and Logging
No blocking issues found. Status of my earlier items at head db574a3f:
- Earlier Issue 1 (docs and incompatible-changes wording, Medium): Fixed. The en
incompatible-changes.mdentry now says the constraint is declared inoptionRule(), that invalid values were rejected before as well, that what changes is where and how, and it leads the Impact bullet with theClickhouseConnectorExceptiontoOptionValidationExceptionchange and tells operators to match on the new type. The zh entry has the same structure. The connector docs (en and zh) now say the value is rejected during option-rule validation before the sink connects to ClickHouse, and mention the empty value. - Earlier Issue 2 (empty-value test message, Low): Fixed.
ClickhouseFactoryTest.emptyDelimiterIsRejectednow asserts the message containsfile_fields_delimiter, same as the multi-character case. - Earlier spotless blocker: still resolved; the Build pointer is green on this head.
Remaining risk: none that I can find.
2. Code Quality Assessment
2.1 Coding Standards
Good. Ordinary imports, a Javadoc on the validator, and formatting passes Spotless (Build is green).
2.2 Test Coverage and Test Stability
Four new tests plus the existing one exercise the real ConfigValidator against the factory rule: single character passes, absent key passes, empty is rejected, multi-character is rejected, each reject case also checks the message. Deleting the extension turns both reject tests red; applying the rule to absent keys turns the absent-key test red. Stability: Stable (no sleeps, no static mutable state except an immutable factory instance, no containers, no timing).
2.3 Documentation Updates
en and zh are consistent with each other and now match the code: the value was always rejected at job start, the change is the earlier position and the exception type.
3. Architectural Soundness
3.1 Elegance of the Solution
Precise fix. It stays inside the connector factory and uses an existing public API.
3.2 Maintainability
Good. The constraint is visible in option-rule metadata instead of buried in createSink.
3.3 Extensibility
Fine. The validator could later become a shared helper if other csv-style connectors adopt the rule.
3.4 Historical-Version Compatibility
No job JSON, option key, default or state format changes. Existing configs, checkpoints and savepoints are unaffected. The only observable difference is failure timing and exception type for configs that were already invalid.
4. Issue Summary
| # | Issue | Location | Severity |
|---|---|---|---|
| - | No open issues; both earlier non-blocking items are fixed | - | - |
5. Merge Recommendation
Conclusion: Ready to merge
- Blockers - must be fixed: none.
- Recommended fixes - non-blocking: none.
Overall assessment: correct, semantically equivalent to the old check, on the normal path, well tested and now accurately documented. There is no better alternative.
Existing approvals: I keep my approval and agree with @davidzollo's earlier LGTM on the code.
CI and sync: the Build check on head db574a3f is green (fork run 36655603621), along with labeler and Notify. The branch is 20 commits behind dev with no conflicts, so no sync is needed. The PR shows BLOCKED only because it is waiting for a required approving review on this new head.
|
@TianHengZhuang pls resolve conflicts.
|
SEZ9
left a comment
There was a problem hiding this comment.
Thanks for working on this. I reviewed the latest head db574a3f3386.
What this PR fixes
- User pain: An invalid
file_fields_delimiteron the ClickhouseFile sink was only rejected at the very end ofClickhouseFileSinkFactory.createSink, after the factory had already opened aClickhouseProxy, fetched the table schema and resolved shards; because the check was not part ofoptionRule(),--check/--dry-runcould not surface it. - Fix approach: Move the constraint into
optionRule()asConditions.extension(FILE_FIELDS_DELIMITER, new SingleCharacterValidator())(ClickhouseFileSinkFactory.java:85), with the validator returningvalue != null && value.length() == 1(line 98); delete the imperativeClickhouseConnectorException(CONFIG_VALIDATION_FAILED)throw and its imports; add fourConfigValidator-driven unit tests; and document the earlier failure point in the en/zh connector docs plus an incompatible-changes entry. - One-line summary: The migration is wired correctly and
ConfigValidator.collectErrorsruns the extension beforecreateSink(so the stated ordering/--checkbenefit is real), but the new validator only reproduces the oldlength() == 1check and therefore still admits values the writer cannot handle (multi-byte single chars,", newlines) when they are later passed as--format_csv_delimiter "<value>"at ClickhouseFileSinkWriter.java:279; the tests do not pin the default\tor the rule description; and the incompatible-changes text overstates the exception-type change since both paths surface asFactoryExceptionfromFactoryUtil.createAndPrepareSink.
Runtime chain I rechecked
FactoryUtil.createAndPrepareSink() FactoryUtil.java:252
-> ConfigValidator.of(context.getOptions()).validate(tableSinkFactory.optionRule()) FactoryUtil.java:252
-> ClickhouseFileSinkFactory.optionRule() ClickhouseFileSinkFactory.java:71
.optional(FILE_FIELDS_DELIMITER, Conditions.extension(FILE_FIELDS_DELIMITER, new SingleCharacterValidator())) ClickhouseFileSinkFactory.java:83-85
-> ConfigValidator.validate(rule) -> collectErrors() ConfigValidator.java:167-187
-> for constraint in rule.getValueConstraints(): skip if structurallyAbsentKeys / !isConstraintApplicable ConfigValidator.java:230-236
-> ConfigValidator.validate(Condition) ConfigValidator.java:498
-> ConditionEvaluators.evaluate(cur, config) ConfigValidator.java:503
-> EXTENSION evaluator: ext.evaluate(cfg, v) ConditionEvaluators.java:168-172
-> SingleCharacterValidator.evaluate(): value != null && value.length() == 1 ClickhouseFileSinkFactory.java:97-98
-> on false: errors.add(formatError(key, TYPE_VALUE, constraint.toString())) -> throw OptionValidationException ConfigValidator.java:239-243, 183
-> (only if validation passed) tableSinkFactory.createSink(context).createSink() FactoryUtil.java:260
-> ClickhouseFileSinkFactory.createSink(): ClickhouseProxy, getClickhouseTableSchema, ShardMetadata, proxy.close(), then FileReaderOption(..., readonlyConfig.get(FILE_FIELDS_DELIMITER), ...) ClickhouseFileSinkFactory.java:116-178 (old length()!=1 throw removed here)
-> ClickhouseFileSinkWriter: Collectors.joining(readerOption.getFileFieldsDelimiter()) ClickhouseFileSinkWriter.java:235
-> ClickhouseFileSinkWriter.generateClickhouseLocalFiles(): command.add("--format_csv_delimiter"); command.add("\"" + readerOption.getFileFieldsDelimiter() + "\"") ClickhouseFileSinkWriter.java:278-279
-> new ProcessBuilder("bash", "-c", String.join(" ", command)) ClickhouseFileSinkWriter.java:328
-> any Throwable from either step wrapped: throw new FactoryException("Unable to create a sink ...", t) FactoryUtil.java:261-265
Tests: ClickhouseFactoryTest.validateFileSink() -> ConfigValidator.of(ReadonlyConfig.fromMap(map)).validate(FILE_SINK_FACTORY.optionRule()) ClickhouseFactoryTest.java:57
Findings
Issue 1: SingleCharacterValidator checks Java String.length() == 1, which still admits delimiters that break the ClickhouseFile writer: non-ASCII single chars (multi-byte for ClickHouse's single-byte format_csv_delimiter), " (corrupts the quoted clickhouse local argument) and \n/\r (splits rows).
- Location:
seatunnel-connectors-v2/connector-clickhouse/src/main/java/org/apache/seatunnel/connectors/seatunnel/clickhouse/sink/file/ClickhouseFileSinkFactory.java:98 - Why it matters: The new rule is now the declared home for this constraint, so it is worth making it match the downstream consumer instead of porting the old
length() != 1check verbatim. ClickhouseFileSinkFactory.java:98accepts any string whose UTF-16 length is 1.ClickhouseFileSinkWriter.generateClickhouseLocalFilesthen passes that value as"\"" + delimiter + "\""to--format_csv_delimiter(ClickhouseFileSinkWriter.java:278-279), and ClickHouse requires that setting to be a single byte. A value such as§,→or a full-width comma is one Java char but two or three UTF-8 bytes, so it passes validation and then fails at commit time inclickhouse local.- A literal
"passes too and turns the argument into""";\nor\rpasses and, because the writer joins fields with the raw delimiter before appending\n(lines 235-236), splits every row into multiple CSV lines. - All of these surface after
--checkhas already reported the config as valid, which is the exact gap this PR set out to close. - Suggested fix: tighten
evaluateto require an ASCII char that is not",\nor\r, updatedescription()accordingly, and add rejection tests for a non-ASCII char and for". - Evidence:
seatunnel-connectors-v2/connector-clickhouse/src/main/java/org/apache/seatunnel/connectors/seatunnel/clickhouse/sink/file/ClickhouseFileSinkFactory.java:93 return "must be a single character";;seatunnel-connectors-v2/connector-clickhouse/src/main/java/org/apache/seatunnel/connectors/seatunnel/clickhouse/sink/file/ClickhouseFileSinkFactory.java:85 Conditions.extension(FILE_FIELDS_DELIMITER, new SingleCharacterValidator()));docs/en/connectors/sink/ClickhouseFile.md:115 character is rejected during option-rule validation, before the sink connects to ClickHouse. - Suggested fix: Now that this is the single declarative guard for
file_fields_delimiter, I'd make it match what the writer can actually consume.value.length() == 1is the UTF-16 length, butClickhouseFileSinkWriterhands the value toclickhouse local --format_csv_delimiterwrapped in double quotes (line 279) and uses it as the raw join separator before appending\n(lines 235-236). So a non-ASCII char like,(1 Java char, 3 UTF-8 bytes), a literal", or\n/\rall pass here and then fail or corrupt rows at commit time - after--checksaid the config was fine. Suggestvalue != null && value.length() == 1 && value.charAt(0) < 0x80 && value.charAt(0) != '"' && value.charAt(0) != '\n' && value.charAt(0) != '\r', adjustdescription()to say so, and add a rejection test for a non-ASCII char and for". - Severity: Medium
Issue 2: absentDelimiterSkipsValidationAndUsesDefault does not pin either half of its name: it cannot distinguish "constraint skipped" from "default \t validated", and the value != null branch of the validator is never exercised.
- Location:
seatunnel-connectors-v2/connector-clickhouse/src/test/java/org/apache/seatunnel/connectors/seatunnel/clickhouse/ClickhouseFactoryTest.java:65 - Why it matters: - The test (
ClickhouseFactoryTest.java:67-70) only callsvalidateFileSink(validFileSinkConfig())with the option absent. InConfigValidator, optional value constraints are skipped when the head option is absent (isConstraintApplicable->anyOrSegmentFullyPresent->hasOption, which isconfig.getOptional(option).isPresent()and does not consult the default), so the extension is never invoked. - If that framework behavior ever changed to evaluate defaults, the test would still pass because
\thas length 1; and if the default were changed to a multi-character string, nothing in this test would notice. The name promises two things and asserts neither. - The
value != nullguard inSingleCharacterValidator.evaluate(ClickhouseFileSinkFactory.java:98) is likewise unreachable throughConfigValidator, since absent options are skipped before the extension runs. - Suggested fix: rename the test to describe what it actually proves (e.g.
absentDelimiterPassesValidation), or add a direct unit test ofSingleCharacterValidatorcoveringnull-> false,"\t"-> true, and""/",,,"-> false. - Evidence:
seatunnel-connectors-v2/connector-clickhouse/src/test/java/org/apache/seatunnel/connectors/seatunnel/clickhouse/ClickhouseFactoryTest.java:66 validateFileSink(validFileSinkConfig());;seatunnel-connectors-v2/connector-clickhouse/src/main/java/org/apache/seatunnel/connectors/seatunnel/clickhouse/sink/file/ClickhouseFileSinkFactory.java:98 return value != null && value.length() == 1; - Suggested fix: This passes for two different reasons that the test cannot tell apart:
ConfigValidatorskips optional value constraints whose head option is absent (hasOptionignores defaults), and even if it did evaluate the default,\tis one char. Neither "skips validation" nor "uses default" is asserted, and thevalue != nullbranch inSingleCharacterValidator.evaluateis never reached through this path. Could you either rename this to something likeabsentDelimiterPassesValidation, or add a direct test ofSingleCharacterValidator(null-> false,"\t"-> true,""/",,,"-> false)? It is package-private, so a small test in the factory's package would do. - Severity: Low
Issue 3: Default \t is never exercised by the new tests even though ConfigValidator skips optional value constraints when the key is absent; the "UsesDefault" test asserts nothing about the default and the rejection tests do not pin the error description
- Location:
seatunnel-connectors-v2/connector-clickhouse/src/test/java/org/apache/seatunnel/connectors/seatunnel/clickhouse/ClickhouseFactoryTest.java:69 - Why it matters: -
absentDelimiterSkipsValidationAndUsesDefault(ClickhouseFactoryTest.java:67-70) only callsvalidateFileSink(validFileSinkConfig()); nothing about the default is asserted. InConfigValidator.isConstraintApplicable/anyOrSegmentFullyPresent, an optional constraint is skipped wheneverhasOptionis false, so if someone later changesFILE_FIELDS_DELIMITER.defaultValue()to a multi-character string, the rule silently never runs against it and the sink only fails later inclickhouse local. - The two rejection tests (
ClickhouseFactoryTest.java:79-81and:91-93) assert only that the message containsfile_fields_delimiter, whichformatErroradds for every failing value constraint on this key. They do not pin the rule textmust be a single character, so a different constraint firing on the same key would still pass. - Suggested fix: add an assertion that
FILE_FIELDS_DELIMITER.defaultValue()satisfies the validator (directly or via a config that sets the option to"\t"), and extend the rejection assertions withcontains("must be a single character"). - Evidence:
seatunnel-connectors-v2/connector-clickhouse/src/test/java/org/apache/seatunnel/connectors/seatunnel/clickhouse/ClickhouseFactoryTest.java:69 validateFileSink(validFileSinkConfig());;seatunnel-connectors-v2/connector-clickhouse/src/test/java/org/apache/seatunnel/connectors/seatunnel/clickhouse/ClickhouseFactoryTest.java:80 exception.getMessage().contains("file_fields_delimiter"), - Suggested fix: The method name says "UsesDefault" but nothing asserts anything about the default. Because
ConfigValidatorskips optional value constraints when the key is absent (isConstraintApplicable→anyOrSegmentFullyPresent→hasOption), the\tdefault is never run throughSingleCharacterValidatoranywhere. Could you add an assertion thatFILE_FIELDS_DELIMITER.defaultValue()passes the validator so a future default change cannot silently bypass the rule? While here, the two rejection tests only check the key appears in the message (whichformatErroralways adds); assertingcontains("must be a single character")as well would pin the description. - Severity: Low
Issue 4: The delimiter is concatenated into a bash -c command line; the new validator is the only gate and still admits shell-significant single characters (", \, `, $)
- Location:
seatunnel-connectors-v2/connector-clickhouse/src/main/java/org/apache/seatunnel/connectors/seatunnel/clickhouse/sink/file/ClickhouseFileSinkFactory.java:85 - Why it matters: - The value validated at
ClickhouseFileSinkFactory.java:98is forwarded verbatim viaFileReaderOptiontoClickhouseFileSinkWriter, where it is wrapped in double quotes (ClickhouseFileSinkWriter.java:279) and joined into a single string executed withnew ProcessBuilder("bash", "-c", String.join(" ", command))(line 328). - The one-character bound this PR preserves is what prevents a multi-character payload from being injected, so it is worth keeping strict. Within that bound, a single
"turns the argument into"""(an empty delimiter as far as bash is concerned), a single\escapes the closing quote, and`or$start shell substitution; each breaks the quoting of the command line. - The resulting failure is reported as a generic
ClickhouseConnectorErrorCode.FILE_NOT_EXISTS(lines 355/361), which gives the operator no hint that the delimiter was the cause. - Suggested fix: reject
",\,`and$inSingleCharacterValidator(this overlaps with the ASCII/no-quote tightening suggested in the Robustness finding), and as a follow-up consider passing the arguments directly toProcessBuilderinstead of throughbash -c. - Evidence:
seatunnel-connectors-v2/connector-clickhouse/src/main/java/org/apache/seatunnel/connectors/seatunnel/clickhouse/sink/file/ClickhouseFileSinkFactory.java:85 Conditions.extension(FILE_FIELDS_DELIMITER, new SingleCharacterValidator())) - Suggested fix: Worth noting while we are making this the declarative rule:
file_fields_delimiteris concatenated into abash -cstring inClickhouseFileSinkWriter("\"" + delimiter + "\""at line 279, executed viaProcessBuilder("bash", "-c", String.join(" ", command))at line 328). The single-char bound already blocks real payloads, but",\,`and$still break the quoting and make clickhouse-local fail with only a genericFILE_NOT_EXISTS. Since this extension is now the one place the value is checked, I'd reject those four characters here too (and ideally, as a follow-up, dropbash -cin favour of passing args straight toProcessBuilder). - Severity: Low
Issue 5: Incompatible-changes entry says the failure type becomes OptionValidationException instead of ClickhouseConnectorException, but at job submission both old and new errors surface wrapped in FactoryException from FactoryUtil.createAndPrepareSink; the entry should say the cause changes.
- Location:
docs/en/introduction/concepts/incompatible-changes.md:243 - Why it matters: - The new entry (docs/en/introduction/concepts/incompatible-changes.md:243, and the zh mirror at :215) tells operators that "Anything that matches on the old exception type has to be updated" and to match on
OptionValidationExceptioninstead. - In the real submission path,
FactoryUtil.createAndPrepareSinkrunsConfigValidator.of(context.getOptions()).validate(tableSinkFactory.optionRule())(FactoryUtil.java:252) andtableSinkFactory.createSink(context)(line 260) inside the sametry, and rethrows anyThrowableasFactoryException("Unable to create a sink for identifier ...", t)(lines 261-265). So the top-level exception type wasFactoryExceptionbefore this change and remainsFactoryExceptionafter it; what changes isgetCause()(ClickhouseConnectorException->OptionValidationException) and the message text. - As written, an operator who follows the migration advice and matches on a bare
OptionValidationExceptionat the top level will miss the error. - Suggested fix: phrase the Impact/Migration lines in terms of the wrapped cause and the new message (
'file_fields_delimiter' must be a single character), in both the en and zh entries. - Evidence:
docs/en/introduction/concepts/incompatible-changes.md:244 - **Migration Guide**: ... If you match on the exception type, match onOptionValidationExceptioninstead.;docs/zh/introduction/concepts/incompatible-changes.md:215 - **影响**:... 异常类型由ClickhouseConnectorException(CONFIG_VALIDATION_FAILED)变为OptionValidationException。 - Suggested fix: Small precision point: in the actual job-submission path
FactoryUtil.createAndPrepareSinkwraps both theConfigValidator.validate(...)call andcreateSink(...)in the sametryand rethrows asFactoryException("Unable to create a sink for identifier ...", t). So the top-level type users and log-matchers see isFactoryExceptionbefore and after this change; what changes isgetCause()(ClickhouseConnectorException->OptionValidationException). I'd phrase the Impact/Migration lines in terms of the cause (and the new message'file_fields_delimiter' must be a single character) so nobody matches on a bareOptionValidationExceptionand misses it. Same for the zh entry. - Severity: Low
Issue 6: The new en/zh prose says the check runs 'before the sink connects to ClickHouse' and that --check reports it, but the options table still describes the constraint only as 'exactly one character' and the zh connector doc gained the behavior sentence without the matching table/description wording; also the en wording duplicates the incompatible-changes entry rather than stating the user-facing constraint.
- Location:
docs/en/connectors/sink/ClickhouseFile.md:114 - Why it matters: - docs/en/connectors/sink/ClickhouseFile.md:113-116 and docs/zh/connectors/sink/ClickhouseFile.md:105 now describe where validation happens (option-rule stage, before connecting,
--check). That is accurate:FactoryUtil.createAndPrepareSinkvalidates the option rule at FactoryUtil.java:252 beforecreateSinkopensClickhouseProxyat ClickhouseFileSinkFactory.java:116, and--checkis a real flag (AbstractCommandArgs.checkConfig). - However, the connector page is the reference users read for what a value may be; the validation mechanics are already covered by the incompatible-changes entry, so repeating them here adds length without adding a constraint users can act on. The options table at line 41 (zh: line 40) still just lists the default
"\t"with no hint of the single-character rule. - If the validator is tightened as suggested in the Robustness finding (ASCII, no
"/CR/LF), the docs, the options table anddescription()need to state the same rule so that "config names, defaults, and examples match the code exactly". - Suggested fix: reduce the per-option prose to one sentence on the allowed value plus a short note that invalid values are rejected at config validation /
--check, and mirror the allowed-value rule in the options table on both the en and zh pages. - Evidence:
docs/en/connectors/sink/ClickhouseFile.md:114 The constraint is declared in the sink's option rule, so an empty value or a value longer than one;docs/en/connectors/sink/ClickhouseFile.md:116--checkreports it too.;docs/zh/connectors/sink/ClickhouseFile.md:105 ...该约束声明在 Sink 的选项规则中,因此空值或长度大于一个字符的值会在选项规则校验阶段被拒绝,早于 Sink 连接 ClickHouse;--check同样会报告该错误。 - Suggested fix: The statement is correct (option-rule validation in
FactoryUtil.createAndPrepareSinkruns beforecreateSinkopens theClickhouseProxy), but connector docs are where users look up what values are allowed; the option-rule mechanics are already covered by your incompatible-changes entry. I'd keep this to one sentence about the allowed value (and, if you adopt the ASCII / no-"/CR/LF tightening, state that here and in the options table at line 41 so docs,description()and code match exactly) plus a note that invalid values are rejected at config validation /--check. Same applies to the zh page. - Severity: Low
Issue 7: Rejection tests only assert the option key appears in the message, not the rule text, so a regression that swaps in a different/unrelated constraint on file_fields_delimiter would still pass
- Location:
seatunnel-connectors-v2/connector-clickhouse/src/test/java/org/apache/seatunnel/connectors/seatunnel/clickhouse/ClickhouseFactoryTest.java:80 - Why it matters: -
ClickhouseFactoryTest.java:80and:92assertexception.getMessage().contains("file_fields_delimiter").ConfigValidator.validateformats every value error asformatError(key, "value", constraint.toString()), so the key is present for any failing constraint on this option; the assertion does not pin that this validator fired. - The user-facing part of the error is the
description()string (must be a single character), which is also what the generated option-rule metadata exposes. If someone replaced the extension with, say, anotBlankcondition,emptyDelimiterIsRejectedwould still pass andmultiCharacterDelimiterIsRejectedwould be the only signal. - Suggested fix: add
Assertions.assertTrue(exception.getMessage().contains("must be a single character"))to both rejection tests. - Evidence:
seatunnel-connectors-v2/connector-clickhouse/src/test/java/org/apache/seatunnel/connectors/seatunnel/clickhouse/ClickhouseFactoryTest.java:92 exception.getMessage().contains("file_fields_delimiter"),;seatunnel-connectors-v2/connector-clickhouse/src/test/java/org/apache/seatunnel/connectors/seatunnel/clickhouse/ClickhouseFactoryTest.java:81 Assertions.assertTrue( exception.getMessage().contains("file_fields_delimiter"),;seatunnel-connectors-v2/connector-clickhouse/src/test/java/org/apache/seatunnel/connectors/seatunnel/clickhouse/ClickhouseFactoryTest.java:68 public void absentDelimiterSkipsValidationAndUsesDefault() { validateFileSink(validFileSinkConfig()); - Suggested fix: This only proves some value constraint on
file_fields_delimiterfailed —ConfigValidatoralways prefixes the key. Could you also assert the rule text (must be a single character) so the test pins thatSingleCharacterValidatoris the one firing? Same foremptyDelimiterIsRejectedbelow. - Severity: Low
Issue 8: Nested validator class could be private static final; a one-line Conditions.matches would also work but the custom description is arguably clearer — your call
- Location:
seatunnel-connectors-v2/connector-clickhouse/src/main/java/org/apache/seatunnel/connectors/seatunnel/clickhouse/sink/file/ClickhouseFileSinkFactory.java:90 - Why it matters: -
static class SingleCharacterValidatoratClickhouseFileSinkFactory.java:90is package-private and not referenced outside the factory (the test lives in...connectors.seatunnel.clickhouse, a different package, and only goes throughoptionRule()). Per the project's "keep APIs minimal; prefer package-private/private" convention it can beprivate static finalunless you decide to unit-test it directly (see the Test findings, in which case package-private plus a test in the same package is fine). Conditions.matches(Option<T>, T regex)(Conditions.java:84) already exists, soConditions.matches(FILE_FIELDS_DELIMITER, "(?s)^.$")would express the same constraint without a nested class; the trade-off is that the generated error/metadata text would show the regex rather than the readablemust be a single character, which is a reasonable reason to keep the extension.- Evidence:
seatunnel-connectors-v2/connector-clickhouse/src/main/java/org/apache/seatunnel/connectors/seatunnel/clickhouse/sink/file/ClickhouseFileSinkFactory.java:85 Conditions.extension(FILE_FIELDS_DELIMITER, new SingleCharacterValidator())) - Suggested fix: Nit: this class is only used inside the factory, so
private static final classwould match our "keep visibility minimal" convention — unless you plan to reference it from a test for a default-value assertion, in which case package-private is fine. (For the record,Conditions.matches(FILE_FIELDS_DELIMITER, "(?s)^.$")would also do the job, but I think the explicit "must be a single character" description is worth the small class.) - Severity: Low
Review conclusion
Conclusion: final approval remains pending on the previous comments
2. Remaining follow-ups
- Issue 1: SingleCharacterValidator checks Java
String.length() == 1, which still admits delimiters that break the ClickhouseFile writer: non-ASCII single chars (multi-byte for ClickHouse's single-byteformat_csv_delimiter),"(corrupts the quotedclickhouse localargument) and\n/\r(splits rows). - Issue 2:
absentDelimiterSkipsValidationAndUsesDefaultdoes not pin either half of its name: it cannot distinguish "constraint skipped" from "default\tvalidated", and thevalue != nullbranch of the validator is never exercised. - Issue 3: Default
\tis never exercised by the new tests even though ConfigValidator skips optional value constraints when the key is absent; the "UsesDefault" test asserts nothing about the default and the rejection tests do not pin the error description - Issue 4: The delimiter is concatenated into a
bash -ccommand line; the new validator is the only gate and still admits shell-significant single characters (",\,`,$) - Issue 5: Incompatible-changes entry says the failure type becomes
OptionValidationExceptioninstead ofClickhouseConnectorException, but at job submission both old and new errors surface wrapped inFactoryExceptionfromFactoryUtil.createAndPrepareSink; the entry should say the cause changes. - Issue 6: The new en/zh prose says the check runs 'before the sink connects to ClickHouse' and that
--checkreports it, but the options table still describes the constraint only as 'exactly one character' and the zh connector doc gained the behavior sentence without the matching table/description wording; also the en wording duplicates the incompatible-changes entry rather than stating the user-facing constraint. - Issue 7: Rejection tests only assert the option key appears in the message, not the rule text, so a regression that swaps in a different/unrelated constraint on
file_fields_delimiterwould still pass - Issue 8: Nested validator class could be
private static final; a one-lineConditions.matcheswould also work but the custom description is arguably clearer — your call
Thanks for the updates so far. Happy to discuss the remaining points.
Resolve the merge conflicts with dev: keep both sides' additions (imports, constants and tests) and apply the project formatter. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
gonna close this one. DanielLeens flagged a High blocking issue back in September that I never came back to, so it isn't going anywhere as-is. sorry for leaving it sitting so long. |

Purpose of this pull request
This migrates the
file_fields_delimitersingle-character constraint of the ClickhouseFile sink to the declarative option rule framework (#11007).What changed
ClickhouseFileSinkFactory.createSinkas an imperativeif (...) throw ...check, so it only ran after a sink writer had already been created. It is now declared inoptionRule()viaConditions.extension(...), so the same rule is evaluated during option-rule validation (--check/--dry-run) instead of at runtime.SeaTunnelAPIErrorCode/ClickhouseConnectorExceptionimports it pulled in.Tests
Extended
ClickhouseFactoryTestto validate the rule end-to-end throughConfigValidator:\tis used)Docs
docs/enanddocs/zhthat the constraint is now checked during option-rule validation.docs/en+docs/zhincompatible-changesentry for the check-time behavior change.Related
Part of the declarative OptionRule migration tracking in #11007.