Skip to content

[Docs][Transform-V2] Rewrite DataValidator documentation - #13379

Merged
nzw921rx merged 3 commits into
apache:devfrom
niumy0701:docs/transform-v2-datavalidator
Nov 27, 2026
Merged

nzw921rx merged 3 commits into
apache:devfrom
niumy0701:docs/transform-v2-datavalidator

Conversation

@niumy0701

Copy link
Copy Markdown
Contributor

Purpose of this pull request

Purpose

Rewrite docs/en/transforms/data-validator.md and docs/zh/transforms/data-validator.md to the connector documentation standard, as part of the Transform-V2 documentation tracker #12809 (DataValidator slice, claimed there).

What changed

  • Add the missing ## Support Those Engines section.
  • Convert the options table to the five-column standard (Name / Type / Required / Default / Description), including the conditional requirements (field_rules for the transform-level rule and for every table_transform entry; row_error_handle_way.error_table when rows are routed) and the multi-table options table_match_regex, table_transform and rule_match_mode.
  • One ### <option> [type] section per option, covering behavior verified against the code: the two equivalent field_rules shapes (nested / flat, with flat entries of the same field merged into one field rule), submission-time validation of every entry (nonblank field_name plus rule_type or a non-empty rules list), skip-with-warning for fields absent from the input schema and for unknown rule types, the five supported rule types (NOT_NULL / RANGE / LENGTH / REGEX / UDF) with their parameters and comparison details, the three row_error_handle_way policies (FAIL / SKIP / ROUTE_TO_TABLE), the fixed five-column schema of routed error records, the error-table path resolution (plain name = same database/schema; a dotted path is used as-is), and the duplicate-path rule_match_mode behavior (omitting the option rejects duplicate table_path entries).
  • Add a ## Multi-Table Configuration section with the rule resolution order (entries → transform-level rule gated by table_match_regex → pass-through), and the DataValidator-specific policy semantics: row_error_handle_way and row_error_handle_way.error_table are error-handling policies configured once at the transform level that also apply to tables selected by a table_transform entry unless the entry overrides them. The EN and ZH pages describe these multi-table semantics identically.
  • Rewrite the examples as three complete runnable batch configurations covering the three usage shapes (transform-level rule only with ROUTE_TO_TABLE / transform-level rule plus per-table rules / per-table rules only), with deterministic FakeSource rows, expected outputs, and a sample routed error record.
  • Add a ## Developing a Custom UDF Rule section covering the DataValidatorUDF interface, @AutoService registration via the Java ServiceLoader, and a complete custom validation function example.

Code referenced for accuracy

  • DataValidatorTransformConfig.java (option keys, types, defaults)
  • DataValidatorTransformFactory#optionRule() (declarative validation)
  • DataValidatorTransform.java (row-level validation without fail-fast, FAIL / SKIP / ROUTE_TO_TABLE error handling, the fixed error-record schema)
  • FieldValidator.java and the rule/ implementations NotNullValidationRule, RangeValidationRule, LengthValidationRule, RegexValidationRule, UDFValidationRule (rule semantics, parameter parsing, custom messages)
  • ValidationResultHandler.java (per-row result aggregation, collected error messages)
  • DataValidatorMultiCatalogTransform / AbstractMultiCatalogTransform (multi-table rule resolution, transform-level policy inheritance, rule_match_mode)
  • udf/DataValidatorUDF and udf/EmailValidator (built-in EMAIL function, ServiceLoader discovery)
  • Example expectations cross-checked against the existing e2e configs data_validator*.conf in seatunnel-transforms-v2-e2e-part-1 (notably data_validator_route_to_table.conf, data_validator_route_to_table_with_table_transform.conf and data_validator_table_transform_only.conf).

No code changes; documentation only.

Does this PR introduce any user-facing change?

How was this patch tested?

Check list

@niumy0701

Copy link
Copy Markdown
Contributor Author

@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 detailed rewrite and the source references! I checked both complete pages against the factory, multi-table wrapper, validation rules and job-graph parser. One runnable-example correction is required.

Reviewed head: c0ab00260c202ab50461ead5bdcfe79abd1b427d; base: dev; merge base: d1e1d79b9e09bf61ad57878b9887c7d173471f39. Local branch: seatunnel-review-13379-20261120. Change size: 2 files changed, 632 insertions(+), 418 deletions(-). Review time: 2026-11-20 12:05:16 EST (UTC-0500).

What Problem Does This PR Solve?

User pain point: Users need to know which table rule runs and where invalid rows go.

Fix approach: Rewrite both guides with option constraints, three complete job configurations and the UDF extension contract.

One-sentence summary and example: The guide explains how to validate several tables without changing valid rows. For example, age 200 becomes an error record in ROUTE_TO_TABLE mode, rather than reaching the valid-row output.

1. Code Change Review

1.1 Core Logic Analysis

Both data-validator.md files are the entire PR scope. The factory validates field rules; DataValidatorMultiCatalogTransform chooses exact table entries before root-rule regex matching and inherits only the error policies. DataValidatorTransform validates every configured field, aggregates failures, and either throws, drops the row or emits the five-column error record. Range, length, regex, UDF loading and error-path resolution match the described implementation. The Chinese second job has a different source alias key from the English job.

Before:

row_error_handle_way = "SKIP"
field_rules = [{ field_name = "name", rule_type = "NOT_NULL" }]

After:

FakeSource {
    plugin_input = "fake"
    tables_configs = [

Key Findings

  • The normal documented/job path reaches the behavior described below; this is not an unreachable recovery-only change.
  • The complete changed-file scope and related runtime contracts were checked; the numbered list is the complete finding set for this review.
  • The source/compatibility conclusion and the current CI/repository gate are assessed separately.

Complete runtime path and correctness boundary:

Saved HOCON -> ConfigParserUtil graph wiring -> FakeSource CatalogTables/rows
 -> DataValidatorTransformFactory.optionRule/createTransform
 -> AbstractMultiCatalogTransform: exact entry -> matching root rule -> identity
 -> DataValidatorMultiCatalogTransform.withGlobalPolicies
 -> DataValidatorTransform.transformRow -> FieldValidator.validate
 -> FAIL / SKIP / generated error row and schema -> Console

1.2 Compatibility Impact

Fully compatible. Only Markdown changes; APIs, option names/defaults, protocols, serialization and existing task behavior are unchanged.

1.3 Performance / Side-Effect Analysis

Markdown only: CPU, memory, GC, network, locks, retries, idempotency and resource ownership are unchanged. The guide describes existing per-row validation and error logging; it does not introduce a new runtime policy.

1.4 Error Handling and Logging

The affected initialization, validation and failure branches are described above. This review does not treat accepted enum syntax or a successful aggregate check as proof of runtime capability. No production exception/logging code is changed beyond the explicitly reviewed implementation.

Issue 1: Fix the source output alias in the Chinese mixed-rule example

  • Location: docs/zh/transforms/data-validator.md:245
  • Problem description: This source block sets plugin_input = "fake", while its downstream DataValidator consumes plugin_input = "fake". A source publishes its dataset through plugin_output. The English counterpart correctly uses plugin_output at line 245. ConfigParserUtil.checkExistTableId/checkInputId (lines 232-239 and 195-211) require or resolve the source output ID; plugin_input does not define it. The advertised complete Chinese job therefore cannot connect the source to the transform.
  • Potential risk: A reader copying this job fails during graph construction before any field validation occurs.
  • Best improvement: Change this one source key to plugin_output = "fake", matching the English example. Compare all three bilingual HOCON blocks after the correction; keep the runtime parser unchanged.
  • Root cause / best location / alternatives: The root cause and smallest safe fix are the translated example. A parser fallback would broaden the source contract and conceal the documentation error. The best general prevention is checking bilingual example wiring, without changing production behavior.
  • Severity: High; Blocking: Yes.
  • Raised by another reviewer: No.

2. Code Quality Assessment

2.1 Coding Standards

Checked changed-file scope, core contracts and explanatory comments. Documentation-only additions introduce no runtime methods/fields. Core documentation observations are included in this PR's analysis above. No unrelated connector registration, config compatibility, saved-job or import/export code was removed.

2.2 Test Coverage and Test Stability

No UT/E2E code changes. Static comparison covers all three fixed-input examples, exact table paths, valid/error counts and UDF signatures. The Chinese wiring defect is not exercised by the existing English-derived transform fixtures. No example was executed locally.

Local verification results: git fetch obtained this exact head; git diff origin/dev...seatunnel-review-13379-20261120, git show, and source searches supplied the file/call-chain evidence. git diff --check passed. Compilation, UT, integration tests, E2E, Docker and service/job execution were not run locally, as required for this review task. The comparison uses merge base d1e1d79b9e09bf61ad57878b9887c7d173471f39, not an assumption that the head contains all current dev commits.

2.3 Documentation Updates

Both languages are updated. Their rule descriptions largely agree, but the mixed-rule source alias must agree as described in Issue 1.

3. Architectural Soundness

3.1 Elegance of the Solution

Change-location assessment: Precise fix to documentation. The best location is the affected bilingual example and its option descriptions; changing the common parser or validator would be unnecessary scope. The minimal correction and the best production change are the same one-key documentation repair.

3.2 Maintainability

Keep the documented/implemented contract next to the responsible factory and runtime component. The requested corrections above identify the smallest responsible boundary and avoid unrelated changes.

3.3 Extensibility

Use existing connector/transform extension points; no new generic framework abstraction is needed for this scope.

3.4 Historical-Version Compatibility

Fully compatible. Only Markdown changes; APIs, option names/defaults, protocols, serialization and existing task behavior are unchanged.

4. Issue Summary

Complete-scan self-check: all changed files; affected entry/runtime/error paths; compatibility/default/state contracts; test assertions and stability; bilingual docs/examples/resources; change location and alternatives; current CI/conflict/review gates. No local runtime acceptance is claimed.

Number Issue Location Severity Blocking
1 Fix the source output alias in the Chinese mixed-rule example docs/zh/transforms/data-validator.md:245 High Yes

5. Merge Recommendation

Conclusion: Ready to merge after fixes

  1. Blockers — must be fixed

Issue 1. Current-head checks must be completed/accepted and the repository maintainer review gate must be satisfied. This COMMENT does not provide write-level approval or dismiss historical requested changes.

  1. Recommended fixes — non-blocking

None.

Overall assessment and alternatives: Precise fix to documentation. The best location is the affected bilingual example and its option descriptions; changing the common parser or validator would be unnecessary scope. The minimal correction and the best production change are the same one-key documentation repair.

Current CI and repository snapshot: no Apache check reported on the head; fork Build: success (attempt 1). GitHub merge state: BLOCKED; review decision: REVIEW_REQUIRED. Daniel repository permissions are pull=true, push=false, triage=false; effective maintainer approval remains separate.

Separate synchronization fact: base dev, head c0ab00260c202ab50461ead5bdcfe79abd1b427d, comparison ahead, ahead 2 / behind 0. This is queue metadata only; no synchronization request is made merely because a branch is behind.

@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.

The Apache CI fact in my previous full review is outdated: Build is now SUCCESS on this unchanged head, matching the successful fork run. That closes the previous missing/adoption check fact only. Issue 1 in my complete review remains: correct the Chinese DataValidator example's input wiring. A successful website/Build does not prove the example consumes the intended output.

Merge conclusion: Merge after the remaining recorded fixes/gates. No new numbered source finding or full source review is added. Effective approval/dismissal remains with a write-capable maintainer.

Checked unchanged head c0ab00260c202ab50461ead5bdcfe79abd1b427d against dev: compare diverged, ahead 2 / behind 3. This drift is recorded independently; it does not by itself request synchronization. This is a discussion/CI follow-up, not another full source review. No local build, test or runtime execution was performed. Daniel has READ repository permission; effective maintainer approval/dismissal remains a separate repository gate. Checked 2026-11-21T11:54:29.720270+00:00.

…mple

Change the mixed-rule example's FakeSource block from plugin_input to plugin_output so the copied job resolves the source dataset during graph construction, aligning the ZH page with the EN page (review issue 1 on apache#13379).
@niumy0701

niumy0701 commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor Author

The Apache CI fact in my previous full review is outdated: Build is now SUCCESS on this unchanged head, matching the successful fork run. That closes the previous missing/adoption check fact only. Issue 1 in my complete review remains: correct the Chinese DataValidator example's input wiring. A successful website/Build does not prove the example consumes the intended output.

Merge conclusion: Merge after the remaining recorded fixes/gates. No new numbered source finding or full source review is added. Effective approval/dismissal remains with a write-capable maintainer.

Checked unchanged head c0ab00260c202ab50461ead5bdcfe79abd1b427d against dev: compare diverged, ahead 2 / behind 3. This drift is recorded independently; it does not by itself request synchronization. This is a discussion/CI follow-up, not another full source review. No local build, test or runtime execution was performed. Daniel has READ repository permission; effective maintainer approval/dismissal remains a separate repository gate. Checked 2026-11-21T11:54:29.720270+00:00.

Fixed in e32e839: the mixed-rule example's FakeSource block in the ZH page now uses plugin_output = "fake", matching the EN page, so the copied job resolves the source dataset during graph construction.

Fork Build at this head: https://github.com/niumy0701/seatunnel/actions/runs/44965264399

@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.

Yes, contributing to Apache SeaTunnel. Thanks for correcting the Chinese source alias in e32e839! I re-read the entire diff and followed the configuration-to-validation path from scratch. My previous Issue1 is closed, both language examples now agree, and I found no remaining source-level blocker.

What problem does this PR solve?

User pain point: users cannot easily tell which table rule runs or how invalid rows reach an error sink.

Fix approach: rewrite both guides with actual option validation, rule matching/policy inheritance and complete fixed-row job examples.

One sentence: users can configure and predict DataValidator behavior from runnable wiring.

Example: age200 becomes an error_data record in ROUTE_TO_TABLE, while the three valid fixture rows keep their original schema.

1. Code changes

1.1 Core logic

Complete runtime path:

Saved HOCON -> ConfigParserUtil output/input ID validation -> FakeSource fixed rows/catalog tables
  -> DataValidatorTransformFactory option validation
  -> AbstractMultiCatalogTransform exact table entries, else root regex rule, else identity
  -> DataValidatorMultiCatalogTransform inherits missing global error policies
  -> DataValidatorTransform -> all field validators/results
  -> FAIL exception / SKIP null / five-column error row with target tableId
  -> produced validated+error CatalogTables -> multi-table Console sink
Custom UDF -> ServiceLoader registration -> function_name -> validate result.

Key findings and correctness:

Both full451-line pages and the complete diff were read, then checked against factory/config parsing, matching wrapper, field/result handling, range/length rules, error-table resolution and UDF interface. Source searches verified ConfigParserUtil.java:195-239 requires source plugin_output and resolves the transform plugin_input. The Chinese mixed-rule example now correctly publishes plugin_output at line245, closing my prior Issue1. A static extraction compared all five HOCON blocks in both languages, ignoring translated comments: all five are equal. Explicit FIRST_MATCH/ALL_MATCH and omitted-mode duplicate rejection match AbstractMultiCatalogTransform.java:62-73,128-159. Policy inheritance matches DataValidatorMultiCatalogTransform.java:74-83; unknown fields/types warn and skip as documented. The guides correctly distinguish per-row all-failure aggregation from the first invalid row stopping a FAIL job. No new source-level blocker found.

Before:

transform {
  DataValidator {
    plugin_input = "source_table"
    row_error_handle_way = "FAIL"
  }
}

After:

source { FakeSource { plugin_output = "fake" /* fixed rows and schema */ } }
transform { DataValidator { plugin_input = "fake"; plugin_output = "validated" } }
sink { Console { plugin_input = "validated" } }

The abbreviated block illustrates graph wiring; the complete guide blocks supply the actual valid HOCON rules and fixtures.

1.2 Compatibility

Fully compatible. Only existing Markdown guides change; public APIs, option keys/defaults, protocols, row/checkpoint formats and runtime behavior are unchanged. The rewrite documents existing fallback/duplicate/policy behavior rather than changing it.

1.3 Performance and side effects

Documentation only: no CPU/memory/GC/network/lock/retry/idempotency or resource-lifecycle change. Existing per-row validation/error logging and replay semantics remain. The guides do not introduce a new performance promise.

1.4 Errors, logging, and findings

No new source-level blocker found. Exceptions must still reach the existing job failure path; this review does not substitute for current-head CI.

Community reconciliation: there is no independent maintainer approval/change request in the collected history. The author response is addressed here in this single complete review; no separate acknowledgment comment is added.

2. Code quality

2.1 Conventions

Reviewed all changed files for license, imports, naming, core-method and state-field comments. No additional convention blocker found.

2.2 Test coverage and stability

Stability rating: Stable. Documentation-only change, no UT/E2E test modifications requiring a stability rating. Static checks covered all complete examples, exact alias/table paths, deterministic fixture counts, error schema/messages, null/range/length policies and UDF method signatures. Fixed fixtures are real FakeSource rows, not random expected values. Current-head fork Build44965264399 is successful and adopted Apache CI is recorded separately. No example, local build or test was executed; website/build success alone is not a runtime execution of these examples.

2.3 Documentation

English and Chinese descriptions and all five HOCON blocks agree after the source-alias correction. Required FakeSource/Console installation and saved-file CLI command are stated. The custom UDF code is a method/class illustration requiring normal imports and packaging; its interface signatures/default description are valid. Existing files are updated; no new licensed source file is introduced.

3. Architecture

3.1 Change location

A precise bilingual documentation correction. Keep example wiring and behavioral descriptions beside this transform; no parser fallback or validator code change is needed.

3.2 Maintainability

Keep the behavior, lifecycle ownership, and failure contract together. A precise bilingual documentation correction. Keep example wiring and behavioral descriptions beside this transform; no parser fallback or validator code change is needed.

3.3 Extensibility

Prefer the existing component boundary and tests over unrelated shared abstractions.

3.4 Upgrade impact

Fully compatible. Only existing Markdown guides change; public APIs, option keys/defaults, protocols, row/checkpoint formats and runtime behavior are unchanged. The rewrite documents existing fallback/duplicate/policy behavior rather than changing it.

4. Findings summary

Completeness check: All changed files and affected entry/failure paths were reviewed; configuration/serialization compatibility, test failure capability and stability, documentation/examples, change ownership, and current CI/conflict/review gates are covered above. No unreviewed source scope is claimed complete.

# Finding Location Severity
- No new source blocker found - -

5. Merge recommendation

Can merge once the recorded CI and repository gates are satisfied

Blocking items: No source blocker. Current-head CI and write-capable maintainer review remain independent requirements.

Non-blocking suggestions: None beyond the validation limits above.

Overall: the reviewed source path is coherent; no runtime acceptance is claimed beyond the actual CI result. Daniel has READ permission, so this COMMENT cannot dismiss historical requested changes or satisfy a write-capable maintainer approval gate.

CI and repository state: Signal pull request update: SUCCESS; Build: SUCCESS; Build: success. GitHub reports BLOCKED / REVIEW_REQUIRED.

Verification: Reviewed all changed files and the referenced call sites at e32e839f53db474e65c9d7f4db736b56946b49ef against merge base d1e1d79b9e09bf61ad57878b9887c7d173471f39. git diff --check passed. I did not build, run tests, or execute SeaTunnel locally.

Review time: 2026-11-23T07:47:37.445179-05:00

Local evidence: git fetch obtained head e32e839f53db474e65c9d7f4db736b56946b49ef; git merge-base returned d1e1d79b9e09bf61ad57878b9887c7d173471f39; git diff --stat reports 2 files changed, 632 insertions(+), 418 deletions(-). git show and source searches were used for the entry points above. No local build, unit test, E2E, Docker run or service startup was executed.

@niumy0701

Copy link
Copy Markdown
Contributor Author

Hi @davidzollo, since you recently merged the sibling PR #13270 (TextChunk docs), could you take a look at this one when you have a chance? It's part of the same Transform-V2 documentation series.

Current status, for convenience:

All review feedback has been addressed (the zh plugin_input alias was fixed in e32e839)
The reviewer confirmed "no remaining source-level blocker" in the latest review
CI is green: Build SUCCESS on head e32e839 (fork run 44965264399)
Thanks!

@DanielLeens

Copy link
Copy Markdown
Contributor

Thanks for the clear summary, @niumy0701. My existing technical clearance is unchanged on e32e839f53db: the alias fix is already accounted for and both Apache and exact-head fork Build report success. The next step is a write-capable maintainer's review; the sibling TextChunk merge does not replace that independent decision. No further documentation rewrite or CI workaround is requested from my side. Thank you for keeping this documentation series moving.

Discussion-only follow-up on unchanged head e32e839f53db474e65c9d7f4db736b56946b49ef; no new full source review or local build/test/runtime execution is claimed. Daniel has READ permission; effective maintainer approval and dismissal remain separate repository actions.

@nzw921rx nzw921rx left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

+1 good job

@nzw921rx
nzw921rx added this pull request to the merge queue Nov 27, 2026
Merged via the queue into apache:dev with commit ee0fb0d Nov 27, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants