Skip to content

[Fix][Connector-V2] Pulsar Source: implement text format support (#11620) - #11631

Closed
waterWang wants to merge 2 commits into
apache:devfrom
waterWang:fix/pulsar-source-text-format
Closed

waterWang wants to merge 2 commits into
apache:devfrom
waterWang:fix/pulsar-source-text-format

Conversation

@waterWang

Copy link
Copy Markdown

Description

The Pulsar Source option contract and factory OptionRule claim that format = text is supported, but the runtime validation and deserialization path reject it:

  1. PulsarSourceFactory OptionRule binds field_delimiter when format = text
  2. PulsarBaseOptions.FORMAT description says "Optional text and avro format"
  3. Pulsar Sink already supports text format via TextSerializationSchema
  4. The seatunnel-format-text dependency is already present in connector-pulsar

However, PulsarMultiTableConfig.validateFormat() only allows JSON, CANAL_JSON and AVRO, and PulsarSource.createDeserialization() has no TEXT branch.

Changes

  1. PulsarMultiTableConfig.java — Allow TEXT in validateFormat() so that format = text passes configuration validation.

  2. PulsarSource.java — Add a TEXT case in createDeserialization() that returns a TextDeserializationSchema configured with the user-specified field_delimiter. The schemaConfig (ReadonlyConfig) is now passed through to createDeserialization() so it can read FIELD_DELIMITER.

Verification

After this fix, a Pulsar Source with format = text and field_delimiter = "," will:

  • Pass configuration validation
  • Use TextDeserializationSchema to deserialize text-format messages
  • Work with the existing seatunnel-format-text dependency

Fixes #11620

@davidzollo

Copy link
Copy Markdown
Contributor

Good job.

Thanks a lot for your valuable contribution to Apache SeaTunnel!

To pass the automated CI checks for this PR, could you please enable CI workflows in your forked repository first? You can refer to the check run link below as a reference for the required CI configuration https://github.com/apache/seatunnel/pull/11631/checks?check_run_id=91602399919

If you run into any trouble enabling CI or encounter related errors during the process, feel free to leave a comment here. Contributors are always ready to offer help~

image

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

Findings\n\n### [P1] Fix the Spotless violations before relying on CI\n\nRunning the module check against this head fails in PulsarSource.java. Spotless reports three changed-file violations: TextDeserializationSchema is imported before the json imports, the createDeserialization(...) call around lines 203-206 needs the formatter's multiline layout, and the delimiter(...) call around lines 281-282 must be kept on one line. The current GitHub Build is also failing, so this head is not merge-ready even though the implementation is small. Please run spotless:apply and rerun the checks.\n\n### [P1] Add a regression test for the new source TEXT path\n\nThe PR changes the user-facing contract from rejecting format=TEXT to constructing a TextDeserializationSchema, but it adds no tests. PulsarSourceTest and PulsarMultiTableConfigTest still cover JSON/AVRO/config behavior only. Please add at least a source test that builds a single-table TEXT config with a non-default field_delimiter, constructs the source, obtains the configured deserializer through the normal source path, and verifies a delimited payload becomes the expected SeaTunnelRow. Also cover a tables_configs entry so the merged per-table schemaConfig cannot silently lose the delimiter. This is especially important because the PR changes the createDeserialization signature and threads a new config object through the metadata construction path.\n\n### [P2] Keep the invalid-format message consistent with the accepted formats\n\nAfter adding TEXT to validateFormat(), the exception at PulsarMultiTableConfig.java:330 still says that only JSON, CANAL_JSON and AVRO are supported. An actually invalid format will now produce a misleading message. Include TEXT in the message or derive it from the same accepted-format definition.\n\n## Verification notes\n\n- Local spotless:check reproduces the changed-file formatting failures above.\n- The GitHub Build check is currently failing because CI is not enabled for the fork.\n- The source/config test run could not be completed locally because the temporary source snapshot cannot compile the existing generated config-shade classes; this does not replace the missing PR regression coverage.

@DanielLeens DanielLeens left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for working on this. I reviewed the full current head 544fff2d51.

+1 to @nielifeng's earlier Spotless point on this head. I am not going to duplicate that finding as a separate numbered Daniel issue. On top of that, I found two more current-head blockers below.

PR solves what problem

  • User pain: the Pulsar source currently rejects format = text, so users cannot consume text payloads through the Pulsar source path even though the sink side already supports text formatting.
  • Fix approach: allow TEXT in Pulsar source validation and build a TextDeserializationSchema with the configured field delimiter.
  • One-line summary: the feature direction is reasonable, but the current head still is not mergeable because the branch is stacked on unrelated commits and the new Pulsar source path is not covered by focused tests.

I. Code change review

1.1 Core logic analysis

Precise change:

  • PulsarMultiTableConfig.validateFormat(...) now accepts TEXT.
  • PulsarSource.createDeserialization(...) now builds TextDeserializationSchema and threads FIELD_DELIMITER from the schema config.

Before / After:

  • Before: the Pulsar source rejected TEXT format and never built a text deserializer.
  • After: the source accepts TEXT and routes it through TextDeserializationSchema.
  • But the current head also includes commit 6bf786bee7 and commit ac8306f332, which are unrelated to Pulsar source text-format support.

Key findings:

  • The intended source-path addition is straightforward.
  • The review head is not isolated to that scope.
  • I did not find any focused Pulsar-source test covering the new TEXT validation/deserialization path on this head.
  • I do not want to merge an uncovered new source path on top of a stacked branch.

Logic correctness / runtime path:

Pulsar source startup
  -> createConsumerMetadata(...)
      -> createDeserialization(format, catalogTable, schemaConfig)
          -> TEXT
              -> TextDeserializationSchema.builder()
                 .seaTunnelRowType(...)
                 .delimiter(schemaConfig.get(FIELD_DELIMITER))

Validation path
  -> PulsarMultiTableConfig.validateFormat(...)
      -> now accepts TEXT

1.2 Compatibility impact

  • Intended feature change is backward compatible.
  • The stacked unrelated commits make the current head non-isolated.

1.3 Performance / side-effect analysis

  • The new text-deserialization path is cheap.
  • The real risk here is correctness coverage, not runtime cost.

1.4 Error handling and logs

Problem 1: current head is stacked on unrelated commits

  • Location: seatunnel-api/src/main/java/org/apache/seatunnel/api/sink/multitablesink/SchemaChangeBarrier.java, seatunnel-connectors-v2/connector-file/connector-file-base/src/main/java/org/apache/seatunnel/connectors/seatunnel/file/source/reader/AbstractReadStrategy.java
  • Problem description: besides the Pulsar source change, this review head also carries unrelated schema-evolution and file-reader commits (6bf786bee7, ac8306f332).
  • Potential risk: the PR can no longer be reviewed or merged as a focused Pulsar-source change.
  • Best improvement suggestion: rebase/split the branch so this PR only contains the Pulsar text-format work.
  • Severity: High
  • Already raised by others: No

Problem 2: the new Pulsar source TEXT path is missing focused test coverage

  • Location: seatunnel-connectors-v2/connector-pulsar/src/main/java/org/apache/seatunnel/connectors/seatunnel/pulsar/source/PulsarSource.java:265, seatunnel-connectors-v2/connector-pulsar/src/main/java/org/apache/seatunnel/connectors/seatunnel/pulsar/config/PulsarMultiTableConfig.java:320
  • Problem description: the PR adds a new accepted format and a new deserializer branch, but the current head does not add a focused Pulsar-source unit/integration test for that path.
  • Potential risk: validation can drift from runtime behavior, delimiter handling can break silently, and the new format support may regress without any Pulsar-specific signal.
  • Best improvement suggestion: add at least a focused Pulsar-source test that covers format = text and delimiter wiring on the source side.
  • Severity: High
  • Already raised by others: No

II. Code quality assessment

2.1 Code style

The implementation is readable, aside from the separate Spotless issue already raised by @nielifeng.

2.2 Test coverage and stability

Current coverage is insufficient for the new Pulsar source path because there is no focused test for TEXT support.

2.3 Documentation updates

If this lands, the user-facing Pulsar source docs/examples should also mention TEXT support explicitly.

III. Architecture

3.1 Solution elegance

The intended source-path addition is precise.

3.2 Maintainability

It will be maintainable once the branch is isolated and the new path has dedicated tests.

3.3 Extensibility

Adding source-side text support is reusable for future Pulsar-source enhancements.

3.4 Historical compatibility

Compatible after the blockers are fixed.

IV. Problem summary

No. Problem Location Severity
1 Current head is stacked on unrelated commits SchemaChangeBarrier.java, AbstractReadStrategy.java High
2 New Pulsar source TEXT path is missing focused test coverage PulsarSource.java:265, PulsarMultiTableConfig.java:320 High

V. Merge conclusion

Conclusion: can merge after fixes

  1. Blocking items
  • Problem 1: please split/rebase the branch so the PR only contains the Pulsar text-format work.
  • Problem 2: please add focused Pulsar-source coverage for the new TEXT path.
  1. Suggested follow-ups
  • Also fix the Spotless issue already raised by @nielifeng on this head.

Overall, the feature idea makes sense. The blockers are the current head composition and the missing Pulsar-specific coverage.

@davidzollo

Copy link
Copy Markdown
Contributor

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 😄

@nzw921rx

Copy link
Copy Markdown
Member

PR #11792 Merged, Thank you for your efforts.

@nzw921rx nzw921rx closed this Sep 14, 2026
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.

[Bug] [Connector-V2] Pulsar Source declares text format support but runtime rejects it

5 participants