Skip to content

[Improve][Connector-V2] Move numeric_special_value_as_null to JdbcSourceOptions - #12989

Merged
davidzollo merged 1 commit into
apache:devfrom
fatmanverse:move-numeric-special-option-to-source
Nov 7, 2026
Merged

davidzollo merged 1 commit into
apache:devfrom
fatmanverse:move-numeric-special-option-to-source

Conversation

@fatmanverse

Copy link
Copy Markdown
Contributor

Follow-up to #12874, as discussed there with @SEZ9 and @DanielLeens. Opened separately now that the test-side exclusion is on dev.

Purpose of this pull request

numeric_special_value_as_null (#12792) only applies to reading PostgreSQL numeric special values, and only JdbcSourceFactory declares it. It was defined in JdbcCommonOptions, so JdbcSinkOptions inherits it too, and JdbcOptionRuleCompletenessTest had to exclude it from the sink check (NOT_SINK_OPTIONS).

This PR defines the option where it applies:

  • Move NUMERIC_SPECIAL_VALUE_AS_NULL from JdbcCommonOptions to JdbcSourceOptions. The key, type, default (false) and description are unchanged.
  • Point the three references in JdbcConnectionConfig (field default, of(), builder default) at JdbcSourceOptions. JdbcSourceFactory already declares it as JdbcSourceOptions.NUMERIC_SPECIAL_VALUE_AS_NULL, which now resolves to the same field directly.
  • Remove the NOT_SINK_OPTIONS exclusion from JdbcOptionRuleCompletenessTest. The sink check passes without it because the sink options no longer see the key.
  • Keep testNumericSpecialValueAsNullIsSourceOnly, which checks that the source accepts the key and the sink rejects it.

Impact checked:

  • NUMERIC_SPECIAL_VALUE_AS_NULL is only referenced inside connector-jdbc. No other connector, CDC module, engine or core module uses it.
  • The CDC *IncrementalSourceOptions classes extend org.apache.seatunnel.connectors.cdc.base.option.JdbcSourceOptions, a different class, so they neither had nor gain the option.
  • [Fix][Connector-V2][Jdbc] Add numeric_special_value_as_null option for PostgreSQL #12792 is not in a release yet, so no released public constant moves.

Does this PR introduce any user-facing change?

No. The option key, type, default and behaviour are the same, and the sink still rejects the key in --check / --dry-run.

How was this patch tested?

On JDK 17 against dev eceeb0a:

  • ./mvnw -pl seatunnel-connectors-v2/connector-jdbc test: 1155 tests, 0 failures, 0 errors (6 skipped), including JdbcOptionRuleCompletenessTest (3 tests) with the exclusion removed.
  • ./mvnw -pl seatunnel-connectors-v2/connector-cdc/connector-cdc-postgres,seatunnel-connectors-v2/connector-cdc/connector-cdc-mysql -am install -DskipTests: builds.

Check list

…rceOptions

The option only applies to reading PostgreSQL numeric special values and
is declared by the Jdbc source only. Defining it in JdbcCommonOptions made
it visible through JdbcSinkOptions, so JdbcOptionRuleCompletenessTest had
to exclude it from the sink check. Moving it to JdbcSourceOptions makes the
exclusion unnecessary; testNumericSpecialValueAsNullIsSourceOnly still
checks that the source accepts the key and the sink rejects it.

Key, type, default and description are unchanged.

@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 splitting this out as a follow-up, @fatmanverse. This is a clean, well-scoped change and the impact analysis in the description matches what I found in the source.

What problem does this PR solve

  • Pain point: numeric_special_value_as_null (#12792) is only meaningful for reading PostgreSQL numeric special values, and only JdbcSourceFactory declares it. Because it was defined in JdbcCommonOptions, JdbcSinkOptions inherited it and JdbcOptionRuleCompletenessTest needed a NOT_SINK_OPTIONS exclusion to hide that.
  • Fix approach: define the option in JdbcSourceOptions (key, type, default and description unchanged), repoint the three references in JdbcConnectionConfig, and drop the test-side exclusion.
  • One sentence: the option now lives where it applies, so sink option collection no longer sees a source-only key.

1 Code change review

Core logic

Before:

// JdbcCommonOptions
public static final Option<Boolean> NUMERIC_SPECIAL_VALUE_AS_NULL = Options.key("numeric_special_value_as_null")...

After: the same declaration, verbatim, in JdbcSourceOptions. JdbcConnectionConfig (field default, of(), builder default) now reads JdbcSourceOptions.NUMERIC_SPECIAL_VALUE_AS_NULL.

What I verified at the head commit:

  • git grep for NUMERIC_SPECIAL_VALUE_AS_NULL / numeric_special_value_as_null shows no remaining reference to JdbcCommonOptions.NUMERIC_SPECIAL_VALUE_AS_NULL anywhere in main, test or e2e code. JdbcSourceFactory already referenced JdbcSourceOptions.NUMERIC_SPECIAL_VALUE_AS_NULL, which now resolves to the declared field directly instead of the inherited one.
  • The option is still declared in the source factory rule (JdbcSourceFactory optionRule), so --check / --dry-run continues to accept it for the source.
  • The two PostgreSQL E2E configs (jdbc_postgres_source_and_sink_numeric_special_value*.conf) set the key inside the jdbc { ... } source block only, so no E2E config is affected by the sink now rejecting it. (The sink already rejected it before this PR, because JdbcSinkFactory never declared it.)
  • The sink path: JdbcConnectionConfig.of(config) is shared by source and sink; the sink config never carries the key, so getOptional returns empty and the default false applies. Behavior is unchanged.
  • Documentation: the option is documented in docs/en and docs/zh connectors/source/Jdbc.md only, which is now consistent with where the option is defined.

Runtime path

Normal source path: JdbcSourceFactory option rule -> JdbcConnectionConfig.of(config) -> numericSpecialValueAsNull -> PostgresJdbcRowConverter. Only the constant's owning class changes; the key and value flow are identical, so this is a pure refactor with no runtime effect.

Compatibility

Fully compatible. The option key, type, default and description are unchanged. The only moved symbol is a Java constant. git tag --contains on the #12792 commit lists no release, so no released public constant moves (this agrees with the description). JdbcCommonOptions.NUMERIC_SPECIAL_VALUE_AS_NULL is no longer reachable, but I found no external user in the repo.

Performance and side effects

None. One trivial note: JdbcConnectionConfig, which is also used on the sink side, now touches JdbcSourceOptions for the default. Class initialization of that options class is cheap and is already triggered by the source factory in the same module.

Error handling and logging

No change.

Issues

No blocking or non-blocking issues found.

2 Code quality

  • Standards: change follows the existing option layout; no new files, so no license header concerns; imports are unchanged (same package).
  • Tests: JdbcOptionRuleCompletenessTest is strengthened rather than weakened in intent: the sink completeness check now runs over the full JdbcSinkOptions key set with an empty exclusion set, and testNumericSpecialValueAsNullIsSourceOnly still asserts that the source accepts the key and the sink rejects it. If someone moves the option back into the common class, the sink completeness test turns red; if someone removes it from the source rule, the source test turns red.
  • Stability rating: Stable. Pure reflection and rule validation, no timing, no shared state, no containers.
  • Docs: no update needed (en and zh unchanged and still accurate).

3 Architecture

  • Precise fix of the option ownership. It is the root-cause fix for the test exclusion rather than a workaround.
  • Maintainability: improves it, since the shared class again holds only genuinely shared options and the test needs no special case.
  • Extensibility: future source-only options have a clear precedent.
  • Historical compatibility: no user-visible change.

4 Issue summary

# Severity Item Blocking
- - None -

5 Merge recommendation

Conclusion: Ready to merge

Blockers: none from the code side.

Recommended non-blocking fixes: none.

CI: there is no Build check on the apache side yet for this head; the fork run is queued (https://github.com/fatmanverse/seatunnel/actions/runs/40302163202). Please make sure it finishes green before merge.

Overall: a minimal, behavior-preserving cleanup with solid test coverage. Nice work.

@DanielLeens

Copy link
Copy Markdown
Contributor

Thanks for the contribution. The CI fact cited in my previous conclusion has changed; this follow-up updates that gate on the unchanged reviewed head, without issuing another full source review.

Gate snapshot (2026-10-28T15:43:10+00:00), head ce088f1fe6be4e54d1739cd5a8986aaad1719a6e: Build is SUCCESS.

CI was previously the only remaining technical gate in my conclusion; CI is now passing, so that CI objection is withdrawn and my technical conclusion is clear to proceed. Daniel currently has READ permission. I have not changed the effective GitHub review state to APPROVED; a write-capable maintainer must perform the final approve/dismiss action required by branch protection.

Comparison recorded in this scan: base dev, diverged, ahead 1 / behind 38, no merge conflict. Branch drift is metadata here and is not an additional sync request.

@fatmanverse

fatmanverse commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor Author

Hi, this PR has been green and marked ready by @DanielLeens since 2026-10-28, and it still merges cleanly with current dev. Could a committer take a look when there is time? Thanks!

@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 your patience and for the follow-up. My earlier review of this exact head found no blockers and only noted that CI was still queued. The fork Build and the apache-side Build have both completed successfully on this head. The branch merges cleanly, though it is 62 commits behind dev. Nothing further from my side; approving.

Conclusion: Ready to merge

Blockers: none. Recommended non-blocking fixes: none beyond the optional Low items in my earlier review.

@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, appreciate your solid contribution, keep up the excellent work

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 😄

@davidzollo
davidzollo added this pull request to the merge queue Nov 7, 2026
Merged via the queue into apache:dev with commit 2298441 Nov 7, 2026
2 checks passed
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.

3 participants