Skip to content

[Feature][API] Add JSON logical type support - #11493

Draft
DanielLeens wants to merge 24 commits into
apache:devfrom
DanielLeens:davidzollo_json-type-10774
Draft

DanielLeens wants to merge 24 commits into
apache:devfrom
DanielLeens:davidzollo_json-type-10774

Conversation

@DanielLeens

@DanielLeens DanielLeens commented Jul 19, 2026 •

Copy link
Copy Markdown
Contributor

Purpose of this pull request

Add a String-backed JSON logical type and preserve native semi-structured JSON types across Snowflake, Doris, and StarRocks.

Closes #10774.

What is changed

  • Add SqlType.JSON and BasicType.JSON_TYPE without changing existing enum ordinals.
  • Parse json and array<json> schema declarations.
  • Preserve JSON objects, arrays, scalars, JSON null, and SQL null in the JSON format; reject empty, incomplete, and trailing-token input.
  • Treat JSON as its String physical representation in Spark translation, Arrow connector reads, Calcite SQL, Copy, JsonPath, CSV, and Avro.
  • Map Snowflake VARIANT to and from JSON and generate PARSE_JSON(:field) for generated INSERT and UPDATE statements.
  • Map Doris JSON and JSONB to SeaTunnel JSON and create native Doris JSON columns.
  • Map StarRocks native JSON bidirectionally in catalog discovery, conversion, and automatic table creation.
  • Serialize StarRocks JSON Stream Load fields as structured JSON instead of quoted strings; invalid JSON is rejected before loading.
  • Explicitly reject native JSON fields in StarRocks CSV Stream Load because StarRocks does not support JSON-formatted columns in CSV Stream Load.
  • Update the corresponding English and Chinese documentation, including the incompatible source-schema change and migration guidance.
  • Remove the duplicate setNullToStatementByDataType method currently present on dev, which otherwise prevents the touched JDBC module from compiling.

E2E coverage

The GitHub-CI-runnable coverage now exercises every in-repository runtime path changed by this PR:

  • Doris native JSON and JSONB catalog discovery, automatic native JSON table creation, and source-to-sink round trips.
  • StarRocks native JSON catalog discovery, automatic native JSON table creation, JSON Stream Load round trips, and explicit CSV Stream Load rejection.
  • Native connector value coverage includes objects, arrays, boolean, number and string scalars, explicit JSON null, and SQL NULL, with exact source-to-sink JSON tree comparisons.
  • LocalFile JSON and CSV round trips cover json, array<json>, structured values, scalars, explicit JSON null, and SQL NULL.
  • Kafka JSON validates raw structured Kafka records; Kafka Avro decodes records through the production Avro deserializer and validates JSON and SQL null independently.
  • Copy, JsonPath, and Calcite each have dedicated JSON logical type E2E jobs.
  • TestTemplate execution carries these paths through the supported SeaTunnel, Flink, and Spark test containers, subject to the existing module-specific Spark 2.4 exclusions.
  • JSON serialization regression coverage verifies a reused serializer cannot leak a prior non-null JSON field into a following SQL NULL row.

Snowflake remains the only external-environment exception. The repository Snowflake IT is class-level disabled and requires a real account. This PR includes catalog, type-conversion, generated INSERT and UPDATE PARSE_JSON, and null behavior regression tests, but real Snowflake TYPEOF, path query, JSON null, SQL NULL, and round-trip verification must be completed in a controlled account before the PR is moved out of Draft.

Compatibility

Appending JSON to SqlType preserves all existing enum ordinals. However, connector source schemas are intentionally changed for native semi-structured columns: Snowflake VARIANT, Doris JSON and JSONB, and StarRocks JSON now produce SeaTunnel JSON instead of STRING.

Pipelines that inspect source schemas or use a downstream component without JSON support must migrate explicitly. A Calcite Transform projection such as SELECT CAST(payload AS VARCHAR) AS payload, ... FROM source_table restores the previous String-backed schema and value behavior. Supported native JSON and VARIANT destinations should keep the JSON type. StarRocks native JSON fields require starrocks.config.format = "JSON".

Verification

Per project-owner instruction, local validation for the final PR head is limited to formatting and static checks. All compilation, unit, integration, and E2E execution is delegated to GitHub CI.

  • Spotless for the affected modules: passed.
  • git diff --check: passed.
  • Independent QA review: PASS-to-push-draft.
  • Independent Maintainer review: PASS-to-push-draft.
  • Local compilation, unit tests, integration tests, E2E, Docker, packaging, and service execution: intentionally not run.
  • GitHub CI: pending for commit 5da55403e1a68341561fa362526dbc4ae5ae1287.

The PR remains Draft while GitHub CI validates the final head.

Maintenance update (2026-11-07)

Yes, contributing to Apache SeaTunnel.

Pushed b3aa0f2fefaa3d8164378e983ec85ea1274e91c9 by normal fast-forward push. Reconciled dev conflicts while retaining JSON and numeric-special-value source options. Added raw JSON support to scalar/array text formats. Fixed Doris-specific Stream Load transport so boolean/string scalars and JSON null retain their native types; strict parsing remains. The two LocalFile JSON-type fixtures now preserve their pre-created writable shared directories instead of recreating them as the driver user. Exact existing E2E value/row assertions are retained, with new serializer/text regression tests and bilingual migration guidance. The follow-up keeps the Doris serializer's original fields and method signatures, preserving its implicit Java serial form.

Root cause: the LocalFile logs report Permission denied at the final file commit after the schema save mode recreates a previously writable directory. Doris 2.1's JSON reader converts top-level boolean tokens to 1/0 and JSON null to SQL NULL before the column cast; document-string transport preserves the native JSON document. See Doris 2.1 reader. Subsequent Doris checksum failures followed the initial assertion before fixture cleanup; they still require the new-head rerun, rather than being counted as passed.

Validation: affected-module Spotless and diff whitespace checks passed; one independent maintainer source review completed for these deltas. No local compilation, unit/IT/E2E execution, Docker or service startup was run under the repository validation policy. The current-head fork Build is pending and no runtime pass is claimed. Earlier verification statements refer to previous heads. The separate Metalake startup timeout, complete current-head CI and real Snowflake-account acceptance remain gates. This PR remains Draft.

The approved merge's POM files exactly match upstream dev; no dependency edits were added. Existing connector registrations, options, exact JSON tree comparisons and 1-row LocalFile assertions remain.

@github-actions github-actions Bot added e2e and removed jdbc labels Jul 19, 2026

@DanielLeens DanielLeens left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Technical self-review of the complete two-commit diff at 6c28e26f4c986a42666fde7bb33bb07a9264a807: the API, JSON-format, and connector-specific implementations are internally coherent, but I found one compatibility blocker before this is ready for maintainer review.

  1. Automatically mapping existing Snowflake VARIANT, Doris JSON/JSONB, and StarRocks JSON columns to the new JSON type breaks unchanged pipelines outside the components updated here. The catalog converters now return JSON_TYPE for these existing native columns (SnowflakeDataTypeConvertor.java:135-136, AbstractDorisTypeConverter.java:183-192, StarRocksDataTypeConvertor.java:126-133), but several core consumers still reject that enum value: Calcite SQL transform falls through to Unsupported SeaTunnel type (CalciteTypeConverter.java:77-121), Copy rejects it (CopyFieldTransform.java:131-189), JsonPath rejects it (JsonPathTransform.java:140-158), and common CSV/Avro serialization also reaches unsupported-type errors (CsvSerializationSchema.java:244-260, SeaTunnelRowTypeToAvroSchemaConverter.java:119-127). A previously valid native-JSON source followed by one of those transforms/formats can therefore fail without any configuration change.

Please either keep these connector-native types mapped to STRING until the shared transform/format surface supports the logical type, or add JSON handling everywhere a String-backed logical value is expected and cover native JSON source -> transform -> sink/format regressions. If the behavior change is intentional, it also needs explicit incompatible-change and migration guidance rather than being described as purely additive.

This is a source compatibility blocker, so the technical verdict is blocking. The required Build check is still queued, and this draft will also require an independent write-capable maintainer review after the blocker is resolved.

@DanielLeens DanielLeens left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I completed a current-head technical self-check of the full diff. I do not see a source-level blocker in this version. Because this is Daniel-authored, this is not an independent approval and a separate maintainer review is still required.

The source review is clear, but the current Build is failing, so this PR is still waiting on CI. The current failed lanes include Run / Dead links, Run / unit-test (11, windows-latest), Run / all-connectors-it-6 (11, ubuntu-latest), Run / doris-connector-it (11, ubuntu-latest), and 2 more failed lanes. The shared dead-link failure has a fix in #11502, but that fix has not merged into dev yet; syncing the current dev alone will not clear that lane today. After #11502 lands, please sync/retrigger and then diagnose only any lanes that still fail.

@DanielLeens DanielLeens left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Rechecked the latest head after the dev synchronization: I reviewed the full 88-file diff again and do not see a reopened source-level blocker. The JSON logical type remains covered across the API, formats, transforms, translations, Doris, StarRocks, and Snowflake conversion/generation paths, and the incompatible native-schema mapping is documented in both locales with migration guidance.

The required Build check is still pending. Because this is Daniel-authored, this self-check is not an independent approval; one other maintainer review is still required.

@DanielLeens DanielLeens left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Basic information

  • PR title: [Feature][API] Add JSON logical type support
  • Author: DanielLeens
  • Link: #11493
  • Base branch: dev
  • State: OPEN
  • Change size: +2004 / -64, 89 file(s)
  • Human review ready: Yes
  • Review time: 2026-07-26T16:20:00Z
  • Local branch: seatunnel-review-11493
  • Local worktree: dedicated PR 11493 review worktree

Stable review keys

  • pr_number: 11493
  • base_sha: cc7836dc46bf92afd95f9b61cb910c3bfbb55457
  • reviewed_base_sha: cc7836dc46bf92afd95f9b61cb910c3bfbb55457
  • merge_base_sha: cc7836dc46bf92afd95f9b61cb910c3bfbb55457
  • head_sha: 9bb1fc70e80292e0051a8cf5edac81300dcc71a3
  • reviewed_head_sha: 9bb1fc70e80292e0051a8cf5edac81300dcc71a3
  • technical_verdict: clear_waiting_ci
  • github_review_event: NOT_POSTED
  • human_review_ready: true
  • intended_change_correctness: pass
  • diff_integrity: pass
  • deletion_total: 64
  • deletion_classified: 64
  • deletion_unclassified: 0
  • other_total: 0
  • other_confirmed: 0
  • other_resolved_in_current_head: 0
  • other_rejected_with_same_proposition_evidence: 0
  • other_not_applicable_with_reason: 0
  • other_unresolved: 0
  • merge_conclusion: gates_then_merge
  • reviewed_at: 2026-07-26T16:20:00Z

CI, compare, and merge-gate facts

  • mergeStateStatus: BLOCKED

  • reviewDecision: REVIEW_REQUIRED

  • mergeable_state: blocked

  • mergeable: True

  • rebaseable: False

  • required_ci_gate: pending

  • approval_gate: pending

  • conflict_gate: satisfied

  • merge_queue_gate: pending

  • compare: status=diverged, ahead_by=7, behind_by=11, total_commits=7, url=dev...9bb1fc7

  • Gate assessment: No source, diff, or conflict blocker exists; the required Build is queued, while Draft, REVIEW_REQUIRED, independent review, and acknowledged controlled Snowflake validation remain. Behind by 11 alone does not justify sync.

  • Other gate draft state: pending — The PR remains a draft pending current-head CI and controlled Snowflake validation.

  • Other gate independent reviewer: pending — DanielLeens is the author; self-review cannot satisfy independent approval.

What problem this PR solves

  • User pain: Snowflake VARIANT, Doris JSON/JSONB, and StarRocks JSON source values are flattened to ordinary STRING, losing JSON intent in schema-aware pipelines and potentially writing native destinations as quoted text.
  • Fix approach: Append a String-backed SqlType.JSON, preserve it through generic formats/translations/transforms, map native connector JSON, generate Snowflake PARSE_JSON binds, emit structured trees for StarRocks, and reject incompatible CSV Stream Load.
  • One-line summary: Native JSON remains a distinct logical type across supported API, format, and connector paths while using a String physical representation for engine and transport compatibility.
  • Before: Snowflake VARIANT {"a":[1,true]} entered SeaTunnel as STRING and could be written as quoted text.
  • After: The same value enters as JSON while remaining exact JSON text in memory; Snowflake binds PARSE_JSON(:field), and StarRocks JSON Stream Load emits an object, array, or scalar.

1. Code-change review

1.1 Core logic and real call/execution chain

  • Behavior before: Native semi-structured source types mapped to STRING, generic pipelines had no JSON schema identity, and Snowflake or StarRocks sinks lacked native structured binding or serialization.
  • Behavior after: The JSON logical type is preserved across APIs, formats, transforms, translations, and declared connector paths, and native destinations use protocol-specific structured representations.
  • Normal-path hit: conditional — Native JSON/VARIANT sources or explicit json schemas take the path; downstream must support JSON or use the documented CAST AS VARCHAR.

Changed files, classes, and methods

  • seatunnel-api/src/main/java/org/apache/seatunnel/api/table/type/SqlType.java:20-50 SqlType.JSON — Appends JSON after all existing enum values, preserving historical ordinals.
  • seatunnel-api/src/main/java/org/apache/seatunnel/api/table/type/BasicType.java:20-60 BasicType.JSON_TYPE — Uses String.class as the physical representation while retaining distinct SqlType.JSON.
  • seatunnel-formats/seatunnel-format-json/src/main/java/org/apache/seatunnel/format/json/JsonToRowConverters.java:80-120 JSON deserialization converter — Distinguishes missing/SQL null, JSON-null text, and complete structured or scalar JSON text.
  • seatunnel-formats/seatunnel-format-json/src/main/java/org/apache/seatunnel/format/json/RowToJsonConverters.java:170-300 JSON serialization converter — Parses one complete JSON value, rejects trailing tokens, and removes an SQL-null property from reused objects.
  • seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/internal/dialect/snowflake/SnowflakeDialect.java:100-220 schema-aware Snowflake SQL generation — Generates PARSE_JSON(:field) only for JSON bind positions while retaining old semantics for other fields.
  • seatunnel-connectors-v2/connector-starrocks/src/main/java/org/apache/seatunnel/connectors/seatunnel/starrocks/serialize/StarRocksJsonSerializer.java:35-110 StarRocks JSON Stream Load serialization — Parses each JSON String into a complete tree before writing the structured Stream Load row.

Effective prerequisites

  • Input must be one complete JSON value; StarRocks native JSON requires JSON Stream Load; Snowflake adds PARSE_JSON only for auto-generated SQL.

Conditions where the change does not apply

  • Unsupported downstream connectors still fail type conversion; StarRocks CSV explicitly rejects JSON; Snowflake custom queries require user-provided conversion.

Complete execution chain

1. seatunnel-api/src/main/java/org/apache/seatunnel/api/table/catalog/SeaTunnelDataTypeConvertorUtil.java:50-140 -> SeaTunnelDataTypeConvertorUtil [method_call]
   Schema/API boundary.
   Side effect: Parses json and array<json> schema declarations into JSON_TYPE.
2. seatunnel-formats/seatunnel-format-json/src/main/java/org/apache/seatunnel/format/json/JsonToRowConverters.java:80-120 -> JsonToRowConverters.createConverter [serialization]
   Format-decode boundary.
   Side effect: Stores structured, scalar, and null JSON as exact JSON text.
3. seatunnel-formats/seatunnel-format-json/src/main/java/org/apache/seatunnel/format/json/RowToJsonConverters.java:170-300 -> RowToJsonConverters [serialization]
   Format-encode boundary.
   Side effect: Validates one complete JSON value and writes its tree; SQL null removes the property.
4. seatunnel-connectors-v2/connector-starrocks/src/main/java/org/apache/seatunnel/connectors/seatunnel/starrocks/serialize/StarRocksJsonSerializer.java:35-110 -> StarRocksJsonSerializer [rpc]
   StarRocks protocol boundary.
   Side effect: Sends the JSON tree as a structured Stream Load payload.
5. seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/internal/dialect/snowflake/SnowflakeDialect.java:100-220 -> SnowflakeDialect schema-aware SQL [rpc]
   Snowflake JDBC boundary.
   Side effect: Adds PARSE_JSON wrappers to JSON INSERT, UPDATE, and condition binds.
  • Recovery, exception, async, serialization, and concurrency paths: JSON is an enum-tail, String-backed basic type and changes no existing serialized values or state ordinals. Shared Jackson mappers are read-only after configuration; reused row serializers explicitly remove properties on SQL null to prevent cross-row leakage. Malformed, incomplete, or trailing-token JSON fails with contextual exceptions.

Multi-table Sink Writer contract audit

  • Applicable: false
  • Sink implements SupportMultiTableSink: Not reported by GitHub
  • createWriter returns the required subclass: Not reported by GitHub
  • optionRule contains the replica option: Not reported by GitHub
  • Evidence: Not applicable: no SupportMultiTableSinkWriter implementation is added.

1.2 Compatibility impact

  • Classification: partially_incompatible (partially incompatible)
  • API: Adds SqlType.JSON and BasicType.JSON_TYPE while preserving existing enum ordinals and APIs.
  • SPI: New schema-aware JdbcDialect overloads preserve old field-name SPI behavior through default delegation.
  • Configuration: Adds json and array schema declarations without removing existing configuration.
  • Defaults: No option default changes; native-source schema inference changes intentionally.
  • Protocol and serialization: The JSON String physical representation preserves engine and transport compatibility; native sinks parse or wrap at protocol boundaries.
  • Checkpoint/restore: JSON is appended to the enum tail so existing values and states are not renumbered; new JSON schemas require downstream support.
  • Historical behavior: Snowflake VARIANT, Doris JSON/JSONB, and StarRocks JSON sources change from STRING to JSON, an intentional partial incompatibility.
  • Migration guidance: EN/ZH incompatible-change docs specify Calcite CAST(payload AS VARCHAR) to restore the old String schema and value path.
  • Incompatible-changes documentation: Bilingual dev incompatible-change entries include affected connectors, impact, and migration.

1.3 Performance and side effects

  • CPU: JSON parsing and serialization are linear in payload size; generic JSON and the StarRocks boundary perform validation parsing.
  • Memory: Each JSON value uses a short-lived Jackson tree and String; no unbounded cache is introduced.
  • GC: Structured serialization adds per-row tree allocations, a bounded correctness trade-off.
  • Network: No additional round trip is added; payload representation changes from quoted string to native structured JSON.
  • Lock contention: No new locks or shared mutable hot-path state is introduced.
  • Concurrency safety: Shared mappers are read-only after configuration; mutable ObjectNode property lifecycle under serializer reuse is explicitly handled.
  • Retry: Connector retry behavior is unchanged; malformed JSON fails before the network call.
  • Idempotency: Connector write idempotency is unchanged; Snowflake generated binds and StarRocks serialization are deterministic for the same String.
  • Resource release: No persistent resource is added; Jackson trees are method-local.
  • Overall: Additional JSON validation parsing is linear and bounded, trading modest cost for schema and structure correctness.

1.4 Error handling and logging

  • Exception propagation: Empty, malformed, incomplete, or trailing-token JSON fails with contextual JSON-operation exceptions; StarRocks CSV fails fast.
  • Context: Errors retain field, type, or protocol context; unsupported downstream paths use existing type-conversion failures.
  • Log levels: No noisy or sensitive logging is added.
  • Sensitive information: JSON values are not newly logged; credential and configuration handling is unchanged.
  • Overall: Invalid representations fail explicitly rather than silently degrading to quoted strings.

1.5 Diff integrity, deletion ledger, and scope audit

  • intended_change_correctness: pass
  • diff_integrity: pass
  • deletion_ledger: total=64, classified=64, unclassified=0
  • Reconciliation: 64 = 64 + 0

Deletion, rename, and disappeared-capability ledger

  • deletion-001 | count=1 | deletion | intended_change | docs/en/connectors/sink/Doris.md (old line 175) — Old STRING/native-type wording is replaced by in-scope bilingual JSON logical-type and migration guidance; no unrelated capability is removed.
  • deletion-002 | count=1 | deletion | intended_change | docs/en/connectors/sink/Snowflake.md (old line 46) — Old STRING/native-type wording is replaced by in-scope bilingual JSON logical-type and migration guidance; no unrelated capability is removed.
  • deletion-003 | count=1 | deletion | intended_change | docs/en/connectors/source/Snowflake.md (old line 51) — Old STRING/native-type wording is replaced by in-scope bilingual JSON logical-type and migration guidance; no unrelated capability is removed.
  • deletion-004 | count=1 | deletion | intended_change | docs/en/connectors/source/StarRocks.md (old line 249) — Old STRING/native-type wording is replaced by in-scope bilingual JSON logical-type and migration guidance; no unrelated capability is removed.
  • deletion-005..deletion-007 | count=3 | deletion | intended_change | docs/en/introduction/concepts/schema-feature.md (old line 158 .. old line 168) — Old STRING/native-type wording is replaced by in-scope bilingual JSON logical-type and migration guidance; no unrelated capability is removed.
  • deletion-008 | count=1 | deletion | intended_change | docs/zh/connectors/sink/Doris.md (old line 173) — Old STRING/native-type wording is replaced by in-scope bilingual JSON logical-type and migration guidance; no unrelated capability is removed.
  • deletion-009 | count=1 | deletion | intended_change | docs/zh/connectors/sink/Snowflake.md (old line 46) — Old STRING/native-type wording is replaced by in-scope bilingual JSON logical-type and migration guidance; no unrelated capability is removed.
  • deletion-010 | count=1 | deletion | intended_change | docs/zh/connectors/source/Snowflake.md (old line 51) — Old STRING/native-type wording is replaced by in-scope bilingual JSON logical-type and migration guidance; no unrelated capability is removed.
  • deletion-011 | count=1 | deletion | intended_change | docs/zh/connectors/source/StarRocks.md (old line 247) — Old STRING/native-type wording is replaced by in-scope bilingual JSON logical-type and migration guidance; no unrelated capability is removed.
  • deletion-012..deletion-014 | count=3 | deletion | intended_change | docs/zh/introduction/concepts/schema-feature.md (old line 158 .. old line 168) — Old STRING/native-type wording is replaced by in-scope bilingual JSON logical-type and migration guidance; no unrelated capability is removed.
  • deletion-015 | count=1 | deletion | intended_change | seatunnel-api/src/main/java/org/apache/seatunnel/api/table/type/SqlType.java (old line 45) — The old STRING-only switch or mapping is replaced by an in-scope String-backed JSON logical-type branch.
  • deletion-016 | count=1 | deletion | intended_change | seatunnel-connectors-v2/connector-doris/src/main/java/org/apache/seatunnel/connectors/doris/datatype/AbstractDorisTypeConverter.java (old line 187) — The old STRING-only switch or mapping is replaced by an in-scope String-backed JSON logical-type branch.
  • deletion-017..deletion-021 | count=5 | deletion | intended_change | seatunnel-connectors-v2/connector-doris/src/test/java/org/apache/seatunnel/connectors/doris/datatype/DorisTypeConvertorV1Test.java (old line 307 .. old line 316) — Old fixtures or assertions are replaced by focused native-JSON, JSON-null/SQL-null, and engine-isolation coverage.
  • deletion-022..deletion-023 | count=2 | deletion | intended_change | seatunnel-connectors-v2/connector-doris/src/test/java/org/apache/seatunnel/connectors/doris/datatype/DorisTypeConvertorV2Test.java (old line 308 .. old line 309) — Old fixtures or assertions are replaced by focused native-JSON, JSON-null/SQL-null, and engine-isolation coverage.
  • deletion-024 | count=1 | deletion | intended_change | seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/catalog/snowflake/SnowflakeDataTypeConvertor.java (old line 132) — Old field-name-only SQL generation or STRING mapping is replaced by schema-aware delegation and JSON mapping while default overloads preserve compatibility.
  • deletion-025..deletion-042 | count=18 | deletion | intended_change | seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/internal/JdbcOutputFormatBuilder.java (old line 119 .. old line 323) — Old field-name-only SQL generation or STRING mapping is replaced by schema-aware delegation and JSON mapping while default overloads preserve compatibility.
  • deletion-043 | count=1 | deletion | intended_change | seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/internal/dialect/snowflake/SnowflakeTypeConverter.java (old line 151) — Old field-name-only SQL generation or STRING mapping is replaced by schema-aware delegation and JSON mapping while default overloads preserve compatibility.
  • deletion-044 | count=1 | deletion | intended_change | seatunnel-connectors-v2/connector-jdbc/src/test/java/org/apache/seatunnel/connectors/seatunnel/jdbc/catalog/SnowflakeDataTypeConvertorTest.java (old line 43) — Old fixtures or assertions are replaced by focused native-JSON, JSON-null/SQL-null, and engine-isolation coverage.
  • deletion-045..deletion-046 | count=2 | deletion | intended_change | seatunnel-connectors-v2/connector-jdbc/src/test/java/org/apache/seatunnel/connectors/seatunnel/jdbc/internal/JdbcOutputFormatBuilderTest.java (old line 110 .. old line 131) — Old fixtures or assertions are replaced by focused native-JSON, JSON-null/SQL-null, and engine-isolation coverage.
  • deletion-047 | count=1 | deletion | intended_change | seatunnel-connectors-v2/connector-starrocks/src/main/java/org/apache/seatunnel/connectors/seatunnel/starrocks/catalog/StarRocksCatalog.java (old line 355) — The old STRING-only switch or mapping is replaced by an in-scope String-backed JSON logical-type branch.
  • deletion-048 | count=1 | deletion | intended_change | seatunnel-connectors-v2/connector-starrocks/src/main/java/org/apache/seatunnel/connectors/seatunnel/starrocks/catalog/StarRocksDataTypeConvertor.java (old line 129) — The old STRING-only switch or mapping is replaced by an in-scope String-backed JSON logical-type branch.
  • deletion-049 | count=1 | deletion | intended_change | seatunnel-connectors-v2/connector-starrocks/src/main/java/org/apache/seatunnel/connectors/seatunnel/starrocks/datatypes/StarRocksTypeConverter.java (old line 157) — The old STRING-only switch or mapping is replaced by an in-scope String-backed JSON logical-type branch.
  • deletion-050 | count=1 | deletion | intended_change | seatunnel-connectors-v2/connector-starrocks/src/main/java/org/apache/seatunnel/connectors/seatunnel/starrocks/serialize/StarRocksJsonSerializer.java (old line 47) — The old STRING-only switch or mapping is replaced by an in-scope String-backed JSON logical-type branch.
  • deletion-051..deletion-052 | count=2 | deletion | intended_change | seatunnel-connectors-v2/connector-starrocks/src/test/java/org/apache/seatunnel/connectors/seatunnel/starrocks/catalog/StarRocksTypeConverterTest.java (old line 342 .. old line 343) — Old fixtures or assertions are replaced by focused native-JSON, JSON-null/SQL-null, and engine-isolation coverage.
  • deletion-053..deletion-054 | count=2 | deletion | intended_change | seatunnel-connectors-v2/connector-starrocks/src/test/java/org/apache/seatunnel/connectors/seatunnel/starrocks/serialize/StarRocksJsonSerializerTest.java (old line 50 .. old line 72) — Old fixtures or assertions are replaced by focused native-JSON, JSON-null/SQL-null, and engine-isolation coverage.
  • deletion-055..deletion-057 | count=3 | deletion | intended_change | seatunnel-e2e/seatunnel-connector-v2-e2e/connector-doris-e2e/src/test/java/org/apache/seatunnel/e2e/connector/doris/DorisIT.java (old line 156 .. old line 724) — Old fixtures or assertions are replaced by focused native-JSON, JSON-null/SQL-null, and engine-isolation coverage.
  • deletion-058 | count=1 | deletion | intended_change | seatunnel-e2e/seatunnel-connector-v2-e2e/connector-starrocks-e2e/src/test/resources/starrocks-thrift-to-starrocks-streamload.conf (old line 76) — Old fixtures or assertions are replaced by focused native-JSON, JSON-null/SQL-null, and engine-isolation coverage.
  • deletion-059 | count=1 | deletion | intended_change | seatunnel-e2e/seatunnel-connector-v2-e2e/connector-starrocks-e2e/src/test/resources/starrocks-to-assert.conf (old line 73) — Old fixtures or assertions are replaced by focused native-JSON, JSON-null/SQL-null, and engine-isolation coverage.
  • deletion-060..deletion-062 | count=3 | deletion | intended_change | seatunnel-formats/seatunnel-format-csv/src/main/java/org/apache/seatunnel/format/csv/CsvSerializationSchema.java (old line 226 .. old line 228) — The old STRING-only switch or mapping is replaced by an in-scope String-backed JSON logical-type branch.
  • deletion-063 | count=1 | deletion | intended_change | seatunnel-translation/seatunnel-translation-spark/seatunnel-translation-spark-common/src/main/java/org/apache/seatunnel/translation/spark/serialization/InternalRowConverter.java (old line 127) — The old STRING-only switch or mapping is replaced by an in-scope String-backed JSON logical-type branch.
  • deletion-064 | count=1 | deletion | intended_change | seatunnel-translation/seatunnel-translation-spark/seatunnel-translation-spark-common/src/main/java/org/apache/seatunnel/translation/spark/serialization/SeaTunnelRowConverter.java (old line 118) — The old STRING-only switch or mapping is replaced by an in-scope String-backed JSON logical-type branch.

Scope and base-drift items

  • scope-1 | configuration_contract | intended_change | seatunnel-api/src/main/java/org/apache/seatunnel/api/table/type/SqlType.java (SqlType enum tail) — JSON is appended at the end, preserving existing ordinals.

  • scope-2 | documentation_contract | intended_change | docs/en/introduction/concepts/incompatible-changes.md (JSON source-schema change) — EN/ZH ledgers record connector scope, impact, and CAST migration.

  • Out-of-scope hunk conclusion: All 89 files belong to the API logical type, generic formats/transforms/translations, Doris/StarRocks/Snowflake mappings, tests/E2E, or corresponding bilingual docs; no out-of-scope hunk was found.

  • Stale-base conclusion: Current compare is diverged, ahead by 7 and behind by 11; the pinned-base diff has no stale-base rollback, and behind status alone does not trigger a sync request.

  • Merge-artifact conclusion: No conflict marker or merge artifact was found; GitHub reports mergeable=true.

2. Code-quality assessment

2.1 Code conventions, title format, and comments

  • Title format: Follows [Feature][API] Description.
  • Code conventions: git diff --check is clean; new test and configuration files are within affected modules.
  • Comment completeness: The public logical type, serializer validation, and schema-aware JDBC overloads are sufficiently documented.

2.2 Test coverage and stability

  • Unit tests: covered — Covers parsing/arrays, JSON null/SQL null/reuse, Arrow/CSV/Avro/Spark/Calcite/transforms, and connector type/SQL generation.
  • Component tests: covered — Doris, StarRocks, and Snowflake converters, serializers, save mode, and JDBC builder have focused tests.
  • Engine integration tests: covered — LocalFile, Kafka, transforms, Doris, and StarRocks jobs cover supported SeaTunnel, Flink, and Spark paths through TestTemplate.
  • E2E: covered — Covers LocalFile JSON/CSV, Kafka raw JSON/Avro, Copy/JsonPath/Calcite, Doris native JSON/JSONB, and StarRocks native JSON/CSV rejection.
  • Regression tests: covered — Covers reused-serializer SQL-null leakage, JSON-null distinction, trailing tokens, and native DDL/type round-trips.
  • Stability classification: stable

Test-stability evidence

  • seatunnel-e2e JSON logical-type scenarios
    • Trigger: Testcontainers connector services, Kafka topics, and StarRocks/Doris tables.
    • Probability basis: Polling is bounded, topics and tables are engine-isolated, and no fixed port, hard sleep, filesystem-order assertion, or unbounded wait is added.
    • Analysis: The static design is stable; shared-runner and Testcontainers timing remain environmental risks, and current-head CI is still queued.

Missing scenarios

  • The class-level disabled Snowflake real-account IT does not cover TYPEOF, path queries, JSON null, SQL NULL, or native round-trip; the draft explicitly treats it as a pre-release gate.

2.3 Documentation

  • User-visible change: true
  • docs/en: Schema-feature, affected source/sink connector, and incompatible-change docs are synchronized.
  • docs/zh: Chinese aligns with English on native mappings, StarRocks format, and CAST migration.
  • Examples: Includes Calcite CAST(... AS VARCHAR) to restore old schema and value behavior.
  • Configuration truth: json/array, StarRocks JSON format, and connector mappings match the code.
  • URL truth: No new stale or broken URL was identified.

2.4 Local-validation boundary and GitHub CI evidence

  • Local boundary: Only static diff/source/call-chain review, git diff --check, and current-head GitHub CI were used; no compilation, unit tests, integration tests, E2E, packaging, Docker, or service was run.

Local execution boundary

  • compilation: not_executed — Not executed; current-head GitHub CI is the runtime evidence.
  • unit_tests: not_executed — Not executed.
  • integration_tests: not_executed — Not executed.
  • e2e: not_executed — Not executed.
  • packaging: not_executed — Not executed.
  • docker: not_executed — Not executed.
  • service_start: not_executed — Not executed.
  • real_job: not_executed — Not executed.

Actually executed review commands

  • git diff --stat cc7836dc46bf92afd95f9b61cb910c3bfbb55457...9bb1fc70e80292e0051a8cf5edac81300dcc71a3
    • Result: passed
    • Explanation: Confirmed 89 files and +2004/-64.
  • git diff --name-status cc7836dc46bf92afd95f9b61cb910c3bfbb55457...9bb1fc70e80292e0051a8cf5edac81300dcc71a3
    • Result: passed
    • Explanation: Completed the full file-scope and new-file audit.
  • git diff --unified=0 cc7836dc46bf92afd95f9b61cb910c3bfbb55457...9bb1fc70e80292e0051a8cf5edac81300dcc71a3
    • Result: passed
    • Explanation: Completed all hunk, call-chain, and deletion audits.
  • git diff --check cc7836dc46bf92afd95f9b61cb910c3bfbb55457...9bb1fc70e80292e0051a8cf5edac81300dcc71a3
    • Result: passed
    • Explanation: No whitespace error.

Required checks

Complete status-check rollup

3. Architecture assessment

3.1 Solution type: precise fix / workaround / long-term design

  • Type: long_term_design
  • Assessment: A logical API type plus connector-native protocol mapping is the correct long-term boundary and adds no connector semantics to generic runtimes.

3.2 Maintainability

The String physical representation reuses mature converter and engine paths while distinct SqlType preserves schema intent.

3.3 Extensibility

Other connectors can explicitly opt into JSON mapping; unsupported paths fail rather than silently stringify.

3.4 Historical-version compatibility

The enum tail preserves existing ordinals; the intentional native-source schema change has bilingual migration guidance.

4. Disposition ledger for findings from other reviewers

  • total=0, confirmed=0, resolved_in_current_head=0
  • rejected_with_same_proposition_evidence=0, not_applicable_with_reason=0, unresolved=0
  • Reconciliation: 0 = 0 + 0 + 0 + 0 + 0

After excluding the author and Daniel, this round has no technical finding to ingest.

5. Formal findings

No blocking finding was identified; the remaining risks and test blind spots are fully recorded in Sections 2 and 3.

6. Findings summary

ID Finding Location Severity Merge gate
- No formal finding - - -

7. Merge conclusion

Conclusion:can merge after gates are satisfied

Blocking items

  • No source, documentation, compatibility, test-completeness, conflict, or diff-integrity blocker remains.

Non-blocking recommendations

  • No additional non-blocking finding is recorded.

Overall assessment

The logical type, null semantics, structured protocol paths, native mappings, compatibility docs, and E2E design are coherent with no source blocker.

Better alternative implementation and trade-offs

  • Alternative: A full JSON-tree public API could reduce repeated parsing but would introduce broad object, serializer, and engine-compatibility contracts.
  • Trade-offs: A validated String-backed logical type is the safer incremental design, at the cost of linear parsing at native protocol boundaries.

8. GitHub publication and reply readback

  • Publication event: COMMENT
  • Publisher identity: DanielLeens (repository permission READ)
  • Reviewed commit: 9bb1fc70e80292e0051a8cf5edac81300dcc71a3
  • This complete report is the submitted GitHub Review body. Its immutable review ID, URL, state, and submission time are verified from the GitHub API immediately after creation and retained in the local bilingual evidence.
  • Any precise line-thread replies are separate GitHub objects and are likewise verified individually.

@DanielLeens DanielLeens left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

What Problem Does This PR Solve?

Native semi-structured columns (Snowflake VARIANT, Doris JSON/JSONB, StarRocks JSON) used to be flattened to plain STRING, so schema-aware pipelines lost the JSON intent and native destinations could receive quoted text instead of structured values. This PR adds a String-backed SqlType.JSON / BasicType.JSON_TYPE logical type and threads it through the API, JSON/CSV/Avro formats, Calcite/Copy/JsonPath transforms, Spark translation, and the Doris/StarRocks/Snowflake conversion, DDL-generation, and write paths. One-sentence summary: JSON stays a distinct logical type end to end while remaining exact JSON text in memory.

This is a structured self-re-review: I authored this PR, so this is a candid re-check of my own work and cannot count as an independent approval — a write-capable maintainer still needs to do the final review and merge. Since my last self-check on 2026-07-26 (head 9bb1fc7), the branch gained one fix commit (0fc133c "[Fix][Connector-V2] Fix JSON type CI failures": StarRocks catalog native-type lookup, StarRocks starrocks.config.format compatibility shim, a CSV E2E header fix, and a corrected StarRocks JSON-null assertion) plus a merge of the latest dev — I verified the merge commit is byte-identical to a clean auto-merge (no manual edits), and the branch is now 0 behind dev. I re-reviewed the entire 90-file, +2046/-66 diff from scratch, not just the increment. There are no new comments from other reviewers to ingest — all prior activity on this PR is my own.

Up front, an apology is owed: Sorry for missing several of the points below in the last review — that's on me. In the 2026-07-26 round I rated the E2E design "stable" and recorded no formal findings; this pass, prompted by the failing current-head CI, found issues that already existed in the version I reviewed then. They are explicitly marked as carryovers below, not new-version regressions.

1. Code Change Review

1.1 Core Logic Analysis

Before: SqlType had no JSON member; the three connectors mapped native JSON columns to BasicType.STRING_TYPE (for example AbstractDorisTypeConverter grouped DORIS_JSON with DORIS_STRING), the JSON format escaped JSON text into a quoted string, and Snowflake inserts bound plain :field parameters.

After:

  • SqlType.JSON is appended at the enum tail (seatunnel-api/src/main/java/org/apache/seatunnel/api/table/type/SqlType.java:46), and BasicType.JSON_TYPE uses String.class as the physical class (BasicType.java:29). BasicType.equals/hashCode include sqlType, so JSON_TYPE and STRING_TYPE stay distinct (BasicType.java:67-77).
  • Schema declaration accepts json and array<json> (SeaTunnelDataTypeConvertorUtil.java:58-59,221-222).
  • JSON format: deserialization stores the exact JSON text of any value shape, distinguishing missing field (SQL null) from JSON null text (JsonToRowConverters.java:90-100); serialization parses one complete document with FAIL_ON_TRAILING_TOKENS and embeds the tree instead of an escaped string (RowToJsonConverters.java:177-193), and removes SQL-null JSON properties from the reused ObjectNode so consecutive rows cannot leak values (RowToJsonConverters.java:286-292).
  • CSV round-trips JSON as a quoted String field and quotes array<json> at the top level (CsvSerializationSchema.java:205-209,226-234); Avro maps JSON to a nullable string schema (SeaTunnelRowTypeToAvroSchemaConverter.java:60-63).
  • Calcite treats JSON as VARCHAR while the output row type derivation preserves JSON_TYPE for untouched projections (CalciteTypeConverter.java:77-78); Copy and JsonPath accept JSON input (CopyFieldTransform.java:133-134, JsonPathTransform.java:140-141).
  • Snowflake: VARIANT maps to JSON both in catalog and type converter (SnowflakeTypeConverter.java:152-155, SnowflakeDataTypeConvertor.java:133-134), and new schema-aware getInsertIntoStatement/getUpdateStatement overloads wrap only JSON binds with PARSE_JSON(:field) (SnowflakeDialect.java:48-108). The new JdbcDialect overloads default-delegate to the old field-name methods, so every other dialect and third-party SPI implementation keeps byte-identical SQL (JdbcDialect.java:163-170,211-227).
  • StarRocks: JSON columns map to JSON_TYPE (with an information_schema native-type lookup because the MySQL protocol can report JSON as VARCHAR, StarRocksCatalog.java:167-190,321-324,394-412); JSON Stream Load parses each value into a tree (StarRocksJsonSerializer.java:60-68,96-104), CSV Stream Load fails fast with an actionable message (StarRocksBaseSerializer.java:76-79).
  • Doris: JSON/JSONB map to JSON_TYPE and reconvert to native JSON (AbstractDorisTypeConverter.java:186-193,381-385).

Complete runtime path (native JSON source to native JSON sink):

native source column (Doris JSON/JSONB | StarRocks JSON | Snowflake VARIANT)
  -> catalog/type converter returns BasicType.JSON_TYPE
     AbstractDorisTypeConverter.java:186-193 / StarRocksCatalog.java:321-324 / SnowflakeTypeConverter.java:152-155
  -> value read as JSON text
     ArrowToSeatunnelRowReader.java:161-162 (Doris/StarRocks Arrow scan) / AbstractJdbcRowConverter.java:81-84 (JDBC)
  -> engine transport: Zeta and Flink carry SeaTunnelRow opaquely (no per-field SqlType switch;
     I verified seatunnel-engine has no SqlType switch and Flink translation uses TypeInformation.of(SeaTunnelRow.class));
     Spark translation maps JSON -> StringType and handles array<json>
     TypeConverterUtils.java:75-76, InternalRowConverter.java:112-113,128-129
  -> optional transforms: Calcite projection keeps JSON, CAST(payload AS VARCHAR) is the documented downgrade;
     Copy and JsonPath pass JSON text through
  -> sink serialization: RowToJsonConverters.java:177-193 (JSON format) | StarRocksJsonSerializer.java:60-68 |
     SnowflakeDialect.java:104-108 PARSE_JSON binds | Doris stream load via JsonSerializationSchema
     (SeaTunnelRowSerializer.java:90-96)

Key findings:

  • The round-1 compatibility blocker is genuinely resolved on the shared surfaces named then: Calcite, Copy, JsonPath, CSV, and Avro all handle JSON now, each with unit and E2E coverage, and the intentional native-schema change is documented bilingually with a CAST migration path.
  • JSON null vs SQL null semantics are consistently designed at the top level (Java null = SQL null, "null" text = JSON null) and regression-tested, including reused-serializer property leakage (JsonRowDataSerDeSchemaTest.java:78-141).
  • The merge with dev is clean (auto-merge identical), so the whole current diff is the reviewed content plus commit 0fc133c.
  • Two generic surfaces still reject JSON in ways I failed to flag before: the text format (default for file sinks and the Doris CSV stream-load branch) and FakeSource random generation — Issues 2 and 3 below, both carryovers.
  • Current-head CI fails exactly in the Kafka and Doris IT lanes that execute this PR's new E2E scenarios — Issue 1, the gating item.

1.2 Compatibility Impact

Partially incompatible (intentional and documented). Native Snowflake VARIANT, Doris JSON/JSONB, and StarRocks JSON source columns change from STRING to JSON in discovered schemas; downstream components without JSON support now fail with their existing unsupported-type errors instead of silently working on quoted text. The incompatible-change ledger in docs/en/introduction/concepts/incompatible-changes.md:27-32 (and its Chinese counterpart) names the affected connectors, the supported component list, and the CAST(payload AS VARCHAR) migration, and warns not to cast when the destination is a native JSON column. The enum member is appended at the tail so no existing SqlType ordinal changes; BasicType keeps serialVersionUID = 2L, and neither Zeta nor Flink serializes rows through a per-SqlType switch, so existing checkpoint/savepoint state remains readable by the new version. The one unavoidable caveat: state or configs that contain the new JSON type cannot be read by older releases (enum constant not present), which matters for rollback, not upgrade. The new JdbcDialect overloads preserve the old SPI via default delegation.

1.3 Performance / Side-Effect Analysis

  • JSON validation/parsing is linear in payload size and happens only at explicit boundaries (JSON format encode, StarRocks JSON Stream Load); decode stores jsonNode.toString() without an extra validation pass.
  • Per-row short-lived Jackson trees add bounded GC pressure on JSON columns only; the shared ObjectMapper in StarRocksJsonSerializer is configured once and read-only afterwards, safe under serializer reuse.
  • StarRocksCatalog.getTable now issues one extra information_schema.columns query per table (StarRocksCatalog.java:394-412) — catalog-time only, not per-row.
  • Snowflake PARSE_JSON(:field) moves JSON parsing server-side per bind; update conditions on JSON columns compare VARIANT values, which Snowflake supports, though JSON primary/condition keys remain an unusual pattern.
  • CSV nested array<json> elements are joined with the level-1 separator; a JSON string value containing that separator would break the split on read. This is the same pre-existing limitation string arrays have, not a new regression — noting it for completeness.

1.4 Error Handling and Logging

Malformed, empty, incomplete, or trailing-token JSON fails with contextual CommonError.jsonOperationError before leaving the process (RowToJsonConverters.java:186-192, StarRocksJsonSerializer.java:63-68); no JSON payloads are newly logged. Formal issues, severity-sorted:

Issue 1 (blocking)

  • Location: seatunnel-e2e/.../doris/DorisIT.java:255-296,804-818; seatunnel-e2e/.../kafka/KafkaIT.java:319-341,1726-1775
  • Problem: The current head's Build check failed, and two of the concluded failing lanes are exactly the ones that execute this PR's new JSON E2E scenarios. The Kafka lane recorded two "Run SeaTunnel on spark failed" and two "SeaTunnel job executed failed" in-container job failures; the Doris lane recorded two "SeaTunnel job executed failed" failures. My primary suspect on the Doris side: assertJsonColumnsRoundTrip requires JSON-null values to survive the sink round trip (sawJsonNull, DorisIT.java:286,295), but commit 0fc133c had to change the equivalent StarRocks assertion because StarRocks normalizes a JSON null written through Stream Load to SQL NULL (StarRocksIT.java:524). If Doris behaves the same way, the Doris assertions (and possibly the job itself, if the read-back representation is not valid JSON text) fail for the same reason, and the fix was applied to only one of the two connectors. The Kafka-lane Spark+Zeta failures need the surefire/container logs to attribute precisely.
  • Potential risk: Merging with red CI on lanes covering this very feature would hide a real cross-engine defect in the new paths.
  • Best improvement: Pull the two lanes' logs, fix the root cause (for Doris, mirror the StarRocks JSON-null normalization handling in both the test data expectations and, if needed, the sink path), and rerun CI at the current head. The branch is 0 behind dev, so a sync is not the answer here — these results are directly evaluable.
  • Severity: High. Raised by another reviewer: No. Carryover in part — I rated this E2E design stable on 2026-07-26.

Issue 2

  • Location: seatunnel-connectors-v2/connector-doris/.../serialize/SeaTunnelRowSerializer.java:95-105; seatunnel-formats/seatunnel-format-text/.../TextSerializationSchema.java:237-241; docs/en/connectors/sink/Doris.md:175
  • Problem: The Doris sink's CSV branch builds a TextSerializationSchema, and the text format has no JSON case — it throws a generic UNSUPPORTED_DATA_TYPE. A Doris sink with doris.config.format = "csv" on a table with native JSON columns therefore fails with an unhelpful text-format error, while the Doris sink docs advertise JSON/JSONB -> JSON with no format restriction. StarRocks handles the identical situation much better: a fail-fast, actionable message (StarRocksBaseSerializer.java:76-79) plus an explicit doc note. The same text-format gap also hits file sinks using the default text format fed by a native JSON source.
  • Potential risk: Previously working pipelines (JSON column as STRING through text/CSV) fail after upgrade with an error that does not mention the JSON Stream Load requirement or the CAST migration.
  • Best improvement: Either add a JSON case to TextSerializationSchema/TextDeserializationSchema (String pass-through, one line each, closing the biggest remaining generic-surface gap), or replicate the StarRocks approach for Doris: a dedicated fail-fast message in the CSV branch plus a doc caveat in both language versions.
  • Severity: Medium. Raised by another reviewer: No. Carryover — this existed in every version I reviewed.

Issue 3

  • Location: seatunnel-connectors-v2/connector-fake/.../source/FakeDataGenerator.java:210-341
  • Problem: randomColumnValue has no JSON case, so a FakeSource schema declaring payload = json without explicit rows hits the default branch and throws UNSUPPORTED_DATA_TYPE. The schema-feature docs now list json as a first-class basic type keyword, and FakeSource is the canonical way users try a schema. All new E2E configs supply rows, which is why CI never exercises this.
  • Potential risk: The first thing a user trying the documented json keyword with a plain FakeSource sees is an unsupported-type exception.
  • Best improvement: Generate a small deterministic JSON object (or reuse the string generator wrapped as a JSON string literal) for JSON columns, with a unit test.
  • Severity: Medium. Raised by another reviewer: No. Carryover.

Issue 4

  • Location: seatunnel-e2e/.../starrocks/StarRocksIT.java:382-391; seatunnel-e2e/.../doris/DorisIT.java:286-296
  • Problem: Test-stability risks in the new E2E (details and rating in 2.2): the CSV-rejection test asserts on execResult.getStderr() + container.getServerLogs(), and where the sink exception surfaces differs between Zeta, Flink, and Spark containers; the Doris JSON-null round-trip assertions encode a server-behavior assumption already proven wrong once on StarRocks.
  • Potential risk: Engine- or server-version-sensitive assertions keep the lanes flaky even after the functional fix.
  • Best improvement: Assert the rejection via exit code plus a log check that tolerates engine differences (or restrict that check to the engine whose log placement is deterministic), and make the JSON-null expectations explicit about server normalization on both connectors.
  • Severity: Medium. Raised by another reviewer: No.

Issue 5

  • Location: seatunnel-connectors-v2/connector-starrocks/.../config/SinkConfig.java:98-103
  • Problem: The new legacy shim maps starrocks.config.format onto loadFormat with a bare StreamLoadFormat.valueOf(...). An unrecognized value (anything but CSV/JSON) now fails at config-load time with a context-free IllegalArgumentException; previously the value was only an HTTP header that the connector ultimately overwrote (StarRocksStreamLoadVisitor.java:392). The shim also silently makes starrocks.config.format take precedence over an explicitly configured load_format, and the block carries no explanatory comment even though it is a deliberate compatibility decision.
  • Potential risk: Config typos produce an enum stack trace with no mention of the option name or allowed values; users setting both options get a precedence change with no warning.
  • Best improvement: Wrap the conversion in a StarRocksConnectorException naming the option and allowed values, log (or reject) the case where both load_format and starrocks.config.format are set inconsistently, and add the missing comment.
  • Severity: Medium (new in commit 0fc133c). Raised by another reviewer: No.

Issue 6

  • Location: seatunnel-formats/seatunnel-format-json/.../RowToJsonConverters.java:283-292
  • Problem: The SQL-null-removes-property rule applies only to top-level row fields. A SQL null element inside array<json> (or a JSON-typed map value) is serialized by the nullable wrapper as JSON null, so it deserializes back as the text "null" — the SQL null / JSON null distinction is silently lost for nested positions. A configured format nullValue is also bypassed for top-level JSON fields (removed rather than rendered).
  • Potential risk: Asymmetric null semantics between top-level and nested JSON values surprise users relying on the documented contract.
  • Best improvement: Document the nested-position behavior in the schema-feature docs (both languages), or extend the distinction into array/map converters.
  • Severity: Low. Raised by another reviewer: No. Carryover.

Issue 7

  • Location: seatunnel-connectors-v2/connector-starrocks/.../catalog/StarRocksCatalog.java:394-412
  • Problem: getNativeColumnTypes is the only new non-trivial method in the latest commit without an explanatory comment — it exists because the MySQL protocol reports StarRocks JSON columns as VARCHAR, and that reason is exactly what a future maintainer needs to know before "simplifying" it away.
  • Potential risk: The workaround gets removed as apparently redundant and JSON discovery silently regresses to STRING.
  • Best improvement: One Javadoc paragraph stating the protocol limitation.
  • Severity: Low. Raised by another reviewer: No.

2. Code Quality Assessment

2.1 Coding Standards

Title follows [Feature][API]. git diff --check is clean; the merge commit introduces no manual edits. Naming and placement are consistent with each module's conventions; the schema-aware dialect overloads follow the established default-method extension pattern. Apart from Issues 5 and 7, new non-trivial methods carry meaningful Javadoc (parameterExpression, readJsonValue, the E2E helpers).

2.2 Test Coverage and Test Stability

Coverage is genuinely broad: type declaration parsing (SeaTunnelDataTypeConvertorUtilTest), JSON serde with null-distinction and invalid-input rejection (JsonRowDataSerDeSchemaTest.java:78-141), CSV/Avro round trips including embedded delimiters, Arrow reader conversion, Calcite projection plus the documented CAST migration (CalciteSQLEngineTest.java:110-153), Copy/JsonPath, all three connectors' converters/serializers/save-mode DDL (including the new SnowflakeTypeConverterTest asserting exact PARSE_JSON SQL), and E2E for LocalFile JSON/CSV, Kafka JSON/Avro, transforms, Doris and StarRocks native round trips plus the CSV-rejection negative test.

Mandatory stability rating: Risk present (medium, non-blocking beyond Issue 1). Evidence: StarRocksIT.java:387 concatenates stderr with getServerLogs() and asserts message text — engine-dependent log surfacing; DorisIT.java:286,295 requires JSON null to survive a Doris Stream Load round trip, an assumption the author (me) already had to retract for StarRocks in StarRocksIT.java:524; the leftover json_csv_rejected table is never dropped after the negative test (unique name, so low impact). On the positive side: no Thread.sleep, bounded awaitility polling, per-container dynamic topic names with cleanup (KafkaIT.java:284-287), deterministic JSON test data (DorisIT.java:804-818), and tables dropped in finally blocks elsewhere.

The class-level-disabled Snowflake real-account IT remains a pre-release validation gate rather than CI coverage; that caveat from my earlier rounds still stands.

2.3 Documentation Updates

docs/en and docs/zh are updated in lockstep: schema-feature (json keyword, array<json>, null semantics), source/sink pages for all three connectors, and the incompatible-changes ledger with the CAST migration. Two gaps: the Doris sink page lacks the CSV-format restriction note that the StarRocks page has (part of Issue 2), and the nested-null asymmetry (Issue 6) is undocumented.

3. Architectural Soundness

3.1 Elegance of the Solution

Long-term solution. A String-backed logical type plus connector-native protocol mapping is the right boundary: generic runtimes stay free of connector semantics, engines carry an ordinary String, and only declared protocol edges (PARSE_JSON, JSON Stream Load) interpret the value. The alternative — a tree-based public JSON API — would buy less re-parsing at the cost of a much larger serialization and compatibility contract; the incremental design chosen here is the safer one.

3.2 Maintainability

Type mapping, value validation, and protocol serialization are cleanly separated; the JdbcDialect default-delegation keeps the SPI stable. The two spots that need better self-explanation are Issues 5 and 7.

3.3 Extensibility

Other connectors opt in by adding one explicit native mapping; unsupported paths fail loudly instead of silently stringifying. The remaining friction is that each generic surface needs its own JSON case — the text format (Issue 2) is the last widely used one missing.

3.4 Historical-Version Compatibility

Enum-tail append preserves all existing SqlType ordinals; BasicType keeps its serialVersionUID; Zeta checkpoint state and Flink transport contain no per-SqlType serialization switch, so existing state restores unchanged. The incompatibility is confined to (a) schemas discovered from the three connectors' native JSON columns — documented with migration — and (b) downgrade of state/configs containing the new type to older releases, which is inherent to any enum addition. Old third-party JdbcDialect implementations compile and behave identically through the default methods.

4. Issue Summary

No. Issue Location Severity
1 Current-head CI failing in the Kafka/Doris IT lanes that execute this PR's own JSON E2E; suspected Doris JSON-null normalization parallel to the StarRocks fix DorisIT.java:255-296, KafkaIT.java:319,1726 High
2 Text format (and Doris sink CSV branch) rejects JSON with a generic error; Doris docs lack the CSV restriction note SeaTunnelRowSerializer.java:95-105, TextSerializationSchema.java:237-241 Medium
3 FakeSource random generation unsupported for the documented json keyword FakeDataGenerator.java:210-341 Medium
4 E2E stability risks: engine-dependent log assertion, server-normalization assumption StarRocksIT.java:382-391, DorisIT.java:286-296 Medium
5 Legacy starrocks.config.format shim: bare valueOf, silent precedence change, no comment SinkConfig.java:98-103 Medium
6 Nested array<json>/map SQL-null vs JSON-null distinction lost; nullValue bypassed for JSON fields RowToJsonConverters.java:283-292 Low
7 getNativeColumnTypes workaround lacks an explanatory comment StarRocksCatalog.java:394-412 Low

5. Merge Recommendation

Conclusion: Ready to merge after fixes

  1. Blockers — must be fixed

    1. Issue 1 (High): Diagnose and fix the failing current-head CI. The Build check (workflow "On pull request update") ended cancelled after ~10h40m at head 070b249; the concluded failing lanes are Run / Dead links, Run / unit-test (11, windows-latest), Run / jdbc-connectors-it-part-2 (11, ubuntu-latest), Run / kafka-connector-it (11, ubuntu-latest), and Run / doris-connector-it (8, ubuntu-latest); the remaining lanes were cancelled without conclusions. My attribution: the Kafka and Doris lanes run this PR's new JSON E2E and logged real in-container job failures (two on Spark and two on Zeta in the Kafka lane, two on Zeta in the Doris lane), so they must be treated as caused by this diff until the lane logs prove otherwise — start with the Doris JSON-null hypothesis above. Dead links is the repo-wide docs.starrocks.io false positive with the open fix #11640 not yet merged — unrelated to this diff, and since this branch is 0 behind dev, a sync will not clear it. jdbc-connectors-it-part-2 hosts hosted-service ITs (OceanBase, SelectDB, StarRocks-JDBC); this diff touches connector-jdbc only through behavior-preserving default delegation covered by JdbcOutputFormatBuilderTest, so it is likely environmental, but the log should confirm that. The Windows unit-test lane has failed on every recent round of this PR and runs all the new unit tests; it needs its surefire report before it can be dismissed. Because the head has directly evaluable CI results, the required action is fix-and-rerun at this head, not a dev sync.
  2. Recommended fixes — non-blocking

    1. Issue 2: add JSON to the text format or replicate the StarRocks fail-fast + doc caveat for the Doris CSV branch (Option A below).
    2. Issue 3: JSON support in FakeSource random generation.
    3. Issue 4: harden the two engine/server-sensitive E2E assertions.
    4. Issue 5: contextual error and comment for the starrocks.config.format shim.
    5. Issues 6-7: document nested-null semantics; comment the StarRocks native-type lookup.

Overall assessment: The source-level design is coherent and the round-1 compatibility blocker is fixed on every surface it named; what remains is a red CI that overlaps this diff's own E2E, plus a cluster of medium/low findings that I should have caught in earlier rounds and am flagging now as carryovers. Two options for the remaining generic-surface gap: Option A — add a String pass-through JSON case to seatunnel-format-text ser/de, which closes the Doris-CSV and file-text regressions in one small change and matches how CSV was handled here; Option B — keep text format unsupported but fail fast with a JSON-specific message and document the restriction on the Doris sink page in both languages, mirroring StarRocks. Option A is my preference: it is smaller than this PR's CSV work and removes the last widely used surface where a native JSON source can break a previously valid pipeline. As always from my side: I only have read-level permission, and since I am also the author of this PR, this review is a self-check that cannot stand in for the independent review — one write-capable maintainer needs to review and perform the final approval and merge after CI is green and the draft status is lifted.

@DanielLeens DanielLeens left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

What Problem Does This PR Solve?

  • Native semi-structured columns (Snowflake VARIANT, Doris JSON/JSONB, StarRocks JSON) were previously flattened to plain STRING in SeaTunnel's schema model, so pipelines lost the JSON intent of the source column and native destinations received quoted text instead of structured JSON.
  • Fix approach: introduce a String-backed SqlType.JSON / BasicType.JSON_TYPE logical type appended at the tail of the existing enum, and thread it through the API core, the JSON/CSV/Avro formats, the Calcite/Copy/JsonPath transforms, Spark translation, and the Doris/StarRocks/Snowflake catalog, DDL-generation, and write paths.
  • One-sentence summary: JSON becomes a first-class, String-backed logical type that survives round trips as exact JSON text instead of being silently stringified.

1. Code Change Review

1.1 Core Logic Analysis

Diff-coverage scope (rule 13): this diff is large (89 files, ~2000 added lines). I traced the full call chain and read complete method bodies (not just the hunks) for every production file in seatunnel-api, seatunnel-formats (json/csv/avro/text), seatunnel-transforms-v2 (calcite/copy/jsonpath, including the pre-existing, untouched OutputRowTypeDeriver.java that this PR relies on), the JDBC dialect/converter/output-builder layer, seatunnel-translation-spark and seatunnel-translation-base, and the Doris/StarRocks/Snowflake catalog+serializer+dialect implementations — this is full call-chain-traced coverage, not sampled. I additionally pulled live CI job results from the fork (DanielLeens/seatunnel, run 30824391316, head 070b249) via the GitHub API to independently confirm current-head CI state rather than trusting the PR's self-review claim. Lighter, structural-only pass: the E2E .conf resource files beyond the ones directly relevant to the null-handling analysis, and the StarRocks/Doris/Calcite test files not already covered by a production-code question (e.g. StarRocksTypeConverterTest, StarRocksBaseSerializerTest, StarRocksJsonSerializerTest, StarRocksSaveModeUtilTest, DorisCatalogIT, CalciteSQLEngineTest, CalciteTypeConverterTest, CopyFieldMultiCatalogTransformTest, TestCopyIT, TestCalciteIT, TestJsonPathTransformIT, KafkaIT) — I confirmed via the diff hunks that these add JSON coverage consistent with the production changes, but did not independently execute or line-by-line audit every assertion in them.

Before: SqlType had no JSON member. AbstractDorisTypeConverter grouped DORIS_JSON with DORIS_STRING (mapped to BasicType.STRING_TYPE); SnowflakeTypeConverter/SnowflakeDataTypeConvertor mapped SNOWFLAKE_VARIANT to STRING_TYPE; StarRocksCatalog/StarRocksDataTypeConvertor/StarRocksTypeConverter mapped JSON to STRING_TYPE. The JSON format escaped JSON text into a quoted string field on serialize.

After (verified by reading the actual source, not the PR description):

  • SqlType.JSON is appended at the tail of the enum (seatunnel-api/src/main/java/org/apache/seatunnel/api/table/type/SqlType.java:45), so no existing ordinal shifts. BasicType.JSON_TYPE uses String.class as the physical class (BasicType.java:29), and BasicType.equals/hashCode include sqlType, so JSON_TYPE and STRING_TYPE remain distinct despite sharing a physical class (BasicType.java:67-77). I grepped the entire repository for SqlType combined with ordinal and found zero matches — nothing in the codebase depends on enum ordinal, so tail-append is safe for both in-memory equality and Java enum serialization (which serializes by constant name, not ordinal).
  • Schema declaration accepts json and array<json> (SeaTunnelDataTypeConvertorUtil.java:58-59,220-221), covered by SeaTunnelDataTypeConvertorUtilTest.testJsonTypeDeclare.
  • JSON format (seatunnel-format-json): JsonToRowConverters.createConverter stores the exact jsonNode.toString() for a present field and returns null only for a genuinely missing node (JsonToRowConverters.java:90-100), so SQL null (absent property) and JSON null ("field":null -> text "null") stay distinguishable on read. RowToJsonConverters.createNotNullConverter adds a case JSON that re-parses the string value with FAIL_ON_TRAILING_TOKENS and embeds the resulting tree instead of an escaped string (RowToJsonConverters.java:177-193); malformed/empty/incomplete JSON throws via CommonError.jsonOperationError before it can reach a downstream system. createRowConverter (RowToJsonConverters.java:250-296) reuses its ObjectNode across rows (confirmed: the reuse parameter is the previous row's node, an established pre-existing pattern used for GC-pressure reduction) and, for a JSON-typed field with a SQL-null value, calls node.remove(fieldName) before continuing the loop — this is necessary and correct given node reuse, otherwise a later row could observe a JSON value left over from an earlier row's non-null value.
  • CSV round-trips JSON as a quoted String field and quotes array<json> at the top level so JSON strings containing the delimiter survive (CsvSerializationSchema.java:204-208,225-234); confirmed via CsvTextFormatSchemaTest.testJsonRoundTrip/testJsonArrayRoundTrip. Avro maps JSON to a nullable string schema, same as STRING (SeaTunnelRowTypeToAvroSchemaConverter.java:59-63).
  • Calcite: CalciteTypeConverter.toCalciteType maps JSON to VARCHAR (CalciteTypeConverter.java:77-78), and I specifically checked the reverse-derivation path in the pre-existing, untouched OutputRowTypeDeriver.java (not part of this diff) to verify the PR's claim that untouched projections keep the JSON type: inferProjectedType (OutputRowTypeDeriver.java:68-79) resolves a plain SqlIdentifier select item via findInputFieldType, which returns the original input SeaTunnelDataType (i.e. JSON_TYPE), and only falls back to CalciteTypeConverter.toSeaTunnelType(fields.get(i).getType()) (which maps VARCHAR back to STRING_TYPE, not JSON_TYPE — there is no reverse JSON mapping) for computed expressions such as an explicit CAST(... AS VARCHAR). This confirms the documented migration path is real: a plain SELECT payload FROM t keeps JSON_TYPE, while CAST(payload AS VARCHAR) genuinely downgrades to STRING_TYPE.
  • Copy and JsonPath accept JSON input by adding case JSON alongside case STRING (CopyFieldTransform.java:133-134, JsonPathTransform.java:140-141).
  • Snowflake: VARIANT maps to JSON in both directions (SnowflakeTypeConverter.java:148-155,303-306, SnowflakeDataTypeConvertor.java:133-134,183-184). New JdbcDialect.getInsertIntoStatement(String,String,TableSchema) / getUpdateStatement(String,String,TableSchema,String[],boolean) default methods delegate to the old field-name overloads (JdbcDialect.java:163-170,211-227), so every dialect that does not override them — i.e. every non-Snowflake dialect and any third-party JdbcDialect SPI implementation — keeps byte-identical SQL generation. SnowflakeDialect overrides both and wraps only JSON-typed binds with PARSE_JSON(:field) via parameterExpression (SnowflakeDialect.java:47-108,826-831), and the bind value itself is still sent with setString (AbstractJdbcRowConverter.java:697-699), i.e. PARSE_JSON parses the bound text server-side.
  • StarRocks: JSON columns map to JSON_TYPE. Because the MySQL wire protocol reports StarRocks JSON columns as VARCHAR, StarRocksCatalog added getNativeColumnTypes (an information_schema.columns lookup) to disambiguate before falling back to the JDBC-metadata-based fromJdbcType (StarRocksCatalog.java:165-190,320-333,394-412). JSON Stream Load parses each value into a tree via a shared, effectively-immutable ObjectMapper (fluent .reader().with(...) never mutates the shared instance, so it is safe under serializer reuse/concurrency) (StarRocksJsonSerializer.java:34-40,57-70,85-104); the CSV Stream Load branch fails fast with an actionable message instead of silently mis-encoding JSON (StarRocksBaseSerializer.java:73-79).
  • Doris: JSON/JSONB map to JSON_TYPE and reconvert to native JSON (AbstractDorisTypeConverter.java:184-193,381-385).

Complete runtime path (native JSON source to native JSON sink), reconstructed and verified against source, not the PR description:

native source column (Doris JSON/JSONB | StarRocks JSON | Snowflake VARIANT)
  -> catalog/type converter returns BasicType.JSON_TYPE
     AbstractDorisTypeConverter.java:186-193 / StarRocksCatalog.java:321-333,394-412 / SnowflakeTypeConverter.java:148-155
  -> value read as JSON text (String-backed, same physical representation as STRING)
     ArrowToSeatunnelRowReader.java:161-162 (Doris/StarRocks Arrow scan) / AbstractJdbcRowConverter.java:81-84 (JDBC read)
  -> engine transport: I grepped seatunnel-engine and seatunnel-translation-flink for any
     SqlType/getSqlType() switch and found none in either module -- Zeta and Flink carry
     SeaTunnelRow opaquely with no per-field type dispatch, so this hop is unaffected by the change;
     Spark translation explicitly maps JSON -> StringType/UTF8String and handles array<json>
     (TypeConverterUtils.java:75-76, InternalRowConverter.java:110-113,127-129,332-335,
      SeaTunnelRowConverter.java:110-116,229-231)
  -> optional transforms: Calcite keeps JSON_TYPE for untouched column projections
     (OutputRowTypeDeriver.java:57-64,68-79) and only downgrades to STRING_TYPE for an explicit
     CAST(... AS VARCHAR); Copy and JsonPath pass JSON text through unchanged
  -> sink serialization: RowToJsonConverters.java:177-193 (JSON format) |
     StarRocksJsonSerializer.java:57-70 (JSON Stream Load; CSV Stream Load fails fast,
     StarRocksBaseSerializer.java:73-79) | SnowflakeDialect.java:104-108 PARSE_JSON binds |
     Doris JSON Stream Load via SeaTunnelRowSerializer.java:87-90 (JsonSerializationSchema branch)

Key findings from independent verification (not carried over from the author's own review text):

  • The SqlType enum-tail append and BasicType identity design are compatibility-safe: no ordinal dependency exists anywhere in the codebase, and old serialized state deserializes the same enum constants it always did.
  • The Calcite untouched-projection-preserves-JSON claim is genuinely true, verified by reading the actual (pre-existing, unmodified) OutputRowTypeDeriver resolution logic rather than taking the PR description at face value.
  • The JdbcDialect SPI compatibility claim (default-method delegation) is genuinely true and independently confirmed by reading both the interface defaults and the one concrete override (SnowflakeDialect).
  • Two generic, widely-reachable surfaces still reject JSON with an unhelpful generic error: the seatunnel-format-text module (Issue 2) and FakeDataGenerator random generation (Issue 3). Both are real, source-confirmed gaps, not carried over from any prior review without verification.
  • The current PR head's CI is genuinely red with real (non-cancelled) job failures that overlap this PR's own new JSON E2E coverage (Issue 1), independently confirmed via the GitHub Actions API against the fork's actual run, not the Apache-side pointer check.

1.2 Compatibility Impact

Partially incompatible (intentional, and documented bilingually). Native Snowflake VARIANT, Doris JSON/JSONB, and StarRocks JSON source columns discovered via catalog/JDBC-metadata change from STRING to JSON after upgrade, with no config change required. Concretely, for an existing pipeline of one of these three connectors reading a native JSON column into a text-format file sink, or into a Doris sink configured for CSV Stream Load, the pipeline worked before this PR (because the column was STRING) and will now hard-fail with an unsupported-type error after upgrade (see Issue 2) — this is a real, if documented, previously-working-pipeline regression, not merely a "new feature gap." docs/en/introduction/concepts/incompatible-changes.md:27-32 (and the docs/zh counterpart) names the affected connectors, lists which components support the new type in this release, and gives a CAST(payload AS VARCHAR) migration recipe with an explicit warning not to apply it when the destination is a native JSON column — this is exactly the kind of documented incompatible-change entry the project requires. SqlType ordinal safety and BasicType.serialVersionUID (unchanged, = 2L) mean existing checkpoint/savepoint state deserializes unchanged; the only unavoidable caveat is that state or configs containing the new JSON constant cannot be read by an older release (irrelevant to forward upgrade, relevant only to rollback).

1.3 Performance / Side-Effect Analysis

  • JSON parse/validate work is linear in payload size and confined to explicit format/protocol boundaries (JSON format serialize, StarRocks JSON Stream Load); the JSON-to-row read path stores jsonNode.toString() without a second validation pass.
  • StarRocksCatalog.getTable now issues one additional information_schema.columns query per table (StarRocksCatalog.java:394-412) — catalog/discovery-time only, not per-row, acceptable.
  • Snowflake PARSE_JSON(:field) moves parsing server-side per bind, consistent with how VARIANT columns are normally populated in Snowflake.
  • The shared ObjectMapper in StarRocksJsonSerializer is a legitimate reuse pattern (verified stateless/thread-safe above), not a hidden mutable-shared-state risk.

1.4 Error Handling and Logging

Malformed, empty, or trailing-token JSON fails with CommonError.jsonOperationError context (component name + short reason) before it can propagate downstream (RowToJsonConverters.java:186-192, StarRocksJsonSerializer.java:63-68 via the wrapping in serialize); no JSON payload content is newly logged. Formal issues below, severity-sorted; all are my own findings, independently re-derived and re-verified against the current head's source and the live GitHub state, not adopted from the author's prior self-review text.

Issue 1 (High)

  • Location: seatunnel-e2e/.../doris/DorisIT.java:255-296 (assertJsonColumnsRoundTrip, sawJsonNull assertion at line 295); seatunnel-e2e/.../starrocks/StarRocksIT.java:511-524 (assertJsonColumnsRoundTrip, assertNull(resultSet.getString("json_null")) at line 524). Live CI: fork run 30824391316 at head 070b249 (gh run list --repo DanielLeens/seatunnel --branch davidzollo_json-type-10774).
  • Problem: I independently queried the live GitHub Actions state (not the PR's self-review claim) for the current head and confirmed the run is CANCELLED after ~12.5h with concluded (non-cancelled) job failures in: Run / Dead links, Run / unit-test (11, windows-latest), Run / jdbc-connectors-it-part-2 (11, ubuntu-latest), Run / kafka-connector-it (11, ubuntu-latest), Run / doris-connector-it (8, ubuntu-latest); the remaining lanes were cancelled without a conclusion once the overall run was aborted. The Kafka and Doris lanes execute this PR's own new JSON E2E scenarios. I traced a concrete root-cause hypothesis myself by comparing the two connectors' JSON-null assertions: StarRocksIT.java:524 explicitly asserts that a JSON null value written through Stream Load reads back as SQL NULL (i.e. StarRocks itself normalizes JSON null to SQL null on Stream Load) — this was a correction the author had to make in commit 0fc133c after discovering the server behavior. DorisIT.java:295 makes the opposite, unverified assumption for Doris: Assertions.assertTrue(sawJsonNull, "Doris JSON E2E must cover JSON null"), i.e. it requires Doris Stream Load to preserve JSON null as distinct JSON null, not normalize it to SQL null — the same server-behavior class of assumption that was already proven wrong once for StarRocks in this same PR, now applied unverified to Doris. I was not able to pull the actual container job logs for this lane in this environment (the Actions log-blob redirect URL expired/EOF'd on every retry), so I cannot show the exact failing assertion text from the log; I am reporting the concrete, source-level, testable hypothesis and the independently-confirmed fact that the lane is genuinely red on the current head, not a stale/cancelled artifact.
  • Potential risk: Merging with red CI on lanes that exercise this PR's own new functionality risks hiding a real cross-connector behavioral defect (either the Doris test's JSON-null assumption is wrong and must be corrected like the StarRocks one was, or there is a genuine Doris-side bug in JSON-null handling that needs a source fix).
  • Best improvement: Pull the Kafka and Doris lane logs, confirm whether Doris Stream Load normalizes JSON null to SQL null the same way StarRocks does; if so, fix DorisIT.assertJsonColumnsRoundTrip's sawJsonNull assertion to match reality (mirroring the StarRocks fix), then rerun CI at the current head (the branch is reported 0 behind dev, so a dev sync will not fix this).
  • Severity: High.

Issue 2 (Medium)

  • Location: seatunnel-formats/seatunnel-format-text/.../TextSerializationSchema.java:187,237-241 and TextDeserializationSchema.java:239,265-267,288,368 (no case JSON in either direction, both fall through to default: throw ... UNSUPPORTED_DATA_TYPE); triggered concretely via seatunnel-connectors-v2/connector-doris/.../serialize/SeaTunnelRowSerializer.java:87-102 where the else (CSV) branch builds a TextSerializationSchema with no JSON handling, unlike the JSON branch which correctly uses JsonSerializationSchema (line 89-93).
  • Problem: I read both switch statements directly and confirmed neither has a JSON case (every other format touched by this PR — CSV, Avro, JSON — was given a paired case STRING: case JSON: or equivalent; text format was not). Concretely, a Doris sink with doris.config.format = "csv" writing a table with a native JSON/JSONB column will now throw UNSUPPORTED_DATA_TYPE after upgrade, whereas before this PR the same column was STRING_TYPE and worked. The same gap hits any file sink using the (default) text format fed by a native JSON source. StarRocks handles the equivalent situation far better: StarRocksBaseSerializer.java:73-79 fails fast with an actionable "Native JSON columns require JSON Stream Load format" message plus a doc note (docs/zh/connectors/sink/StarRocks.md:193, and the English page). The Doris sink docs advertise JSON/JSONB -> JSON with no CSV-format caveat.
  • Potential risk: A previously-working Doris-CSV or default-text-format pipeline against a native JSON source breaks on upgrade with a generic error that gives the operator no clue this is a JSON/format interaction, no mention of the CAST migration path documented elsewhere in this same PR.
  • Best improvement: Either (Option A) add a case JSON String pass-through to TextSerializationSchema/TextDeserializationSchema — a one-line change per direction, closing the largest remaining generic-surface gap and matching how CSV was handled in this same PR — or (Option B) replicate the StarRocks fail-fast pattern for the Doris CSV branch plus a doc caveat in both docs/en and docs/zh. I prefer Option A: it is smaller than the CSV work already done in this PR and removes the last widely-used surface where a native JSON source can silently break a previously-valid pipeline.
  • Severity: Medium (documented workaround exists via an explicit Calcite CAST transform inserted upstream of the affected sink/format, but the failure is a genuine regression for zero-config-change upgrades).

Issue 3 (Medium)

  • Location: seatunnel-connectors-v2/connector-fake/.../source/FakeDataGenerator.java:210-337 (randomColumnValue, switch has case STRING: at line 235 but no case JSON:, falls to default: at line 337).
  • Problem: I read randomColumnValue directly and confirmed there is no JSON branch. docs/en/introduction/concepts/schema-feature.md (this PR) now lists json as a first-class basic type keyword usable anywhere a schema is declared, and FakeSource without explicit rows is the standard way a user experiments with a schema/type. A FakeSource schema declaring payload = json with no rows override therefore throws UNSUPPORTED_DATA_TYPE immediately. All of this PR's own new E2E configs supply explicit rows (confirmed by grep across the new .conf files), which is exactly why this gap is invisible to CI.
  • Potential risk: The first thing a user trying the newly-documented json keyword with a plain FakeSource sees is an unsupported-type crash — a poor first-touch experience for the feature this PR introduces.
  • Best improvement: Generate a small deterministic JSON value (object/array/scalar) for JSON columns in randomColumnValue, with a dedicated unit test.
  • Severity: Medium.

Issue 4 (Medium)

  • Location: seatunnel-e2e/.../starrocks/StarRocksIT.java:382-391 (testNativeJsonRejectsCsvStreamLoad, asserts on execResult.getStderr() + container.getServerLogs() string content); seatunnel-e2e/.../doris/DorisIT.java:255-296 (server-normalization assumption, see Issue 1).
  • Problem (mandatory test-stability analysis, rule 9): I checked for the standard flakiness patterns. No Thread.sleep found in the new JSON-specific E2E code I reviewed. The concrete risk I found is engine-dependent log/error surfacing: StarRocksIT.java:387 concatenates container stderr with getServerLogs() and asserts a specific substring is present — where a sink exception actually surfaces (stderr vs. server log vs. exit code alone) can differ across Zeta/Flink/Spark containers, and I did not find this test scoped to a single engine. Combined with Issue 1's JSON-null server-behavior assumption (already proven wrong once for StarRocks and re-applied unverified to Doris), these are the two concrete stability risks in the new JSON E2E surface.
  • Mandatory stability rating: Risk present (not High risk on its own — it does not use sleep-based waits or nondeterministic ordering — but combined with Issue 1 it is directly implicated in the current red CI).
  • Potential risk: Lanes stay flaky/engine-sensitive even after Issue 1's root cause is fixed, if the log-string assertion additionally breaks under a different container engine.
  • Best improvement: Assert the CSV-rejection case via exit code plus a log check restricted to the engine(s) whose log placement is deterministic (or drop the log substring check and rely on exit code plus a targeted error field check), and make the JSON-null expectations for both connectors explicit about server-side normalization behavior rather than assuming it.
  • Severity: Medium.

Issue 5 (Medium)

  • Location: seatunnel-connectors-v2/connector-starrocks/.../config/SinkConfig.java:97-103; cross-referenced against seatunnel-connectors-v2/connector-starrocks/.../client/StarRocksStreamLoadVisitor.java:383-392.
  • Problem: I traced this precisely rather than taking the "legacy shim" description at face value. Before this PR, StarRocksStreamLoadVisitor.getStreamLoadHttpHeader (lines 383-392) copies all streamLoadProps entries (including any user-set starrocks.config.format) into headerMap, but then unconditionally overwrites the "format" header with sinkConfig.getLoadFormat().name() on line 392 — meaning starrocks.config.format had zero effect prior to this PR; it was accepted but silently discarded. This PR's new code in SinkConfig.of() (lines 98-103) reads that same streamLoadProps.get("format") and, if present, overwrites the loadFormat that was just correctly derived from the proper StarRocksSinkOptions.LOAD_FORMAT option two lines above — i.e. a previously-inert option now takes effect and silently wins over the documented option when both are set. The conversion itself is a bare StreamLoadFormat.valueOf(...), so any value other than CSV/JSON (case-insensitive) throws a context-free IllegalArgumentException with no mention of which config key caused it. The block also carries no comment explaining this is a deliberate compatibility decision.
  • Potential risk: (a) Users who previously set starrocks.config.format as a no-op (perhaps copy-pasted from StarRocks' own Stream Load HTTP header docs) now get a real, silent behavior/precedence change if they also set load_format to something different. (b) Config typos produce an unhelpful stack trace instead of a config-validation-style error naming the option and allowed values.
  • Best improvement: Wrap the conversion in a StarRocksConnectorException naming the option (starrocks.config.format) and allowed values (CSV, JSON); explicitly warn or reject when both load_format and starrocks.config.format are set to conflicting values; add a comment stating this is a deliberate legacy-compatibility shim and why.
  • Severity: Medium (new in commit 0fc133c, i.e. introduced during this PR's own CI-stabilization work, not present at the PR's initial submission).

Issue 6 (Low)

  • Location: seatunnel-formats/seatunnel-format-json/.../RowToJsonConverters.java:250-296 (createRowConverter), specifically the new branch at line ~283-290 versus wrapIntoNullableConverter at lines 78-88.
  • Problem: I confirmed by reading both methods that the SQL-null-removes-property rule (line 290, node.remove(fieldName)) applies only to the top-level row-field loop in createRowConverter, and that it runs before the field converter (and therefore before wrapIntoNullableConverter's nullValue handling) is ever invoked for a JSON-typed field. Two consequences, both confirmed by code reading: (a) a SQL-null element nested inside array<json> or a JSON-typed map value goes through the ordinary nullable-converter path instead, which renders it as an explicit nullNode() — so the SQL-null/JSON-null distinction that is carefully preserved at the top level is silently lost for nested positions (it will round-trip back as the text "null", indistinguishable from an explicit JSON null). (b) A configured format nullValue (e.g. \N) is completely bypassed for top-level JSON fields — the property is removed rather than rendered as the configured null placeholder, unlike every other type in this schema, where nullValue is honored via wrapIntoNullableConverter.
  • Potential risk: Low — this is a documented-by-design top-level behavior, but the nested-position asymmetry and the nullValue-bypass are both currently undocumented, and a user relying on either the array/map null semantics or a configured nullValue for a JSON column would get a silent surprise.
  • Best improvement: Document the nested-position behavior and the nullValue bypass in docs/en/introduction/concepts/schema-feature.md (both locales), or extend the SQL-null/JSON-null distinction into the array/map converter branches for full consistency.
  • Severity: Low.

Issue 7 (Low)

  • Location: seatunnel-connectors-v2/connector-starrocks/.../catalog/StarRocksCatalog.java:394-412 (getNativeColumnTypes).
  • Problem: I confirmed there is no Javadoc or inline comment on this new method. It exists specifically to work around the MySQL wire protocol reporting StarRocks JSON columns as VARCHAR in ResultSetMetaData (the actual reason, per the PR's own commit history, but not stated in the code itself) — exactly the kind of non-obvious protocol-limitation rationale that should be captured in a comment per this project's documentation standard for new non-trivial methods.
  • Potential risk: A future contributor, seeing what looks like a redundant extra metadata query, could "simplify" it away, silently regressing JSON column discovery back to STRING_TYPE.
  • Best improvement: Add a one-paragraph Javadoc stating the protocol limitation and why the extra information_schema.columns lookup is necessary.
  • Severity: Low.

2. Code Quality Assessment

2.1 Coding Standards

Title follows [Feature][API]. New/changed non-trivial methods generally carry Javadoc consistent with this project's standard (e.g. parameterExpression, readJsonValue, the various E2E helper methods) — the two exceptions are captured as Issues 5 and 7 above (missing comment on a deliberate compatibility decision, and on a protocol-workaround method, respectively; both are Medium/Low findings above, not restated here). Naming and code placement are consistent with each module's existing conventions; the JdbcDialect schema-aware overloads follow the project's established default-method extension pattern rather than introducing a new one.

2.2 Test Coverage and Test Stability

Coverage is genuinely broad across the surfaces this PR touches: type-declaration parsing (SeaTunnelDataTypeConvertorUtilTest), JSON serde with explicit null-distinction and invalid-input rejection tests (JsonRowDataSerDeSchemaTest.testJsonLogicalTypeSerDe/testJsonLogicalTypeRejectsInvalidJson), CSV/Avro round trips including embedded delimiters (CsvTextFormatSchemaTest, AvroSerializationSchemaTest), the Arrow reader conversion path, Calcite projection behavior, Copy/JsonPath, all three connectors' converters/serializers/save-mode DDL generation (including a new SnowflakeTypeConverterTest asserting exact PARSE_JSON SQL text), and E2E coverage for LocalFile JSON/CSV, Kafka JSON/Avro, the two transform E2E suites, and Doris/StarRocks native round trips including a negative CSV-rejection test for StarRocks.

Mandatory stability rating (rule 9): Risk present. This is not a "Stable" rating because of the two concrete items verified above and counted as formal issues: the Doris/StarRocks JSON-null server-normalization assumption asymmetry (Issue 1/4) and the engine-dependent stderr/log-string assertion in StarRocksIT.testNativeJsonRejectsCsvStreamLoad (Issue 4). I did not find Thread.sleep-based waits, hard-coded ports, or floating-point-without-delta assertions in the JSON-specific test code I reviewed in depth; I did not independently verify the claim (made in the PR's own text, not verified by me) that Kafka topic names are per-container-unique with cleanup, since I did not do a full line-by-line read of KafkaIT.java's JSON-specific additions — flagging this as a scope boundary per rule 12 rather than asserting it either way.

2.3 Documentation Updates

docs/en and docs/zh are updated in lockstep and I read both language versions of the incompatible-changes and schema-feature pages directly: the json keyword and array<json> are documented in the type table, the null-semantics distinction (Java null = SQL null, text "null" = JSON null) is stated, and the incompatible-changes ledger names the affected connectors, the supported-component list, and the CAST(payload AS VARCHAR) migration with an explicit warning against misapplying it. Two confirmed gaps: the Doris sink page does not carry the CSV-format restriction note that the StarRocks page has (part of Issue 2), and the nested-null asymmetry from Issue 6 is undocumented in either locale.

3. Architectural Soundness

3.1 Elegance of the Solution (Precise fix / Temporary workaround / Long-term solution)

This is a long-term solution, not a workaround. A String-backed logical type plus opt-in, connector-native protocol mapping is the correct boundary for this kind of feature: the generic engine/transport layers stay type-agnostic (verified: no SqlType switch exists in seatunnel-engine or seatunnel-translation-flink), and only the specific protocol edges that need JSON semantics (Snowflake PARSE_JSON, StarRocks/Doris JSON Stream Load) interpret the value specially. The alternative of a tree-based public JSON API in SeaTunnelRow would avoid some re-parsing but would require a much larger, harder-to-reason-about serialization/compatibility surface; the incremental, String-backed design chosen here is the safer choice for a system with this project's backward-compatibility bar.

3.2 Maintainability

Type mapping, value validation, and protocol-specific serialization are cleanly separated across modules. The JdbcDialect default-method delegation pattern keeps the SPI contract stable for all third-party dialect implementations. The two places that most need better self-documentation for future maintainers are Issues 5 and 7 above.

3.3 Extensibility

Other connectors can opt in to JSON by adding one native-type mapping; connectors and generic surfaces that have not opted in fail loudly with an explicit unsupported-type error rather than silently mis-stringifying JSON, which is the right default for a new logical type. The remaining friction is that every generic value-consuming surface needs its own explicit JSON case — seatunnel-format-text (Issue 2) is the last widely-used one still missing it, and FakeDataGenerator (Issue 3) is the most user-visible one.

3.4 Historical-Version Compatibility

Enum-tail append preserves every existing SqlType ordinal (confirmed: no ordinal dependency anywhere in the repository); BasicType.serialVersionUID is unchanged. Neither Zeta's engine transport nor Flink's translation layer contains a per-SqlType serialization switch (confirmed by repository-wide grep), so existing checkpoint/savepoint state restores unchanged after upgrade. The incompatibility surface is precisely bounded to (a) schemas newly discovered from the three connectors' native JSON columns, which is documented with a migration path, and (b) the inherent, standard caveat that state/configs containing the new JSON constant cannot be read by an older release on rollback. Old third-party JdbcDialect SPI implementations compile and behave identically through the new default methods.

4. Issue Summary

No. Issue Location Severity
1 Current-head CI genuinely red in Kafka/Doris IT lanes that execute this PR's own JSON E2E; Doris JSON-null round-trip assertion makes the same server-normalization assumption already disproven for StarRocks in this PR DorisIT.java:255-296,295; StarRocksIT.java:511-524,524 High
2 seatunnel-format-text (and the Doris sink's CSV branch, which is built on it) has no JSON case; a previously-working native-JSON-to-text/CSV pipeline breaks on upgrade with a generic error TextSerializationSchema.java:187,237-241; SeaTunnelRowSerializer.java:87-102 Medium
3 FakeSource random generation has no JSON case despite json now being a documented first-class schema keyword FakeDataGenerator.java:210-337 Medium
4 E2E stability: engine-dependent log-string assertion; JSON-null server-normalization assumption (see Issue 1) StarRocksIT.java:382-391 Medium
5 starrocks.config.format legacy shim: previously-inert option now silently overrides the documented load_format option; bare valueOf with no contextual error; no comment SinkConfig.java:97-103 Medium
6 Nested array<json>/map SQL-null vs JSON-null distinction lost; configured nullValue silently bypassed for top-level JSON fields RowToJsonConverters.java:250-296 Low
7 getNativeColumnTypes protocol-workaround method lacks an explanatory comment StarRocksCatalog.java:394-412 Low

5. Merge Recommendation

Conclusion: Ready to merge after fixes

  1. Blockers — must be fixed

    1. Issue 1 (High): Diagnose and fix the current-head CI failures in the Kafka and Doris IT lanes, which execute this PR's own new JSON E2E scenarios. My independently-derived working hypothesis: Doris Stream Load likely normalizes JSON null to SQL NULL, the same server behavior already discovered and fixed for StarRocks in this PR's own 0fc133c commit; DorisIT.assertJsonColumnsRoundTrip's sawJsonNull assertion (line 295) currently assumes the opposite and needs to be verified against real Doris Stream Load behavior and corrected if my hypothesis holds. The jdbc-connectors-it-part-2 and Dead links lane failures should be independently triaged — the latter appears to be a pre-existing, unrelated repo-wide docs link-check issue based on the failure lane name, but this was not independently confirmed via log content in this review. Because the branch is reported 0 commits behind dev, a dev sync alone will not resolve these; the fix-and-rerun-at-this-head path is required.
  2. Recommended fixes — non-blocking

    1. Issue 2: add a JSON case to seatunnel-format-text, or replicate the StarRocks fail-fast-with-actionable-message pattern for the Doris CSV branch plus a doc caveat in both locales.
    2. Issue 3: add JSON support to FakeDataGenerator.randomColumnValue.
    3. Issue 4: harden the engine-sensitive log-string assertion in StarRocksIT.testNativeJsonRejectsCsvStreamLoad.
    4. Issue 5: give the starrocks.config.format legacy shim a contextual error message and an explanatory comment; consider warning on conflicting load_format/starrocks.config.format values.
    5. Issues 6-7: document the nested-null asymmetry and the nullValue bypass; add the missing Javadoc to getNativeColumnTypes.

Overall assessment: The core design — a String-backed logical type with opt-in, connector-native protocol handling, appended safely to the tail of SqlType, with no ordinal or checkpoint-compatibility risk anywhere in the codebase — is sound and is the right long-term shape for this feature. Every core compatibility claim I independently checked (ordinal safety, JdbcDialect SPI backward compatibility, Calcite's untouched-projection type preservation, Zeta/Flink transport being unaffected) held up under direct source verification. What currently blocks merge is a genuinely red CI on lanes that exercise this PR's own new functionality, plus a cluster of Medium/Low findings in generic surfaces (text format, FakeSource) and one connector-specific compatibility nuance (the StarRocks legacy format shim) that should be closed before this lands, given the project's backward-compatibility bar. Two options exist for the largest remaining gap (Issue 2): Option A — add a String pass-through JSON case to seatunnel-format-text, which is small and consistent with how this PR already handled CSV; Option B — keep text format unsupported but fail fast with a JSON-specific, actionable message and document the restriction on the Doris sink page, mirroring StarRocks. I'd lean toward Option A as the more complete fix, but either is acceptable for merge. As the author is also the only reviewer of record so far, a write-capable maintainer still needs to perform the final independent review, verify the CI root cause once logs are available, and approve/merge.

@SEZ9 SEZ9 left a comment

Copy link
Copy Markdown
Collaborator

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 latest head 070b249d1199.

What this PR fixes

  • User pain: Native semi-structured columns (Snowflake VARIANT, Doris JSON/JSONB, StarRocks JSON) are flattened to STRING, so JSON structure is lost end-to-end and sinks store escaped strings instead of native JSON values.
  • Fix approach: Introduce a String-backed SqlType.JSON / BasicType.JSON_TYPE logical type, wire it through schema parsing, Spark translation, Calcite SQL, Copy/JsonPath transforms, CSV/Avro/JSON formats, and map it natively in the Snowflake (PARSE_JSON on generated INSERT/UPDATE), Doris, and StarRocks connectors, plus docs and an incompatible-change entry.
  • One-line summary: The type plumbing is broad and the docs/migration notes are commendably thorough, but the source-side STRING-to-JSON remap is a silent breaking change with no opt-out, and JSON validity is only enforced at the StarRocks load boundary rather than fail-fast at sink initialization or via the type itself, so I want the compatibility and validation gaps addressed before merge.

Runtime chain I rechecked

Source read path (StarRocks/Doris/Snowflake -> JSON logical type):
  StarRocksCatalog.buildColumn() -> StarRocksTypeConverter.convert("JSON")  StarRocksTypeConverter.java:~210
    -> returns BasicType.JSON_TYPE  BasicType.java (new JSON_TYPE constant)
  SnowflakeTypeConverter.convert("VARIANT") -> BasicType.JSON_TYPE  SnowflakeTypeConverter.java

Sink write path (Snowflake, generated statements):
  JdbcOutputFormat.writeRecord() -> SnowflakeDialect.getInsertIntoStatement()/getUpsertStatement()  SnowflakeDialect.java
    -> wraps JSON columns as PARSE_JSON(:field) in the generated SQL
    -> FieldNamedPreparedStatement.setString() binds the String-backed JSON value

Sink write path (StarRocks Stream Load):
  StarRocksSinkWriter.write() -> StarRocksISerializer.serialize()
    -> StarRocksJsonSerializer.serialize() emits the JSON field as a structured JSON node (readTree) instead of a quoted string; invalid JSON throws before load  StarRocksJsonSerializer.java
    -> StarRocksCsvSerializer rejects JSON-typed fields explicitly (CSV Stream Load unsupported)  StarRocksCsvSerializer.java

Schema declaration path:
  SeaTunnelDataTypeConvertorUtil.deserializeDataType("json" | "array<json>") -> BasicType.JSON_TYPE / ArrayType(JSON)  SeaTunnelDataTypeConvertorUtil.java

Note: line numbers in the code paths above are approximate and should be verified against the full change set.

Findings

Issue 1: Snowflake VARIANT, Doris JSON/JSONB, and StarRocks JSON source columns silently change from STRING to the new JSON logical type with no opt-out, breaking existing pipelines on upgrade

  • Location: docs/en/introduction/concepts/incompatible-changes.md:27
  • Why it matters: - Root cause: this PR unconditionally remaps native semi-structured columns to the new SqlType.JSON in the Snowflake, Doris, and StarRocks type converters, and the docs confirm there is no configuration to retain the previous STRING mapping — only a manual Calcite CAST(... AS VARCHAR) workaround.
  • Impact: any existing pipeline that reads one of these columns and writes to a sink that has not been taught about JSON (MySQL, Hive, Elasticsearch, most JDBC dialects, etc.) will fail at schema-mapping time with an unsupported-type error immediately after upgrading, even though the user changed nothing. Saved job configs and restored Zeta checkpoints that captured the old STRING schema can also mismatch the newly discovered JSON schema on restart, so a job that was mid-flight before the upgrade may not resume cleanly.
  • Fix: add a connector-level option (e.g., json.type.mapping = JSON|STRING, defaulting to the legacy STRING for at least one release) on the affected Snowflake/Doris/StarRocks converters, or gate the new mapping behind an explicit opt-in, following the deprecation pattern used for other incompatible changes in this file. At minimum, the type converters should produce an actionable error message that points users to the CAST workaround.
  • Evidence: docs/en/introduction/concepts/incompatible-changes.md:30 - **Impact**: Pipelines that inspect the source schema or write to a sink without JSON support can observe a different type or receive an unsupported-type error.; docs/en/connectors/source/Snowflake.md:52 | VARIANT | JSON |
  • Suggested fix: This is an unconditional breaking change for every pipeline that currently reads Snowflake VARIANT, Doris JSON/JSONB, or StarRocks JSON into a sink without JSON support — those jobs will fail with an unsupported-type error immediately after upgrading, and jobs restored from a pre-upgrade checkpoint can hit a schema mismatch on restart. Please add an opt-out (e.g., a json.type.mapping = JSON|STRING converter option defaulting to the legacy STRING for one release) instead of relying on users to insert a Calcite CAST(... AS VARCHAR) transform after their job has already broken.
  • Severity: High

Issue 2: JSON logical type is physically a plain String everywhere, so nothing prevents non-JSON text from reaching a native JSON sink; validation appears to exist only at the StarRocks load boundary

  • Location: docs/en/introduction/concepts/schema-feature.md:142
  • Why it matters: - Root cause: the new type is documented as String-backed (java.lang.String) with a text-based convention distinguishing SQL null (Java null) from JSON null (the text null), and the PR treats JSON as its String physical representation in Spark translation, Calcite, Copy, JsonPath, CSV, and Avro — meaning any transform or format in the middle of a pipeline can produce arbitrary, invalid text for a JSON-typed field without early rejection.
  • Impact: per the PR description, invalid JSON is rejected "before loading" only in the StarRocks path; for Doris and Snowflake (PARSE_JSON executes server-side) malformed values from a Calcite expression, a Copy transform, or a CSV source only fail deep inside the sink, per-batch, with an error message that does not identify which upstream component corrupted the value — and on Snowflake the whole batch statement fails, aborting sibling rows.
  • Fix: centralize a lightweight isValidJson check (the JSON-format parser in this PR already rejects empty/incomplete/trailing-token input) and apply it in the JDBC row converter for JSON fields and in the Doris serializer as well, so all three native-JSON sinks fail with a consistent, field-identifying error instead of an opaque server-side one. Also consider whitespace tolerance in the JSON-null sentinel comparison (null vs null) so semantically null values are not mis-stored.
  • Evidence: docs/en/connectors/source/StarRocks.md:24 StarRocks native JSONcolumns map to the SeaTunnelJSON logical type. JSON values are represented as valid JSON text inside SeaTunnel.
  • Suggested fix: Since JSON is physically a plain java.lang.String, transforms (Calcite expressions, Copy) and text formats can put arbitrary invalid text into a JSON-typed field, and per this PR only the StarRocks Stream Load path validates before loading — Doris and Snowflake (PARSE_JSON runs server-side) will fail deep inside the sink with a batch-level, non-field-identifying error. Please centralize a lightweight JSON-validity check (the JSON format parser added here already rejects empty/incomplete/trailing input) and apply it in the JDBC row converter and Doris serializer for JSON fields, and make the null JSON-null sentinel comparison whitespace-tolerant.
  • Severity: Medium

Issue 3: StarRocks sink with native JSON columns and the default CSV Stream Load format only fails at load time; the rejection should be a fail-fast validation at sink initialization

  • Location: docs/en/connectors/sink/StarRocks.md:229
  • Why it matters: - Root cause: the PR explicitly rejects native JSON fields in StarRocks CSV Stream Load, but the StarRocks sink defaults to CSV format, so the auto-created-native-JSON-table path documented right above this note produces a configuration that is invalid by default and requires a manual starrocks.config.format = "JSON" override.
  • Impact: if the rejection is raised inside the Stream Load serialization/flush path rather than at sink prepare/open, a streaming job will start successfully, possibly auto-create the table with a native JSON column, buffer rows, and then fail on the first flush containing a JSON field — on Zeta/Flink this triggers restart loops that repeatedly hit the same deterministic error, and any rows batched with the failing one are re-driven through retries that can never succeed.
  • Fix: validate the (schema contains JSON field) × (format == CSV) combination once during sink initialization/table-schema resolution and fail immediately with a message telling the user to set starrocks.config.format = "JSON", instead of (or in addition to) rejecting per-row during serialization. Also state in the docs that CSV is the default format, so users understand they must change it for JSON columns.
  • Evidence: docs/en/connectors/sink/StarRocks.md:229 Native StarRocks JSONcolumns require JSON Stream Load. Setstarrocks.config.format = "JSON"; CSV Stream Load does not support JSON-formatted columns.
  • Suggested fix: Since the StarRocks sink defaults to CSV Stream Load, a pipeline that reads a native JSON column (or auto-creates one) is invalid out of the box unless the user remembers to set starrocks.config.format = "JSON". Please make sure this JSON-field-with-CSV combination is rejected at sink initialization (schema resolution / prepare), not inside the Stream Load flush path — otherwise a streaming job starts, buffers rows, and then enters a deterministic restart loop on the first flush. It would also help to mention here that CSV is the default format.
  • Severity: Medium

Issue 4: Snowflake sink with a user-defined query silently skips PARSE_JSON wrapping for JSON fields, deferring failure to a server-side error mid-run

  • Location: docs/en/connectors/sink/Snowflake.md:53
  • Why it matters: - Root cause: PARSE_JSON(:field) is only injected into SeaTunnel-generated INSERT/UPDATE statements; when the user supplies a custom query, JSON-typed fields are bound as plain strings and the docs merely ask the user to add the conversion manually.
  • Impact: an upgraded pipeline whose custom query targets a VARIANT column will either fail server-side on every batch (Snowflake rejects a bare string bind into VARIANT depending on the statement) or, worse, silently store an escaped JSON string instead of a structured VARIANT — a data-correctness regression that is invisible until someone queries the target. Because the error surfaces per-batch inside the JDBC write path, the connector's retry logic will re-drive a deterministic failure until retries exhaust, instead of failing fast.
  • Fix: when the sink row type contains a JSON field and a user-defined query is configured, log a prominent warning (or validate and fail fast with a message naming the field and suggesting PARSE_JSON) at output-format construction time, rather than relying only on this documentation note.
  • Evidence: docs/en/connectors/sink/Snowflake.md:53 When SeaTunnel generates the insert statement, JSON fields are wrapped with PARSE_JSONso their JSON structure is stored in SnowflakeVARIANT. For a user-defined query, add the required Snowflake conversion function to the query explicitly.
  • Suggested fix: Relying on the user to remember PARSE_JSON in a custom query means an upgraded pipeline either fails server-side on every batch (a deterministic error re-driven through JDBC retries) or silently stores an escaped string into VARIANT. I'd add a fail-fast validation or at least a WARN at output-format construction when the row type contains a JSON field and a user-defined query is set, naming the field and suggesting PARSE_JSON, rather than documenting it here only.
  • Severity: Medium

Review conclusion

Conclusion: can merge after the blocking items are fixed

1. Blocking items

  • Issue 1: Snowflake VARIANT, Doris JSON/JSONB, and StarRocks JSON source columns silently change from STRING to the new JSON logical type with no opt-out, breaking existing pipelines on upgrade

2. Remaining follow-ups

  • Issue 2: JSON logical type is physically a plain String everywhere, so nothing prevents non-JSON text from reaching a native JSON sink; validation appears to exist only at the StarRocks load boundary
  • Issue 3: StarRocks sink with native JSON columns and the default CSV Stream Load format only fails at load time; the rejection should be a fail-fast validation at sink initialization
  • Issue 4: Snowflake sink with a user-defined query silently skips PARSE_JSON wrapping for JSON fields, deferring failure to a server-side error mid-run

Thanks for the updates so far. Happy to discuss the remaining points.

@DanielLeens

Copy link
Copy Markdown
Contributor Author

Thanks @SEZ9 for the extra pass. I re-checked each point against the current head's source before responding, since there's no new commit since my last review — this is a focused reply, not a new full review.

Issue 1 (silent STRING->JSON remap, no opt-out) — relates to my own 1.2 finding, but I disagree that a config opt-out is required to merge.

This is the same underlying fact I already flagged in section 1.2 of my last review ("Partially incompatible... a real, if documented, previously-working-pipeline regression") and docs/en/introduction/concepts/incompatible-changes.md (the "Breaking Change: Native semi-structured columns map to the JSON logical type" entry) confirms there is indeed no config toggle, only the CAST(payload AS VARCHAR) migration recipe — so the factual premise is correct. Where I'd push back is on treating this as a High blocker that requires a json.type.mapping opt-out: this exact same dev branch already carries a precedent for unconditional, opt-out-free type remapping documented the same way — see the adjacent "Breaking Change: Mapping of timezone-aware timestamp columns to TIMESTAMP_TZ type" entry in the same file, which changed MySQL/PG/Oracle/SQL Server/Snowflake timestamp mappings unconditionally with only a documented CAST-based migration, no opt-in flag. If that bar was acceptable for merge, requiring a new opt-out flag specifically for this PR isn't consistent with project precedent, and I'd rather not block on it.

I also traced the checkpoint-restart claim specifically, since it's the part of your Issue 1 I hadn't verified before: MultipleTableJobConfigParser.createAndPrepareSource only takes the "reuse checkpointed state" branch (FactoryUtil.restoreAndPrepareSource(..., checkpoint, ...)) when factory instanceof ChangeStreamTableSourceFactory (FactoryUtil.java:139-149) — that interface is CDC/change-stream specific (e.g. MySQL-CDC). None of Doris/StarRocks/Snowflake implement it, so on both a fresh submit and a restore-from-savepoint submit they go through the identical createAndPrepareSource(factory, ...) -> source.getProducedCatalogTables() path (FactoryUtil.java:99-172), which queries live catalog metadata every time, not a schema cached in checkpoint state. So this isn't a distinct checkpoint-corruption risk — a restored job sees exactly the same new JSON schema a freshly-started job would, no more and no less. It's the same already-documented compatibility fact, not a new failure mode.

Issue 2 (no client-side JSON validation before native sinks) — agree for Snowflake, disagree for Doris.

For Snowflake, this is accurate and a genuinely new point I hadn't independently verified: PARSE_JSON(:field) binds go through plain setString (AbstractJdbcRowConverter.java:697-699), so invalid content is only caught server-side, per-batch, which is a real UX gap versus fail-fast client-side validation.

For Doris, though, I checked connector-doris/.../serialize/SeaTunnelRowSerializer.java and the JSON-format branch (LoadConstants.JSON) constructs new JsonSerializationSchema(this.seaTunnelRowType, true) — the same seatunnel-format-json serializer whose RowToJsonConverters.createNotNullConverter case I already verified re-parses and rejects malformed/empty/trailing-token JSON via CommonError.jsonOperationError before the row ever leaves the client (my prior review, section 1.1). So for Doris's JSON Stream Load path specifically, validation does happen client-side, before load — your "fails deep inside the sink, per-batch, opaque" framing doesn't hold for that branch. It does still apply to the Doris CSV branch, but that's the pre-existing gap I already logged as my own Issue 2 (seatunnel-format-text has no case JSON) for a different reason (unsupported type, not invalid content).

Issue 3 (StarRocks CSV+JSON rejected at flush, not at sink init) — +1, this is new and valid.

I only looked at the CSV-rejection E2E test's stability (my Issue 4); I hadn't examined when in the write lifecycle the rejection fires. I checked StarRocksBaseSerializer.convert() and confirmed the case JSON: throw ... is inside the per-value convert() method, called from row serialization during writer flush — not from open()/prepare(). Your restart-loop concern for streaming jobs is well-founded given that. Worth adding as a non-blocking follow-up alongside my existing Issues.

Issue 4 (Snowflake custom query bypasses PARSE_JSON wrapping) — +1, new and valid, but already self-documented, so I'd keep it non-blocking.

Matches my own read of SnowflakeDialect: PARSE_JSON wrapping lives in getInsertIntoStatement/getUpdateStatement, which only apply to SeaTunnel-generated statements, not a user-supplied query. The PR's own doc note at docs/en/connectors/sink/Snowflake.md:53 already discloses this, which is the same documented-limitation pattern I accepted elsewhere in this PR (my Issues 2/3/5) rather than a hard blocker.

Net effect on my Merge Recommendation: unchanged from my last review — the actual blocker is still my Issue 1 (red CI on the Kafka/Doris lanes exercising this PR's own JSON E2E coverage). I don't think Issue 1 here should become an additional hard blocker given the TIMESTAMP_TZ precedent and the checkpoint-restore correction above, but your Issue 2 (Snowflake half only) and Issue 3 are legitimate additions to the non-blocking follow-up list together with my Issues 2/3/5/6/7.

# Conflicts:
#	docs/en/connectors/sink/Snowflake.md
#	docs/en/connectors/source/Snowflake.md
#	docs/zh/connectors/sink/Snowflake.md
#	docs/zh/connectors/source/Snowflake.md
#	seatunnel-e2e/seatunnel-connector-v2-e2e/connector-starrocks-e2e/src/test/java/org/apache/seatunnel/e2e/connector/starrocks/StarRocksIT.java

@DanielLeens DanielLeens left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the substantial follow-up. I re-read the complete current diff and the source-to-format/connector paths. The opt-out, validity contract and early StarRocks validation are now present. Sorry for missing the Snowflake INSERT grammar problem in earlier rounds: Issue 10 below is an older omission that still exists, not a new regression. I also traced the actual current-head unit failure rather than treating the cancelled workflow as generic CI noise.

What this PR solves

  • User pain: native semi-structured values are flattened into ordinary strings, losing the distinction between JSON structure and escaped text.
  • Fix: introduce String-backed JSON logical types and connect them to schema parsing, conversion, formats, transforms and selected native sinks.
  • In one sentence: preserve a value such as {"id":1} as a JSON object where supported, while retaining explicit STRING migration paths.

1. Code Change Review

1.1 Core Logic Analysis

Local branch seatunnel-review-11493 matches 925fb9c1fe0da5b6cd1b0a65b7fbcd036f22a16b. The full 109-file Git diff covers API types, connector mappings, all changed tests/config resources, both language docs, formats and Spark translation. Source searches additionally checked FakeSource fixture decoding, JDBC execution, plugin type fallbacks and error construction. No local build, test, container or job ran.

Before, native VARIANT/JSON values mapped to STRING and JSON serialization escaped them. After, BasicType.JSON_TYPE retains String storage but RowToJsonConverters parses the text with FAIL_ON_TRAILING_TOKENS. SQL NULL removes a top-level reused JSON key; text null remains a JSON NullNode. SqlType.JSON is appended, and BasicType retains serialVersionUID 2.

native source metadata / declared json schema
 -> BasicType.JSON_TYPE, physical String
 -> optional source handle_json_as_string -> metadata-preserving STRING projection
 -> SeaTunnelRow / Copy / Calcite / JsonPath / Spark adapters
 -> JSON format parses native value; CSV/Avro carry text representation
 -> supported native sink mapping / DDL
    StarRocks: init rejects JSON+CSV -> strict JSON serialization -> Stream Load
    Snowflake: schema-aware INSERT/UPDATE -> bind String -> PARSE_JSON on server
    Qdrant: explicit rejection instead of old silent payload omission
checkpoint/schema serialization -> existing stable enum/serializable type identities
 -> old/new inferred schemas still require documented migration decisions

Key findings: normal source/sink paths reach these changes; Doris/JDBC opt-out applies before produced schemas, including JDBC dry run; StarRocks Source uses declared schema, so STRING remains an explicit choice there; JSON parsing is enforced at selected format/sink boundaries, not throughout the type system; generated Snowflake INSERT currently uses an unsupported SQL shape (Issue 10). Constructor/metadata copies preserve query/split settings; the new logical type does not make every existing sink JSON-aware.

1.2 Compatibility Impact

Partially incompatible, explicitly documented in both incompatible-changes guides. Existing native inferred columns can become JSON, while Doris/JDBC handle_json_as_string=true, declared STRING schemas or CAST provide migration routes. Existing enum ordinals and BasicType UID remain. New JSON values are still physical strings in CSV/Avro/Spark, but schema identity and JSON null/key omission differ. This is not proof of an executed historical-checkpoint upgrade. Native JSON support remains connector-specific; text fallback is not native JSON preservation.

1.3 Performance / Side Effects

JSON output now parses/allocates trees per JSON value; CSV/Avro retain String storage. Large/nested payloads increase parsing CPU, temporary allocation and GC; no unbounded buffer or new production thread is introduced. Static ObjectMapper use is configured per reader rather than mutated per row. StarRocks catalog adds a parameterized information_schema query and closes statements/results. JDBC parameter binding stays prepared; generated SQL must still be valid for its backend. No new lock/retry/resource-owner change was found; deterministic validation errors should not be retried as transient writes.

1.4 Error Handling and Logging

Active findings, in impact order:

Issue 10: Generated Snowflake JSON INSERT uses a disallowed VALUES expression.

  • Location: seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/internal/dialect/snowflake/SnowflakeDialect.java:78; SnowflakeTypeConverterTest.java:74; both Snowflake sink docs.
  • Context/problem: the normal schema-aware insert path generates INSERT INTO ... VALUES (:id, PARSE_JSON(:payload)). Snowflake explicitly disallows semi-structured expressions in VALUES and shows this precise PARSE_JSON shape must use INSERT ... SELECT instead. Prepared parameter binding does not move the function out of VALUES. The unit test currently asserts the unsupported SQL rather than executing backend grammar.
  • Risk: the ordinary generated-insert path for a JSON/VARIANT target fails SQL compilation, so a central advertised feature does not work.
  • Best fix: generate INSERT INTO ... SELECT :id, PARSE_JSON(:payload) for JSON-bearing schemas, preserving the existing non-JSON path and binding order; update the unit expectation and user-query examples. Validate against Snowflake in authorized CI. UPDATE expressions are a separate SQL form and need not be changed just to fix INSERT.
  • Severity: High, blocking.
  • Already raised by others: No. Explicit older-round omission acknowledged above. Snowflake INSERT usage notes document the restriction and supported SELECT alternative.

Issue 3: Qdrant's new error construction fails before producing the intended connector error.

  • Location: seatunnel-connectors-v2/connector-qdrant/src/main/java/org/apache/seatunnel/connectors/seatunnel/qdrant/sink/QdrantBatchWriter.java:174; QdrantBatchWriterTest.java:36.
  • Context/problem: the new JSON branch passes parameterized CommonErrorCode.UNSUPPORTED_DATA_TYPE a free-form message without identifier/dataType/field parameters. SeaTunnelRuntimeException formatting throws IllegalArgumentException while constructing QdrantConnectorException. The current-head unit job confirms Param [identifier] is not set and the wrong exception type.
  • Risk: current required unit CI fails and users lose the intended actionable JSON/STRING migration message. Silent dropping is removed, but the replacement rejection is not correctly constructed.
  • Best fix: use an existing appropriate free-form connector error code or correctly supply the structured error parameters; retain the rejection and meaningful type/message assertions. No shared error-framework redesign is required.
  • Severity: Medium, blocking. This is a refinement of existing Issue 3, not a claim the old silent drop remains.
  • Already raised by others: No.

Issue 8: The StarRocks rejection IT still expects the old late-serializer error.

  • Location: seatunnel-e2e/seatunnel-connector-v2-e2e/connector-starrocks-e2e/src/test/java/org/apache/seatunnel/e2e/connector/starrocks/StarRocksIT.java:352.
  • Context/problem: sink construction now correctly rejects JSON+CSV with a message naming the table/columns and starrocks.config.format. The IT still searches for Native JSON columns require JSON Stream Load format, which belongs to the later serializer guard that construction prevents reaching.
  • Risk: the regression test fails when the intended early-validation fix works, and a correct nonzero exit cannot satisfy its stale substring assertion.
  • Best fix: assert the new initialization diagnostic/column and format option, and preserve the failed-exit assertion. Avoid accepting an arbitrary failure or weakening to exit-code-only validation.
  • Severity: Medium, blocking test correction. Related to @SEZ9's F3; the production fail-fast part is now resolved.

Issue 9: Custom-query validation accepts any occurrence of PARSE_JSON.

  • Location: SnowflakeDialect.java:129.
  • Context/problem: a query with two JSON columns passes when only one placeholder is wrapped, or when the token appears only in a comment/string. The method is a token-presence heuristic, not validation of each JSON expression.
  • Risk: the remaining plain bind can still store escaped text or fail on the server; the user must follow the documented per-field requirement.
  • Best fix: either fail closed for unsupported custom JSON SQL, validate supported expression shapes, or clearly describe this as a heuristic and warn with the affected fields. Add a two-JSON-column regression and comment-token case.
  • Severity: Medium, nonblocking hardening because custom-query conversion is now prominently documented and user-owned; the ordinary generated path is blocked separately by Issue 10.
  • Already raised by others: related to @SEZ9's F4. The new init hook/diagnostic addresses that original request; this is the new guard's remaining limitation.

Issue 11: Restore explicit replacement checks for removed length assertions.

  • Location: DorisTypeConvertorV1Test.java:307, DorisTypeConvertorV2Test.java:308, StarRocksTypeConverterTest.java JSON case.
  • Context/problem: existing columnLength checks are removed when expected STRING becomes JSON, without asserting the intended new metadata value. The old MAX_STRING_LENGTH expectation need not remain if the JSON contract changes, but the property should not disappear from coverage.
  • Risk: metadata regressions become invisible to these tests.
  • Best fix: assert the intended new JSON length metadata explicitly, and retain a legacy STRING-mapping check.
  • Severity: Low, test-coverage delivery item; it was already raised in earlier Daniel rounds and is carried forward rather than presented as a new regression.
  • Already raised by others: No independent duplicate; earlier Daniel assertion-policy finding.

2. Code Quality Assessment

2.1 Coding Standards

The new logical value, compatibility helper and important validation methods explain their contracts. Prepared metadata queries avoid interpolation. Qdrant's exception-code misuse is the concrete style/API-contract error to fix, rather than cosmetic naming changes. The typed Mockito TableSchema matchers resolve the earlier overload compilation ambiguity.

2.2 Test Coverage and Test Stability

Stability rating: At risk, primarily the database normalization assumptions in DorisIT.assertJsonColumnsRoundTrip and engine-log-dependent rejection assertion at StarRocksIT.java:352. Issue 3 is an actual current deterministic failure, and Issue 8 is a deterministic expectation mismatch, not a scheduling flake.

UTs cover schema/array parsing, Arrow, null/key reuse, strict invalid/trailing-token rejection, CSV/Avro, Copy/Calcite/JsonPath, generated SQL text and compatibility metadata. Existing connector/transform ITs are extended. FakeSource fixture decoding supports both named-object and positional-array rows through JsonToRowConverters, so the positional fixtures are not themselves an error. LocalFile fixtures now reset writable paths and keep row-count/data assertions. This improves the earlier zero-row scenario but is not a substitute for a passing current-head run.

Earlier validation gates Issue 1 (LocalFile round trip) and Issue 2 (Doris scalar/null normalization) remain unclosed: the current workflow did not establish successful execution of those assertions. I do not claim the historical failures reproduced on this head. In particular, the existing Doris test still requires observing JSON null separately from SQL NULL and comparing scalar values; current backend evidence is needed before clearing it. Do not weaken these assertions to match a lossy conversion.

The exact-head unit-test JDK 11 job failed only the new QdrantBatchWriterTest: one test, one failure, missing identifier parameter. The downloaded log contains that cause and Maven's connector-qdrant failure. Subsequent cancelled lanes are not passing E2E evidence. This failure is PR-owned and should be fixed directly.

2.3 Documentation Updates

English/Chinese schema, source/sink and migration updates agree on physical representation, boundary validation, opt-out and unsupported sink behavior. +1 to @SEZ9's F1/F2 direction: the escape hatch and documented validity contract now exist. StarRocks F3 now fails at construction. Snowflake examples must use the backend-valid SELECT shape (Issue 10), and its custom-query guard should not be described as full SQL analysis.

The docs now disclose Databend's warned STRING fallback and Easysearch's string mapping. Databend actually logs that fallback in the current source, so earlier Issue 4's silent-fallback wording is obsolete. Easysearch's fallback remains the existing nonblocking Issue 5; unsupported-sink use should retain the documented STRING migration.

3. Architectural Soundness

3.1 Elegance

A useful logical-type layer with limited native connector mappings. It avoids changing the physical row representation, but every backend write expression still needs its own semantic validation.

3.2 Maintainability

The shared legacy projection preserves table metadata and JDBC split/query settings. Keep compatibility and syntax tests focused on real contracts; asserting a generated SQL string cannot establish that the backend accepts it.

3.3 Extensibility

More sinks can add explicit JSON mappings. Arbitrary fallthrough to STRING is not native JSON support; the support matrix and opt-out remain necessary.

3.4 Historical-Version Compatibility

Old enum ordinals and explicit type UID remain. Inferred schema changes and native JSON output semantics are intentionally incompatible and documented; no cross-version job restore was run.

4. Issue Summary

No. Active issue / gate Location Severity
10 Generated Snowflake INSERT uses unsupported VALUES/PARSE_JSON SnowflakeDialect.java:78 High, blocking
1 Current-head LocalFile round trip not established LocalFileIT.java:383,435 Validation gate
2 Current-head Doris scalar/null round trip not established DorisIT.java:367 Validation gate
3 Malformed structured Qdrant exception; current unit failure QdrantBatchWriter.java:174 Medium, blocking
8 StarRocks rejection IT expects obsolete message StarRocksIT.java:352 Medium, blocking
9 Custom SQL token check does not validate each JSON bind SnowflakeDialect.java:129 Medium, nonblocking
5 Easysearch string fallback EasysearchDataTypeConvertor.java:113 Medium, nonblocking; documented
11 Dropped length assertions lack replacement DorisTypeConvertorV1Test.java:307 Low, coverage delivery item

Numbering preserves the latest Daniel full-review series, with Issue 10 explicitly acknowledged as an older omission and Issue 11 carrying the earlier assertion finding. Earlier Issue 6/F1 and Issue 7/F2 are addressed; production F3 is addressed; F4 has an init hook/documented manual policy with Issue 9's heuristic limitation. I agree with @SEZ9's compatibility/robustness direction while explicitly recognizing these repairs, rather than carrying all historical objections forward unchanged.

5. Merge Recommendation

Conclusion: Ready to merge after fixes

  1. Blockers: Issue 10, then the PR-owned Qdrant failure (Issue 3), the stale StarRocks test assertion (Issue 8), restored metadata coverage (Issue 11), and successful current-head execution for Issues 1/2. GitHub also reports actual merge conflicts against dev; those must be resolved independently before final CI/maintainer approval.
  2. Suggested improvements, nonblocking: Issue 9's per-bind/custom-query protection and Issue 5's explicit unsupported-mapping signal. Nested JSON SQL-null versus JSON-null preservation remains an existing limitation; the top-level distinction is covered and should not be generalized to every array/map path without tests.

Current CI is Build 41163130794, completed/cancelled after the concrete Qdrant unit failure above. This updates the previous generic engine/dead-link diagnosis: that older failure is not the cause observed now. Fix this branch's error construction; do not chase it with unrelated dependency changes or a blind retry. Resolve the actual merge conflicts with the latest dev, then validate the corrected head. Behind/diverged is recorded separately from that conflict requirement.

Overall, the type plumbing and compatibility repairs are worthwhile, but the generated Snowflake write path and current test failures prevent clearance. The smaller alternative is backend-valid INSERT ... SELECT plus focused error/test fixes, retaining the existing representation. Daniel has READ permission, cannot approve his own PR, and cannot dismiss historical/independent reviews; final effective approval belongs to a write-capable maintainer.

Snapshot 2026-11-01T14:34:20.317071+00:00: head 925fb9c1fe0da5b6cd1b0a65b7fbcd036f22a16b, base dev; compare diverged, ahead 16 / behind 9; merge dirty / DIRTY, review decision REVIEW_REQUIRED. Drift is recorded separately; it does not itself request synchronization.

@SEZ9

SEZ9 commented Nov 2, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the follow-up on 925fb9c1fe0da5b6cd1b0a65b7fbcd036f22a16b. Checking the earlier points against the current diff:

  • F1 (STRING -> JSON change on upgrade) – The source-level handle_json_as_string option providing a metadata-preserving STRING projection covers the opt-out. Could you confirm it is documented on each affected source connector page (Snowflake, Doris, StarRocks), not only in the incompatible-changes page, so users hitting this on upgrade can find it where they look first?

  • F2 (JSON logical type is a plain String) – Strict parsing with FAIL_ON_TRAILING_TOKENS in RowToJsonConverters gives the validity contract at the format boundary. It would help transform authors if the schema docs state explicitly that validation happens there rather than at construction.

  • F3 (StarRocks JSON + default CSV Stream Load) – The init-time rejection of JSON columns with the CSV format addresses this. Please make sure the StarRocks sink doc points users to the JSON load format for native JSON columns.

  • F4 (Snowflake user-defined query skips PARSE_JSON) – This looks like the remaining open item, and the Snowflake INSERT grammar omission has been noted as still present. Could you clarify how a user-supplied query targeting JSON-typed fields is handled now: is PARSE_JSON applied, is there a clear early error, or is this documented as a requirement on the user?

Happy to take another look once F4 is clarified.

@DanielLeens

Copy link
Copy Markdown
Contributor Author

@SEZ9 thanks. I checked each point against 925fb9c1fe0da5b6cd1b0a65b7fbcd036f22a16b. F1 to F3 are documented where you asked; F4 is where I need to be honest about a bigger problem.

  • F1 (opt-out on each affected source page). handle_json_as_string is documented with the new type mapping in docs/en and docs/zh for the Doris source, the Jdbc source (only Snowflake VARIANT is mapped to JSON; other dialects are unaffected), and the Snowflake source, in addition to the incompatible-changes page. The StarRocks source has no inferred mapping to opt out of because it always uses the declared schema; its page says to declare the column as string to keep the old behavior.
  • F2 (validity contract). schema-feature.md (en and zh) now has a note under the json row: the type guarantees the representation only, and validity is enforced at the parsing boundaries (JSON format, StarRocks JSON Stream Load, Snowflake PARSE_JSON on the server). Every other sink passes the text through.
  • F3 (StarRocks JSON with default CSV). The StarRocks sink page in both languages says native JSON columns need starrocks.config.format = "JSON", and that the sink rejects JSON columns with CSV at creation time.
  • F4 (Snowflake user-defined query). Current behavior: with JSON fields in the schema, a custom query is rejected at sink creation unless it contains PARSE_JSON (a case-insensitive text check), and the docs tell the user to wrap each JSON placeholder. That check is weak: it does not verify that every JSON bind is wrapped (Issue 9 in my last review, non-blocking).

More important, and a miss from earlier rounds that I only caught in my last review: Snowflake does not allow PARSE_JSON(...) inside a VALUES clause. The generated insert (SnowflakeDialect.java, VALUES (:id, PARSE_JSON(:payload))), the unit test that asserts that string, and the docs example INSERT ... VALUES (?, PARSE_JSON(?)) all use the unsupported shape. The form should be INSERT INTO ... SELECT :id, PARSE_JSON(:payload), so the generated SQL, the docs example, and the test expectation all need to change. That has not been done on this head.

Still open from the same review, also needing code: the Qdrant error construction fails with a unit failure (Issue 3), the StarRocks rejection IT still expects the old late-serializer message (Issue 8), and replacement checks for the dropped Doris length assertions (Issue 11). The branch is also currently DIRTY against dev, so a sync is needed along with these fixes. So this PR is not ready; I will address these in the next push and not claim a CI result until a run completes on that head.

# Conflicts:
#	docs/en/introduction/concepts/incompatible-changes.md
#	docs/zh/introduction/concepts/incompatible-changes.md
…eview findings

- Snowflake: generate INSERT INTO ... SELECT when the schema has JSON fields,
  because Snowflake rejects PARSE_JSON inside a VALUES clause; schemas without
  JSON fields keep INSERT ... VALUES. Docs examples updated accordingly.
- Qdrant: use the free-form UNSUPPORTED_DATA_TYPE code for the JSON payload
  rejection; the structured code threw IllegalArgumentException for missing
  parameters before the connector error was built.
- StarRocks IT: assert the sink-creation diagnostic for JSON with CSV Stream
  Load instead of the serializer message that is no longer reached.
- Doris/StarRocks: keep the former STRING length metadata on JSON columns so
  the handle_json_as_string projection restores the previous column, and
  restore the column length assertions.
@DanielLeens

Copy link
Copy Markdown
Contributor Author

Pushed the follow-up promised in my last comment. New head: ff53cb15bf52a9f44d7e3c9b6ae0bc35292b12c9 (merge of dev @ 3244c9504c7 plus one fix commit).

Dev sync. The only conflicts were in incompatible-changes.md (en/zh): #13065 split the page into per-release sections and moved the Engine REST metrics entry under 2.3.13. I dropped this branch's stale copy of that entry and moved the JSON logical type entry into the ## dev section, since it is not released yet. GitHub now reports the PR as mergeable.

Fixes in ff53cb15bf5:

  • Snowflake INSERT grammar (F4 / Issue 10). SnowflakeDialect#getInsertIntoStatement now generates INSERT INTO t (id, payload) SELECT :id, PARSE_JSON(:payload) when the schema has a JSON field. Schemas without JSON fields still go through the standard INSERT ... VALUES path unchanged, and the bind order is the same in both forms. The unit expectation is updated, a no-JSON test pins the unchanged VALUES form, and both Snowflake sink docs now show the SELECT form for user-defined queries. They also say plainly that the custom-query check only looks for PARSE_JSON somewhere in the query (Issue 9 is still a non-blocking limitation). UPDATE ... SET payload = PARSE_JSON(:payload) is valid Snowflake syntax, so it is unchanged.
  • Qdrant error construction (Issue 3). The structured CommonErrorCode.UNSUPPORTED_DATA_TYPE needs identifier/dataType/field parameters, so building the exception threw IllegalArgumentException. It now uses the free-form CommonErrorCodeDeprecated.UNSUPPORTED_DATA_TYPE, which keeps the migration message. The test now asserts the error code, the message, and the handle_json_as_string hint.
  • StarRocks rejection IT (Issue 8). testNativeJsonRejectsCsvStreamLoad still requires a non-zero exit. It now asserts the sink-creation diagnostic (StarRocks sink table test.json_csv_rejected has native JSON column(s) [payload]) and the starrocks.config.format = "JSON" hint, instead of the serializer message that is no longer reached.
  • Length metadata (Issue 11). The Doris JSON/JSONB and StarRocks JSON mappings dropped the MAX_STRING_LENGTH column length that the old STRING mapping exposed. That meant handle_json_as_string did not restore exactly the previous column. Those mappings now keep the length, and the original getColumnLength() assertions are back unchanged in DorisTypeConvertorV1Test (json and jsonb), DorisTypeConvertorV2Test and StarRocksTypeConverterTest.

Local checks were limited to spotless on the touched modules. Fork Build 41568670242 is queued on the new head. I am not claiming any CI result, including the LocalFile/Doris round-trip gates (Issues 1/2), until it finishes.

@SEZ9

SEZ9 commented Nov 3, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the follow-up in ff53cb15bf5 and for syncing with dev @ 3244c9504c7.

F1 (silent STRING → JSON change / opt-out). Keeping MAX_STRING_LENGTH on the Doris JSON/JSONB and StarRocks JSON mappings sounds like the right direction so that handle_json_as_string restores exactly the previous column, and moving the entry into the ## dev section of incompatible-changes.md (en/zh) makes sense since it is unreleased. I still need to verify this against the diff rather than the description. Two asks: (1) your comment appears to be cut off at the end — could you confirm which StarRocks test got its getColumnLength() assertions back? (2) Could you confirm that the Snowflake VARIANT mapping is covered by the same handle_json_as_string opt-out, and that the ## dev entry documents the opt-out for all three connectors?

F3 (StarRocks fail-fast for native JSON + CSV). Re-pointing testNativeJsonRejectsCsvStreamLoad at the sink-creation diagnostic is the shape I was hoping for, but the IT assertion alone does not show where the check lives. Could you point me to the validation code in the diff that runs at sink initialization (and the test that exercises it directly, if there is one) so I can confirm the rejection happens before any load is attempted?

F4 (Snowflake user-defined query / PARSE_JSON). Generating INSERT INTO t (id, payload) SELECT :id, PARSE_JSON(:payload) only when the schema has a JSON field, with a no-JSON test pinning the unchanged VALUES form and identical bind order, sounds like it addresses the core concern; I will confirm against the diff. Leaving UPDATE ... SET payload = PARSE_JSON(:payload) unchanged is fine. I'm okay treating the "custom query is only checked for PARSE_JSON somewhere in the query" limitation as non-blocking as long as the docs state it plainly — could you point me at the exact wording in the Snowflake sink docs so I can confirm it reads as a limitation rather than a guarantee?

F2 (no validation of JSON text before native sinks). I don't see anything in this update that speaks to F2. Could you either describe where non-JSON text is caught before it reaches Doris/Snowflake native JSON columns, or state explicitly that the sink-side database error is the intended behavior and document that? Either is acceptable, but it should be deliberate and written down.

Once the F1 confirmations, the F3 pointer, the F4 doc wording, and an F2 answer are in, I'm happy to do a final pass.

@DanielLeens DanielLeens left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Self-review of head ff53cb15bf52a9f44d7e3c9b6ae0bc35292b12c9 (dev merge 792ba76575 + fix commit ff53cb15bf), following my 2026-11-01 review of 925fb9c1fe.

I have to start with an apology: while re-checking this head I found two gaps that my previous self-review should have kept on the list. Issue 12 (the text format / Doris CSV path) was raised in several earlier rounds and was dropped from the 11-01 summary even though the code and docs were never changed; Issue 13 (generic JDBC auto-create DDL for JSON) is an older omission I never flagged at all. Neither is a regression introduced by ff53cb15bf; both are carryovers and are listed below in full so nothing has to be discovered in another round.

What Problem Does This PR Solve?

  • User pain: native semi-structured values (Snowflake VARIANT, Doris JSON/JSONB, StarRocks JSON) are flattened to STRING, so JSON outputs escape them as text and native JSON destinations receive quoted strings.
  • Fix: a String-backed SqlType.JSON / BasicType.JSON_TYPE logical type threaded through schema parsing, formats, transforms, Spark translation and selected native sinks, with a handle_json_as_string source opt-out.
  • One sentence: {"id":1} stays a JSON object end to end where supported, with an explicit path back to the old STRING behavior.

1. Code Change Review

1.1 Core Logic Analysis

What ff53cb15bf changes, verified against the source at this head:

  • Snowflake generated insert (SnowflakeDialect.java:66-87): when any field is JSON, it now emits INSERT INTO t (id, payload) SELECT :id, PARSE_JSON(:payload); schemas without JSON fields delegate to the unchanged getInsertIntoStatement(database, tableName, fieldNames) VALUES form. Bind order is identical in both forms. All three insert call sites in JdbcOutputFormatBuilder.java:132,266,286,318 go through the TableSchema overload, so the plain-insert path and the insert-or-update fallback both get the fixed shape. UPDATE ... SET payload = PARSE_JSON(:payload) is unchanged and valid.
  • Qdrant (QdrantBatchWriter.java:172-182): switched to the free-form CommonErrorCodeDeprecated.UNSUPPORTED_DATA_TYPE with the existing (SeaTunnelErrorCode, String) constructor (QdrantConnectorException.java:24), so the exception is now actually constructed. The test asserts the error code and both message fragments.
  • StarRocks IT (StarRocksIT.java:352-363): asserts the sink-construction diagnostic. I checked the string against StarRocksSink.java:160-168: with database = "test", table = "json_csv_rejected" from starrocks-json-csv-streamload-rejected.conf:44-45, the formatted message is exactly StarRocks sink table test.json_csv_rejected has native JSON column(s) [payload] and it contains `starrocks.config.format = "JSON"`. The non-zero exit assertion is kept.
  • Length metadata (AbstractDorisTypeConverter.java:200-206, StarRocksTypeConverter.java:160-165): JSON columns keep MAX_STRING_LENGTH, so LegacyJsonTypeUtil.mapJsonColumnsToString (column.copy(STRING_TYPE)) reproduces the old column exactly. Reconvert for JSON ignores length (StarRocksTypeConverter.java:316-319, AbstractDorisTypeConverter.java:427-430), so auto-created DDL is unaffected. Snowflake VARIANT already kept typeDefine.getLength().
native metadata (Doris JSON/JSONB, StarRocks JSON, Snowflake VARIANT)
 -> TypeConverter.convert -> BasicType.JSON_TYPE (+ legacy columnLength)
 -> [source handle_json_as_string=true] LegacyJsonTypeUtil -> STRING (identical to before)
 -> SeaTunnelRow (physical String)
 -> sink:
    Snowflake  JdbcOutputFormatBuilder -> SnowflakeDialect INSERT ... SELECT PARSE_JSON(:f)
    StarRocks  StarRocksSink ctor rejects JSON+CSV -> JSON Stream Load (strict parse)
    Doris      SeaTunnelRowSerializer: format=json -> JsonSerializationSchema (strict parse)
               format=csv  -> TextSerializationSchema -> no JSON case -> throws (Issue 12)
    MySQL/PG/other JDBC with auto-create -> reconvert default -> throws (Issue 13)
    Qdrant     explicit rejection

1.2 Compatibility Impact

Partially incompatible, intentionally, and documented in docs/{en,zh}/introduction/concepts/incompatible-changes.md:8-15 (now correctly under ## dev). SqlType.JSON is tail-appended and BasicType keeps its serialVersionUID, so checkpoint/savepoint state written before upgrade is unaffected; state containing JSON cannot be read by an older release (rollback only). The opt-out now restores the exact previous column including length. The two remaining compatibility gaps are documentation accuracy plus one first-party write path (Issues 12 and 13).

1.3 Performance / Side Effects

No change to the earlier assessment for JSON formats (one parse per JSON value). One new point for the Snowflake fix: INSERT ... SELECT with bind parameters may not use the Snowflake JDBC driver's array-binding fast path that INSERT ... VALUES batches use, which could turn a batch into per-row execution. I have not verified this against the driver; it only affects schemas with JSON fields, and it needs a real Snowflake run (the Snowflake IT is still class-level disabled), so I list it as a validation note rather than a defect.

1.4 Error Handling and Logging

Status of the 11-01 issues at this head:

No. Item Status at ff53cb15bf
10 Snowflake PARSE_JSON inside VALUES Fixed in code (SnowflakeDialect.java:84-86); backend execution still unverified because no Snowflake IT runs
3 Qdrant exception construction failed Fixed (QdrantBatchWriter.java:178); waiting for the unit-test lane
8 StarRocks IT expected obsolete message Fixed (StarRocksIT.java:357-362)
11 Dropped length assertions Fixed: original getColumnLength() assertions restored in DorisTypeConvertorV1Test.java:308,320, DorisTypeConvertorV2Test.java:309, StarRocksTypeConverterTest.java:343, with the production mapping changed to match
9 Custom-query check only looks for PARSE_JSON anywhere Still open, non-blocking; now stated plainly as a limitation in docs/{en,zh}/connectors/sink/Snowflake.md:56
5 Easysearch string fallback Open, non-blocking, documented
1 / 2 LocalFile and Doris round-trip E2E on current head Validation gates; fork Build is still queued

Open issues:

Issue 12 (carryover, dropped from my 11-01 summary): the text format still has no JSON case, so Doris CSV Stream Load and file sinks on the text format fail at the first row

  • Location: seatunnel-formats/seatunnel-format-text/src/main/java/org/apache/seatunnel/format/text/TextSerializationSchema.java:213,271; reached from seatunnel-connectors-v2/connector-doris/src/main/java/org/apache/seatunnel/connectors/doris/serialize/SeaTunnelRowSerializer.java:113-122; docs docs/en/connectors/sink/Doris.md:183,193 and docs/zh/connectors/sink/Doris.md:192; incompatible-changes.md:13.
  • Problem: SeaTunnelRowSerializer uses TextSerializationSchema for every non-JSON Doris format, and its switch has case STRING but no case JSON, so it falls into default and throws SeaTunnel format text not supported for parsing this type [JSON]. A Doris-to-Doris (or Doris-to-file text) pipeline that worked before upgrade fails at runtime, after the job has started, with an error that mentions neither Doris, the format option, nor handle_json_as_string. The docs make this worse: the incompatible-changes entry lists Doris among the components that "support the new logical type", and the Doris sink page says "The supported formats include CSV and JSON" without the caveat StarRocks now has.
  • Risk: a silent-looking upgrade break on a first-party, previously zero-config path, discovered only at the first flush.
  • Best improvement: add case JSON: next to case STRING: in TextSerializationSchema (and the matching deserializer), which is a pure pass-through since the value is already a String; or, if text is intentionally out of scope, mirror the StarRocks fail-fast check in the Doris sink constructor and add the caveat to both Doris sink pages and the incompatible-changes entry. The first option is smaller and also fixes file sinks.
  • Severity: Medium, should be fixed before merge.
  • Raised by another reviewer: related to @SEZ9's F1 blast-radius point; raised by me in several earlier rounds.

Issue 13 (older omission, not raised before): generic JDBC sinks cannot auto-create a table for a JSON column

  • Location: seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/internal/dialect/mysql/MySqlTypeConverter.java:402,635-639; .../dialect/psql/PostgresTypeConverter.java:326,545-549 (same pattern in other dialects); incompatible-changes.md:13.
  • Problem: reconvert has no JSON case in MySQL or PostgreSQL, so schema_save_mode paths that create the target table throw convertToConnectorTypeError(..., "JSON", column). Before this PR the same Doris/StarRocks/Snowflake column arrived as STRING with MAX_STRING_LENGTH and became LONGTEXT / TEXT. Writing into an existing table still works (AbstractJdbcRowConverter.java:274-276 binds setString), so only auto-create is affected. The incompatible-changes entry says a sink without JSON support "can receive an unsupported-type error", but then enumerates only Qdrant, Databend and Easysearch, which reads as if the common JDBC sinks are fine.
  • Risk: Doris/StarRocks/Snowflake to MySQL/PostgreSQL with auto table creation is a very common pipeline and fails at submission after upgrade.
  • Best improvement: minimal: name the generic JDBC sinks' auto-create behavior explicitly in both incompatible-changes pages and point to handle_json_as_string / CAST. Better (can be a follow-up): map JSON to the native JSON type in MySQL and jsonb in PostgreSQL reconvert.
  • Severity: Medium; the documentation part should be fixed before merge, the native mapping is optional.
  • Raised by another reviewer: No.

2. Code Quality Assessment

2.1 Coding Standards

The new comments in SnowflakeDialect, QdrantBatchWriter and both type converters explain why (Snowflake grammar restriction, missing structured-error parameters, exact opt-out restoration), which is the right level. isJsonField is a self-explanatory private helper. No unused import is left behind (Code style lane passed).

2.2 Test Coverage and Test Stability

Stability rating: Risk present.

  • SnowflakeTypeConverterTest.java:74-107: the new testInsertWithoutJsonKeepsValuesClause pins the unchanged non-JSON path, which is a real regression guard. Both Snowflake tests still only compare SQL text, so backend acceptance of the SELECT form remains unproven until a Snowflake run exists.
  • QdrantBatchWriterTest.java:36-50: now asserts the error code and the migration hint, so it fails if the exception regresses to the structured code again.
  • StarRocksSinkTest.java:66,81 exercise the constructor check directly; StarRocksIT.java:352-363 covers it end to end. The IT still reads the diagnostic from stderr + serverLogs, which is engine-log dependent but deterministic for the same message.
  • DorisIT.java:371-382 (assertJsonColumnsRoundTrip, separate JSON-null vs SQL-NULL observation) and the LocalFile JSON round trip remain unproven on any recent head; I am not weakening them, but they must pass on this head before Issues 1/2 close.
  • No test covers Issue 12 or Issue 13 yet; whichever fix is chosen should add one focused case (a text-format JSON pass-through assertion, or a reconvert/doc check).

2.3 Documentation Updates

docs/en and docs/zh are in lockstep for every file touched in this commit. For @SEZ9's open questions on the last update, so the answers are in one place:

  • F1: handle_json_as_string covers Snowflake VARIANT through the Jdbc source (docs/en/connectors/source/Snowflake.md:76, plus Jdbc and Doris source pages); the ## dev entry documents the opt-out for Doris, Jdbc/Snowflake and the declared-schema route for StarRocks (incompatible-changes.md:14, zh :13). The StarRocks length assertion is back in StarRocksTypeConverterTest.java:343.
  • F3: the check lives in the sink constructor, StarRocksSink.java:71 calling validateJsonColumnsAgainstLoadFormat at :147-169, tested directly by StarRocksSinkTest.java:66.
  • F4: the limitation wording is in docs/en/connectors/sink/Snowflake.md:56 ("The check only looks for PARSE_JSON anywhere in the query; it does not verify that every JSON placeholder is wrapped").
  • F2: the contract is stated in docs/en/introduction/concepts/schema-feature.md:161 (zh same line): the type guarantees representation, not validity, and validity is enforced where the text is parsed. One small correction worth making there: the Doris JSON Stream Load path also parses through JsonSerializationSchema, so it should be listed alongside StarRocks; and the Doris CSV path should not be implied to work (Issue 12).

3. Architectural Soundness

The String-backed logical type with per-connector native mappings remains the right shape: no physical row change, no engine serialization change, and explicit opt-in per connector. The cost of that design is that every generic consumer (text format, JDBC DDL) needs its own explicit decision; Issues 12 and 13 are the two widely used consumers where that decision has not been made or documented. The opt-out and exact length restoration make the incompatible change safe to adopt as long as the documented blast radius matches reality.

4. Issue Summary

No. Issue Location Severity
12 Text format has no JSON case; Doris CSV / file text sinks fail at runtime; docs claim Doris support without caveat TextSerializationSchema.java:213,271; Doris.md:193 Medium, fix before merge
13 MySQL/PostgreSQL (generic JDBC) auto-create throws for JSON; not named in incompatible-changes MySqlTypeConverter.java:635; PostgresTypeConverter.java:545; incompatible-changes.md:13 Medium, docs before merge
1 LocalFile JSON round trip on current head LocalFileIT.java Validation gate (CI)
2 Doris scalar/null round trip on current head DorisIT.java:371 Validation gate (CI)
9 Custom-query PARSE_JSON presence check SnowflakeDialect.java:140 Medium, non-blocking, documented
5 Easysearch string fallback EasysearchDataTypeConvertor.java Medium, non-blocking, documented
- Snowflake INSERT ... SELECT batching behavior unverified SnowflakeDialect.java:84 Validation note
10, 3, 8, 11 Previously blocking see table in 1.4 Fixed at this head

5. Merge Recommendation

Conclusion: Ready to merge after fixes

  1. Blockers (non-CI): Issue 12 (text-format JSON pass-through or Doris fail-fast, plus Doris sink doc caveat) and the documentation part of Issue 13.
  2. CI gates: fork Build 41568670242 on this head has passed only the light checks (changes, code style, license header, dead links, helm, sanity); 79 unit/E2E jobs are still queued, so the Qdrant unit fix and Issues 1/2 are not yet proven. GitHub reports MERGEABLE (no conflicts), 3 commits behind dev, review decision REVIEW_REQUIRED.
  3. Non-blocking: Issue 9, Issue 5, the Snowflake batching note, and the native MySQL JSON / PostgreSQL jsonb mapping for Issue 13.

The four blockers from 11-01 are genuinely fixed in this commit and the opt-out now restores the exact legacy column, which is good progress. As the author I cannot approve this PR; final approval belongs to a committer after the remaining items and a green run on the final head.

@SEZ9

SEZ9 commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator

Re-checked the four points from my earlier review against head ff53cb15bf52a9f44d7e3c9b6ae0bc35292b12c9 (792ba76575 + ff53cb15bf), based on the self-review posted for this head:

PR11493-F1 (STRING → JSON source change with no opt-out) — The self-review describes a handle_json_as_string source option as the explicit path back to the old STRING behavior, which is the shape I was asking for. Remaining asks: (a) confirm the option is honoured by all three affected sources (Snowflake VARIANT, Doris JSON/JSONB, StarRocks JSON), and (b) make sure docs/en/introduction/concepts/incompatible-changes.md spells out the default change and names the option so users hitting this on upgrade know how to restore the previous behavior.

PR11493-F2 (JSON logical type is physically a plain String, no validation outside the StarRocks load boundary) — I don't see anything in this round touching that. Please state whether you intend to add validation at the JSON type boundary (or at the native-JSON sinks), or whether the documented position in docs/en/introduction/concepts/schema-feature.md is that JSON is a semantic tag only and malformed text fails at the destination. Either is acceptable to me if it is written down.

PR11493-F3 (StarRocks native JSON + default CSV Stream Load format only failing at load time) — The note that StarRocksIT.java:352-363 now asserts a sink-construction diagnostic suggests this moved to fail-fast, which is what I asked for. The asserted message itself wasn't included, so please paste the exact diagnostic and confirm docs/en/connectors/sink/StarRocks.md tells users to switch the load format when the target table has JSON columns.

PR11493-F4 (Snowflake user-defined query skipping PARSE_JSON) — The description of the generated-insert path in SnowflakeDialect.java:66-87 emitting INSERT INTO t (id, payload) SELECT :id, PARSE_JSON(:payload) for schemas with JSON fields, with the insert call sites in JdbcOutputFormatBuilder.java going through the TableSchema overload, suggests the generated-SQL side is covered; I'll confirm that against the diff. My original point was about the user-supplied query path, which is not mentioned. Please confirm what happens there: either validate/warn at sink initialization when JSON fields are present with a custom query, or document in docs/en/connectors/sink/Snowflake.md that the user is responsible for wrapping JSON binds in PARSE_JSON.

Once F2 and F4 are answered and the F1/F3 doc confirmations are in, I'm fine with this from my side.

@DanielLeens

Copy link
Copy Markdown
Contributor Author

Thanks @SEZ9. Here are the confirmations against ff53cb15bf5. All four of your points are covered on this head. I also list below what I still owe from my own review of this head, because it overlaps with your F1/F2.

F1, opt-out coverage and docs.

  • Doris JSON/JSONB: handle_json_as_string is applied in DorisSourceFactory.java:113-117 via LegacyJsonTypeUtil.mapJsonColumnsToString.
  • Snowflake VARIANT: the option is applied by the Jdbc source in JdbcSource.java:72-82.
  • StarRocks: the StarRocks source has no inferred schema. StarRocksSourceTableConfig.java:58 builds it only from the user-declared schema, so declaring the column as string keeps the old behavior. The mapping change there affects only StarRocksCatalog and automatic table creation.
  • docs/en/introduction/concepts/incompatible-changes.md:10-15 (zh mirrored) states the default change, names the option for Doris and the Jdbc/Snowflake source, and explains the StarRocks case.

F2, validation contract. The documented position is in docs/en/introduction/concepts/schema-feature.md:161 (zh same line). json is String-backed, and the type guarantees the representation, not the validity of the text. Validity is enforced where the text is parsed: the JSON format, the StarRocks JSON Stream Load serializer, and Snowflake PARSE_JSON. I'm not adding validation at the type boundary. One correction to that sentence is owed (see the list below).

F3, StarRocks CSV fail-fast. The StarRocksSink constructor (StarRocksSink.java:71) calls validateJsonColumnsAgainstLoadFormat (:147-169). The exact message is:

StarRocks sink table %s.%s has native JSON column(s) %s, but the Stream Load format is CSV, which does not support JSON-formatted columns. Set starrocks.config.format = "JSON"for this sink, or convert the field(s) to STRING upstream (for exampleCAST(field AS VARCHAR) in a Calcite Transform).

StarRocksIT.java:351-363 asserts both StarRocks sink table test.json_csv_rejected has native JSON column(s) [payload] and starrocks.config.format = "JSON". The docs tell users to switch the format: docs/en/connectors/sink/StarRocks.md:243, and docs/zh/connectors/sink/StarRocks.md:238.

F4, Snowflake user-defined query. This path fails at sink initialization rather than relying on docs alone. JdbcSink.java:114 calls dialect.validateUserDefinedQuery, and SnowflakeDialect.java:125-151 rejects a custom query that has JSON fields but no PARSE_JSON, naming the fields. It is tested by SnowflakeDialectTest#userDefinedQueryWithoutParseJsonIsRejectedForJsonFields and #userDefinedQueryWithParseJsonOrWithoutJsonFieldsIsAccepted. docs/en/connectors/sink/Snowflake.md:56 documents that the user wraps placeholders with PARSE_JSON(?). It also documents the limitation that the check only looks for PARSE_JSON somewhere in the query, not at every placeholder.

Still owed in a follow-up commit (from my self-review of this head; these overlap with your F1 blast-radius point and F2):

  1. Issue 12: add a JSON case next to STRING in TextSerializationSchema (:213, plus the nested case at :239) and in TextDeserializationSchema (:288). It is a pass-through, because the value is already a String. This fixes Doris CSV Stream Load and text-format file sinks, which today fail at the first row with not supported for parsing this type [JSON]. I'll add one text-format JSON round-trip test.
  2. Issue 13 (docs): in both incompatible-changes.md pages, state that generic JDBC sinks (MySQL, PostgreSQL and others) cannot auto-create a table for a JSON column, and point users to handle_json_as_string or a CAST.
  3. F2 doc correction in schema-feature.md:161 (en and zh): list the Doris JSON Stream Load path as a parsing boundary next to StarRocks, and don't imply that the Doris CSV path validates JSON.

@DanielLeens

Copy link
Copy Markdown
Contributor Author

The earlier queued-CI status has changed: Build 41568670242 completed/cancelled after LocalFile JDK 17, Doris JDK 11/17 and JDBC part 7 JDK 17 failures. DorisIT reports a JSON assertion at line 399 (expected true, got 1) and checksum discrepancies; these are relevant to the JSON behavior under review and must be reconciled with the intended typed/raw-JSON contract, not dismissed as infrastructure or fixed by loosening assertions. LocalFile failures also need their scenario results checked against that contract. The separate MetalakeIT.startUp:158 readiness timeout precedes the JDBC job and its fixture is unchanged in latest dev; retry that lane separately. The existing JSON text-path and bilingual migration-documentation blockers remain. No blanket sync cure is established for this mixture of failures.

CI reference: Build 41568670242.

This updates CI/merge facts on the already-reviewed head; it is not another full source review. No local runtime testing was performed. Daniel has READ permission; effective maintainer approval/dismissal remains separate.

@davidzollo

Copy link
Copy Markdown
Contributor

Yes, contributing to Apache SeaTunnel.

Pushed b3aa0f2fefaa3d8164378e983ec85ea1274e91c9 by normal fast-forward push. Reconciled dev conflicts while retaining JSON and numeric-special-value source options. Added raw JSON support to scalar/array text formats. Fixed Doris-specific Stream Load transport so boolean/string scalars and JSON null retain their native types; strict parsing remains. The two LocalFile JSON-type fixtures now preserve their pre-created writable shared directories instead of recreating them as the driver user. Exact existing E2E value/row assertions are retained, with new serializer/text regression tests and bilingual migration guidance. The follow-up keeps the Doris serializer's original fields and method signatures, preserving its implicit Java serial form.

Root cause: the LocalFile logs report Permission denied at the final file commit after the schema save mode recreates a previously writable directory. Doris 2.1's JSON reader converts top-level boolean tokens to 1/0 and JSON null to SQL NULL before the column cast; document-string transport preserves the native JSON document. See Doris 2.1 reader. Subsequent Doris checksum failures followed the initial assertion before fixture cleanup; they still require the new-head rerun, rather than being counted as passed.

Validation: affected-module Spotless and diff whitespace checks passed; one independent maintainer source review completed for these deltas. No local compilation, unit/IT/E2E execution, Docker or service startup was run under the repository validation policy. The current-head fork Build is pending and no runtime pass is claimed. Earlier verification statements refer to previous heads. The separate Metalake startup timeout, complete current-head CI and real Snowflake-account acceptance remain gates. This PR remains Draft.

The approved merge's POM files exactly match upstream dev; no dependency edits were added. Existing connector registrations, options, exact JSON tree comparisons and 1-row LocalFile assertions remain.

@DanielLeens DanielLeens left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Self-review of head b3aa0f2fefaa3d8164378e983ec85ea1274e91c9, following my 2026-11-03 review of ff53cb15 and my 2026-11-05 CI update. Two commits are new: 6f185ecf, a merge of dev (fae9ffa9) that also carries real PR changes, and b3aa0f2f ("Preserve Doris serializer class shape"). I separated the PR's own changes from what came in with dev by comparing the per-file PR diff before and after. The PR-side changes are in 15 files: the text format (serializer, deserializer, test), the Doris serializer and its test, DorisIT, the two LocalFile JSON-type fixtures, JdbcSourceOptions (conflict resolution), and the Doris sink, incompatible-changes and schema-feature docs (en/zh). No file was deleted and no POM was edited on the PR side.

What Problem Does This PR Solve?

  • User pain: native semi-structured values (Snowflake VARIANT, Doris JSON/JSONB, StarRocks JSON) are flattened to STRING, so JSON outputs escape them as text and native JSON destinations receive quoted strings.
  • Fix: a String-backed SqlType.JSON / BasicType.JSON_TYPE logical type threaded through schema parsing, formats, transforms, Spark translation and selected sinks, with a handle_json_as_string source opt-out.
  • One sentence: {"id":1} stays a JSON object end to end where supported, and there is an explicit path back to the old STRING behavior.

1. Code Change Review

1.1 Core Logic Analysis

Text format (closes my Issue 12 in code). JSON now shares the STRING branch in TextSerializationSchema.java:213 and in TextDeserializationSchema.java:239 (array elements) and :289 (scalar). The value is already a String, so this is a verbatim pass-through. Doris CSV Stream Load and text-format file sinks no longer fail with not supported for parsing this type [JSON].

Doris JSON Stream Load transport (new behavior). SeaTunnelRowSerializer.java:134-158:

ObjectNode node = (ObjectNode) jsonSchema.convert(row);      // strict parse of every JSON field
for (int i = 0; i < seaTunnelRowType.getTotalFields(); i++) {
    if (seaTunnelRowType.getFieldType(i).getSqlType() == SqlType.JSON
            && row.getField(i) != null) {
        node.put(seaTunnelRowType.getFieldName(i), (String) row.getField(i));  // document as string token
    }
}

The common converter still validates every document. The JSON field is then re-emitted as a JSON string token holding the document text, so Doris parses the text into the JSON column. Before this change, a top-level true would be turned into 1 and a JSON null into SQL NULL. SQL NULL fields keep the converter's output. Field names come from the processed row type, so caseSensitive=false and __DORIS_DELETE_SIGN__ behave as before. b3aa0f2f moved the "has a JSON field" check from a constructor-cached final field into a per-row loop, so that the implicit serial form of the Serializable class stays the same.

Conflict resolution. JdbcSourceOptions.java:189-196 keeps both HANDLE_JSON_AS_STRING and dev's NUMERIC_SPECIAL_VALUE_AS_NULL. JdbcSourceFactory.java:91,122 registers both, and JdbcSource.java:82 still applies LegacyJsonTypeUtil.

LocalFile fixtures. fake_json_type_to_local_csv.conf and fake_json_type_to_local_file.conf switch from RECREATE_SCHEMA/DROP_DATA to CREATE_SCHEMA_WHEN_NOT_EXIST/APPEND_DATA. I checked the claim in the comment: LocalFileIT.java:1093-1100 (resetJsonTypeTestPath) runs rm -rf, mkdir -p and chmod -R 777 on both paths before each round trip (:387, :440). The sink therefore writes into a fresh, empty, world-writable directory, and the exact 1-row and JSON-tree assertions are unchanged. This is not a weakening of the JSON contract. The save mode was never what these fixtures were testing.

Doris/StarRocks/Snowflake metadata -> BasicType.JSON_TYPE (+ legacy length)
 -> [handle_json_as_string] -> STRING (identical to before)
 -> SeaTunnelRow (physical String)
 -> Doris  format=json -> JsonSerializationSchema.convert (strict) -> JSON field re-emitted as string token -> Doris parses into JSON column
           format=csv  -> TextSerializationSchema JSON==STRING pass-through
 -> file text/csv  -> pass-through; JSON format -> native tree
 -> StarRocks JSON+CSV -> fail-fast in sink ctor; Snowflake -> PARSE_JSON
 -> MySQL/PG auto-create -> unsupported (now documented)

1.2 Compatibility Impact

This is still an intentional, documented incompatible change (incompatible-changes.md, en/zh, ## dev). The new commits add no option, default or API change. SqlType.JSON is still tail-appended and BasicType keeps its serialVersionUID. b3aa0f2f keeps the field set of SeaTunnelRowSerializer identical to dev. The new Doris string-token transport only applies when a row type contains JSON, so pipelines without JSON fields produce the same bytes as before.

1.3 Performance / Side Effects

  • SeaTunnelRowSerializer.java:136-142 now loops over the field types for every row to decide whether any field is JSON. This is a per-row cost on the Doris hot path that the earlier version did not have. It is small next to JSON serialization, but it is avoidable. A lazily computed private transient field (the default serialVersionUID ignores private transient fields) would keep the class shape and remove the per-row scan. Low, non-blocking.
  • For JSON rows, convert builds the full tree, which is then patched. That is one extra put per JSON field and no extra parse beyond the existing validation.

1.4 Error Handling and Logging

Status of my 11-03 items at this head:

No. Item Status at b3aa0f2f
12 Text format had no JSON case (Doris CSV, file text) Fixed in code (TextSerializationSchema.java:213, TextDeserializationSchema.java:239,289) and in docs (docs/en/connectors/sink/Doris.md:195, zh :194). The new test is broken, see Issue 14
13 Generic JDBC auto-create of JSON undocumented Docs part fixed: docs/en/introduction/concepts/incompatible-changes.md:14, zh :16. Native MySQL JSON / PostgreSQL jsonb mapping stays an optional follow-up
F2 doc schema-feature.md:161 should list Doris JSON Stream Load as a parsing boundary Fixed (en and zh)
1 LocalFile JSON round trip on current head JDK 17 lane passed. JDK 11 lane cancelled at the workflow deadline
2 Doris scalar/null round trip on current head Not yet proven: both Doris IT lanes were cancelled. The DorisIT change at :399-402 only adds a failure message, and the assertion is unchanged
9, 5 Snowflake custom-query check; Easysearch fallback Open, non-blocking, documented

New and remaining issues:

Issue 14: the new text-format test dereferences a null row, so every unit-test lane fails

  • Location: seatunnel-formats/seatunnel-format-text/src/test/java/org/apache/seatunnel/format/text/TextFormatSchemaTest.java:196.
  • Problem: for a single-field row whose value is SQL NULL, the serializer emits an empty byte array (asserted at :195). TextDeserializationSchema#deserialize returns null for an empty message (TextDeserializationSchema.java:176-178, unchanged behavior), so deserializer.deserialize(sqlNull).getField(0) throws NullPointerException. The fork Build reports TextFormatSchemaTest.testJsonDocumentsRoundTripWithoutStringQuoting:196 NullPointer on all four unit-test lanes (JDK 11/17, ubuntu/windows). Because seatunnel-format-text fails, Maven skips connector-doris and the other downstream modules. So the new SeaTunnelRowSerializerTest#testNativeJsonDocumentsUseStreamLoadStrings, the Qdrant test and the Snowflake dialect tests have still not run on any recent head.
  • Risk: blocks validation. Production code is not affected.
  • Best improvement: assert the real contract. Either Assertions.assertNull(deserializer.deserialize(sqlNull)) for the single-column case, or use a two-column row such as {null, "x"} so the line is not empty, then assert field 0 is null and field 1 round-trips. The second option tests the SQL NULL vs "null" distinction more directly. Do not drop the SQL NULL assertion.
  • Severity: High (blocks validation, caused by this PR).
  • Raised by another reviewer: No.

Issue 15: Doris string-token transport is only proven by a serializer unit test, not against a Doris backend

  • Location: SeaTunnelRowSerializer.java:128-158; DorisIT.java:371-402.
  • Problem: the change relies on Doris parsing a JSON string token into a JSON/JSONB column (the commit cites the Doris 2.1 reader). The unit test only checks the bytes SeaTunnel sends. On 11-05 the DorisIT assertion at :399 failed (expected true, got 1). That is exactly what this change targets, and on this head both Doris IT lanes were cancelled before they ran. One more case is not covered at all: a SeaTunnel JSON field written into a pre-existing Doris VARIANT column now arrives as a string token rather than an object. Auto-create maps JSON to Doris JSON, so only pre-existing tables are affected.
  • Risk: if the target Doris version treats the string token as a JSON string literal rather than parsing it, documents would be stored double-encoded. This is a data-correctness risk, so it must be proven by the IT and not assumed.
  • Best improvement: get a green doris-connector-it (JDK 11 and 17) on the final head with the unchanged exact assertions. Either confirm VARIANT targets in the IT, or state in Doris.md that JSON fields are meant for JSON/JSONB columns and STRING fields for VARIANT (the docs already say the second half).
  • Severity: Medium. Validation gate, must pass before merge.
  • Raised by another reviewer: related to @SEZ9's F2 (validation contract).

Issue 16 (Low): ZH and EN incompatible-changes differ in structure for the JDBC auto-create note

  • Location: docs/en/introduction/concepts/incompatible-changes.md:14 is a labelled bullet inside the entry. docs/zh/introduction/concepts/incompatible-changes.md:16 is a free paragraph after the bullet list.
  • Problem and fix: the content matches, but the ZH note sits outside the entry and has no label. Make it a bullet with a label under the same entry. Non-blocking.
  • Raised by another reviewer: No.

@SEZ9's F1-F4: I answered these point by point on 11-04 against ff53cb15, and nothing in the new commits regresses them. F2's documented contract now also lists the Doris JSON Stream Load boundary, as I promised.

2. Code Quality Assessment

2.1 Coding Standards

The Javadoc on buildJsonString explains why the string token is used (the Doris 2.1 coercion of top-level tokens). The inline comment explains why the flag is not cached. The new tests have Javadoc that states which regression they guard. No unused imports remain (Code style lane passed).

2.2 Test Coverage and Test Stability

Stability rating: High risk at this head, because TextFormatSchemaTest.java:196 fails deterministically (Issue 14).

  • TextFormatSchemaTest#testJsonDocumentsRoundTripWithoutStringQuoting: the document loop (:186-193) is a good regression guard for the pass-through. It would fail if case JSON were removed or if the serializer quoted the value. Only the SQL NULL tail is wrong.
  • SeaTunnelRowSerializerTest#testNativeJsonDocumentsUseStreamLoadStrings (:47): checks the textual token for object, array, boolean, number, string and null documents, that a SQL NULL field is omitted, and that invalid text is rejected. It would fail if the transport went back to structured tokens. It has not executed yet (module skipped).
  • LocalFile fixture changes keep the exact assertions (see 1.1).

2.3 Documentation Updates

Doris.md (en :195, zh :194), schema-feature.md:161 and incompatible-changes.md are updated in both languages with matching content. The only gap is the structure difference in Issue 16.

3. Architectural Soundness

The String-backed logical type with explicit per-consumer decisions remains the right design. This round makes the two decisions that were missing: the text format passes JSON through, and Doris JSON transport preserves native JSON types. The Doris transport detail correctly lives in the connector serializer, not in the shared JSON format.

4. Issue Summary

No. Issue Location Severity
14 New text test calls getField on the null row returned for an empty line; all unit lanes fail TextFormatSchemaTest.java:196 High, blocks validation
15 Doris string-token transport not yet proven against Doris; VARIANT targets uncovered SeaTunnelRowSerializer.java:128-158; DorisIT.java:371-402 Medium, validation gate
2 Doris round trip on current head DorisIT.java:399 Validation gate (lanes cancelled)
1 LocalFile JSON round trip, JDK 11 LocalFileIT.java:387,440 Validation gate (JDK 17 passed)
- Per-row JSON-field scan in Doris serializer SeaTunnelRowSerializer.java:136-142 Low, non-blocking
16 ZH JDBC auto-create note outside the entry incompatible-changes.md (zh):16 Low, non-blocking
9, 5 Snowflake custom-query check; Easysearch fallback SnowflakeDialect.java:140; EasysearchDataTypeConvertor.java Medium, non-blocking, documented
12, 13 (docs), F2 doc Previously blocking see table in 1.4 Fixed at this head

5. Merge Recommendation

Conclusion: Not recommended for merge

  1. Blockers: Issue 14 (a one-line test fix, but it fails every unit lane and hides the Doris, Qdrant and Snowflake unit tests behind a skipped reactor). Then a green Doris IT for Issue 15 / Issue 2. The PR is also still a Draft, and real Snowflake-account acceptance remains open.
  2. CI: fork Build 42348741989 on this head completed with failure. The 4 unit-test lanes failed on Issue 14, which this PR causes. 28 IT lanes were cancelled at the workflow deadline and did not fail, including both doris-connector-it lanes and connector-file-local-it (11). 53 jobs passed, including connector-file-local-it (17), all JDBC part lanes on JDK 17 except part 7, and the light checks. The cancelled lanes are a capacity issue, not a code failure. They need a rerun after the fix, not a dev sync.
  3. Merge state: MERGEABLE (no conflicts) and BLOCKED (review required). The branch is 17 commits behind dev.
  4. Non-blocking: the per-row scan, Issue 16, Issues 9 and 5, and the native MySQL/PostgreSQL JSON mapping.

Issues 12 and 13 from my last round are now properly closed in both code and docs, and the conflict merge kept both source options intact. That is real progress. Once the test tail is fixed and the Doris IT is green on the final head, I expect only the non-blocking items to remain. As the author I cannot approve this PR; final approval belongs to a committer.

@DanielLeens DanielLeens left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

A merge-state fact in my previous conclusion has changed. GitHub now reports merge conflicts (mergeable_state=dirty) between unchanged head b3aa0f2fefaa3d8164378e983ec85ea1274e91c9 and dev. The earlier statement that this head had no conflicts is obsolete.

Please sync the latest dev and resolve the conflicts first, preserving both the PR's intended change and the upstream changes, then rerun the checks on the resolved head. This request is for an actual reported merge conflict, not merely because the branch is behind.

The prior deterministic TextFormatSchemaTest failure and Doris/current-head integration validation gates remain open. A branch update alone does not resolve them.

Conclusion: Ready to merge after fixes

  • Blockers — must be fixed: The merge conflict plus the previously identified blockers, where listed above. A fresh head requires a full re-review and current-head checks.
  • Recommended fixes — non-blocking: Earlier optional suggestions retain their previous status; this note adds no source finding against the unchanged code version.

Recorded comparison: diverged, ahead 20 / behind 36 of dev. I have not changed the contributor's branch or executed the PR locally. Daniel has READ permission; effective approval/dismissal and merge remain with a write-capable maintainer.

@SEZ9

SEZ9 commented Nov 14, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the follow-up commits on b3aa0f2f. Checking them against the four points from my earlier review:

F1 – silent STRING → JSON change for Snowflake VARIANT / Doris JSON/JSONB / StarRocks JSON. The handle_json_as_string source option is exactly the opt-out I was asking for, so the design concern is resolved. Remaining ask: please make sure docs/en/introduction/concepts/incompatible-changes.md (and the zh counterpart) explicitly states that these three connectors now emit JSON by default and names handle_json_as_string as the way to restore the previous STRING behavior, so users hitting this on upgrade can find the escape hatch quickly.

F2 – JSON is physically a plain String, so non-JSON text can reach a native JSON sink. The Doris change helps here: running every row through jsonSchema.convert(row) before re-emitting the JSON field as a string token means malformed documents are rejected on the Doris side as well, not only at the StarRocks load boundary. Please add a unit test in the Doris serializer test that feeds an invalid JSON string into a SqlType.JSON field and asserts the failure, so this validation doesn't regress. For schema-feature.md, a one-line note that json is String-backed and validated only by sinks that write native JSON would set the right expectation.

F3 – StarRocks native JSON columns + default CSV Stream Load format fails only at load time. I don't see this addressed in the new commits. The ask stands: fail fast at sink initialization when a JSON field is present and the load format is CSV, with a clear message pointing to the JSON format, and document that constraint in docs/en/connectors/sink/StarRocks.md.

F4 – Snowflake sink with a user-defined query skips PARSE_JSON wrapping. Also not addressed yet. Either wrap JSON fields in the user query path too, or reject/warn at initialization when a JSON field is present with a custom query, and state the behavior in docs/en/connectors/sink/Snowflake.md.

Separately, the head now reports merge conflicts with dev (ahead 20 / behind 36). Please sync dev, resolve the conflicts keeping both sides intact, and push a fresh head; the open TextFormatSchemaTest failure and the Doris integration validation noted above should be re-verified on that head rather than on b3aa0f2f.

Once F3 and F4 have fail-fast handling plus docs, and the branch is conflict-free, I'm happy to take another full pass.

Preserve the changes from both parents and resolve only the overlapping paths for this pull request.

@DanielLeens DanielLeens left a comment •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Apache SeaTunnel self-review at a645c856a90a37473a34d83ac5b9f5e91a8d1116. The dev merge does not fix the previous text regression. The net diff also stops carrying a duplicate package/license context in the Qdrant test; the current JSON behavior still needs the checks below.

What Problem Does This PR Solve?

A JSON column should remain a logical JSON value across catalog/connector conversion and row transport instead of being silently exposed as an ordinary string. The patch adds the logical type in BasicType / SqlType, adjusts row conversion and schema mapping, handles connector-specific representations in JDBC, Doris and StarRocks, and updates JSON, Avro, CSV and TEXT format conversion plus SQL/transform and Flink/Spark adapters. The normal path for a declared JSON column reaches these changes. Existing non-JSON columns should retain their old representation. The important distinction is SQL NULL versus the JSON document null; a textual representation can be copied internally but must not emerge as an unintended JSON string token at the sink.

1. Code Change Review

1.1 Core Logic Analysis

The logical type belongs at the schema boundary with explicit serialization in each format. That is preferable to converting every JSON column to an ordinary string in the API, which would lose the downstream type and null contract. New checkpoint/row artifacts containing the logical type need consumers that understand it; the bilingual compatibility notes document the behavior shift, but the review did not run a mixed-release restore.

Before/after diff excerpt from BasicType.java (removed and added lines are marked):

+    public static final BasicType<String> JSON_TYPE = new BasicType<>(String.class, SqlType.JSON);

Key Findings

  • The ordinary entry point and the conditions that reach the change are shown below.
  • Preserve the old TEXT empty-line policy and validate both current Doris storage and upgrade consumption separately.
  • The issue analysis identifies remaining review blockers.

Complete runtime path

Catalog logical JSON type
  -> connector converter
  -> SeaTunnelRow
  -> format serializer or native sink adapter
  -> target parsing/storage; serialized artifacts require a consumer that knows JSON

1.2 Compatibility Impact

Partially incompatible. Preserve the old TEXT empty-line policy and validate both current Doris storage and upgrade consumption separately.

1.3 Performance / Side-Effect Analysis

The operational side effects and ownership boundaries in this patch are described in the call-chain review and the fixture assessment below. Runtime performance was not measured locally.

1.4 Error Handling and Logging

Issue 14 (High, blocking, carried forward): TextFormatSchemaTest.java:195–196 serializes a one-column SQL-null row as an empty line and immediately calls getField(0) on the result of deserializing it. The text deserializer's empty-record policy returns a null row. The test cannot get to its field assertion. Use a row shape that preserves a real record while independently checking the null JSON cell, or assert the existing empty-record behavior at its own boundary. Do not change the format's longstanding empty-line contract just to satisfy this fixture.

Issues 15 / 2 (Medium, validation blockers, carried forward): the Doris serializer sends an encoded string token for a JSON document, and the real Doris job must prove that the target parses it rather than stores a quoted document. The added Doris case checks native JSON values including SQL NULL; the VARIANT boundary still needs evidence or a narrower claim. Verify the exact-head Doris and LocalFile JSON integration lanes. A JDBC type-mapping test cannot substitute for actual storage and readback.

2. Code Quality Assessment

2.1 Coding Standards

The relevant documentation, lifecycle boundaries and known findings are identified above; the full file list was reconciled against GitHub.

2.2 Test Coverage and Test Stability

Test stability: High risk while the text test deterministically dereferences a null row. The remaining formatter and adapter cases cover typed conversion, JSON literal null and scalar/structured values; database-backed and cross-version evidence must be reported separately. The existing Snowflake custom-query limitation, Easysearch fallback and bilingual note placement remain non-blocking as previously documented.

Local diff paths match GitHub. No local build or tests were executed. The exact-head fork Build is queued; the older failed unit lanes are historical evidence, not a result for this commit.

2.3 Documentation Updates

New checkpoint/row artifacts containing the logical type need consumers that understand it; the bilingual compatibility notes document the behavior shift, but the review did not run a mixed-release restore. The existing Snowflake custom-query limitation, Easysearch fallback and bilingual note placement remain non-blocking as previously documented.

Local diff paths match GitHub.

3. Architectural Soundness

3.1 Elegance of the Solution

Long-term solution. Preserve the old TEXT empty-line policy and validate both current Doris storage and upgrade consumption separately.

3.2 Maintainability

Keep the ownership and validation boundaries named in the runtime and issue analysis.

3.3 Extensibility

The review recommendation below records where the smallest safe change fits and where a broader redesign would need separate verification.

3.4 Historical-Version Compatibility

Preserve the old TEXT empty-line policy and validate both current Doris storage and upgrade consumption separately.

4. Issue Summary

Number Issue Location Severity
14 TEXT fixture dereferences an empty record TextFormatSchemaTest.java:195–196 High
15 Verify native JSON storage and VARIANT claims Doris serializer and IT Medium
2 Verify exact-head output lanes Doris and LocalFile IT Medium

5. Merge Recommendation

Conclusion: Not recommended for merge

  1. Blockers — must be fixed
  • Issue 14: TEXT fixture dereferences an empty record.
  • Issue 15: Verify native JSON storage and VARIANT claims.
  • Issue 2: Verify exact-head output lanes.
  1. Recommended fixes — non-blocking
  • See the existing test and implementation suggestions above, where applicable.

Fix the TEXT fixture and obtain real exact-head Doris and LocalFile output evidence before proceeding. This is a COMMENT on my own draft and cannot replace independent review.

Head a645c856a90a37473a34d83ac5b9f5e91a8d1116; base dev at b3828eb141d3ca669181084dbd73bfb534064e08; comparison diverged, ahead 21 / behind 1. Apache Build: No Apache Build check observed on this head. My technical review on my own PR is a COMMENT and does not provide independent approval.

@DanielLeens

Copy link
Copy Markdown
Contributor Author

Implementation Notes and Trade-offs

Yes, contributing to Apache SeaTunnel. Follow-up on head e4d826fb702dad3ed3571c6e4e09a841f433c035.

The TEXT serializer emits an empty line for a one-column SQL-NULL record. The reader deliberately treats a zero-byte input as no record. The updated fixture keeps an ID column so it can distinguish a real SQL-NULL cell from JSON literal null, and separately asserts the existing empty-record behavior. Changing the production reader would change behavior for existing jobs. The Doris and LocalFile output and compatibility checks remain open.

The focused Java file passed Spotless with the repository's version and Java rules in an isolated formatter project. The staged diff passed the whitespace check and independent source review found no blocker in this correction. No local compile, runtime, E2E, or UI validation was run. GitHub CI on this head is required before runtime verification can be claimed.

@SEZ9

SEZ9 commented Nov 15, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the follow-up on e4d826fb702dad3ed3571c6e4e09a841f433c035. The notes there focus on the TEXT fixture and the still-open Doris/LocalFile checks, so from my side the four points from the earlier review are still outstanding. Summarizing what I'd like to see before I can approve:

  1. Source type change with no opt-out (HIGH) – Snowflake VARIANT, Doris JSON/JSONB and StarRocks JSON columns now surface as the new JSON logical type instead of STRING on upgrade. Please either add an option that keeps the previous STRING mapping, or make an explicit case in docs/en/introduction/concepts/incompatible-changes.md for why a silent change is acceptable and what users with existing pipelines must do. The current wording in the compatibility note documents the shift but does not give users a migration path.

  2. No JSON validation on the logical type (MEDIUM) – since JSON_TYPE is physically a String, non-JSON text can flow all the way to a native JSON sink and only fail at the StarRocks load boundary. Please clarify in docs/en/introduction/concepts/schema-feature.md whether validation is intentionally the sink's responsibility, and if so, where each native JSON sink enforces it. If there is a central validation point I missed, point me to it.

  3. StarRocks CSV Stream Load + native JSON columns (MEDIUM) – the rejection should be a fail-fast check at sink initialization rather than a load-time error. Please add that check and document the constraint in docs/en/connectors/sink/StarRocks.md.

  4. Snowflake sink with user-defined query (MEDIUM) – skipping PARSE_JSON wrapping silently defers failure to a server-side error mid-run. Either wrap JSON fields in the custom-query path as well, or fail fast/warn at initialization and document the limitation in docs/en/connectors/sink/Snowflake.md.

Two smaller asks tied to the above: the follow-up states that no local compile, runtime or E2E validation was run on this head, so please confirm once the CI on e4d826fb702dad3ed3571c6e4e09a841f433c035 is green and add E2E coverage for points 3 and 4 (misconfigured StarRocks CSV + JSON column, Snowflake custom query with a JSON field). Also, the self-review at a645c856a90a37473a34d83ac5b9f5e91a8d1116 mentions that the Doris storage and upgrade-consumption checks are still open—please share the result of those once done, as they feed directly into point 1.

Happy to take another look as soon as these are pushed.

Reuse the test fixture version update merged in apache#13285.

@SEZ9 SEZ9 left a comment

Copy link
Copy Markdown
Collaborator

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 latest head dc30ce70f73b.

What this PR fixes

  • User pain: Snowflake VARIANT, Doris JSON/JSONB and StarRocks JSON columns travel through SeaTunnel as plain STRING. Sinks and formats cannot tell a JSON document from text, so they write it back as an escaped string instead of a native JSON value (issue #10774).
  • Fix approach: add a String-backed SqlType.JSON / BasicType.JSON_TYPE and map the three native types to it in the type converters and catalogs. Each write path then treats the value as a document:
    • The JSON format and StarRocks JSON Stream Load re-parse it into a Jackson tree.
    • Doris JSON Stream Load validates it through the JSON format converter and then sends the original text as a document string.
    • Snowflake wraps the bind in PARSE_JSON(:field) using INSERT ... SELECT, and refuses a user-defined query that does not contain PARSE_JSON.
    • StarRocks rejects JSON columns with CSV Stream Load when the sink is created.
    • A new handle_json_as_string source option on Doris and Jdbc restores the previous STRING schema.
  • One-line summary: the type and its write paths are coherent, but the new mapping is on by default, and several write paths change values, output shape or error quality in ways the incompatible-changes entry and connector docs do not yet cover.

Runtime chain I rechecked

Read path (source schema: STRING -> JSON by default)
  Snowflake: SnowflakeTypeConverter.convert(): VARIANT -> BasicType.JSON_TYPE  SnowflakeTypeConverter.java:156
    -> opt-out: `handle_json_as_string` (JdbcSourceOptions.java:189, read in JdbcSourceConfig.java:100) maps JSON columns back to STRING through LegacyJsonTypeUtil
  Doris: AbstractDorisTypeConverter: JSON/JSONB -> BasicType.JSON_TYPE  AbstractDorisTypeConverter.java:202
    -> opt-out: `handle_json_as_string` (DorisSourceOptions.java:105-112, default false) applied in DorisSourceFactory through LegacyJsonTypeUtil
  StarRocks: StarRocksCatalog: native `json` -> BasicType.JSON_TYPE  StarRocksCatalog.java:326, 370   (no opt-out option)

Write path (String-backed JSON value -> native document)
  JSON format: RowToJsonConverters `case JSON`  RowToJsonConverters.java:193-210
    -> mapper.reader().with(FAIL_ON_TRAILING_TOKENS).readTree((String) value)  :199-201   (mapper from JsonSerializationSchema.java:49, only WRITE_BIGDECIMAL_AS_PLAIN at :99)
    -> failure: CommonError.jsonOperationError("Common", "invalid JSON value", e)  :207
    -> row converter: SQL NULL JSON field -> node.remove(fieldName)  :311-316
  Doris JSON Stream Load: SeaTunnelRowSerializer.buildJsonString()  SeaTunnelRowSerializer.java:134-159
    -> jsonSchema.convert(row) validates each document  :147
    -> node.put(fieldName, (String) row.getField(i)) re-emits the original text as a string  :151
  StarRocks: StarRocksSink constructor -> validateJsonColumnsAgainstLoadFormat()  StarRocksSink.java:71, 147-168   (fires only when loadFormat == CSV)
    -> SinkConfig.of(): config.get(LOAD_FORMAT) (key `starrocks.config.format`, default JSON), then `format` from the `starrocks.config` map overrides it  SinkConfig.java:99-105
    -> StarRocksJsonSerializer.serialize(): readJsonValue() on a bare ObjectMapper  StarRocksJsonSerializer.java:43, 60-68, 96-106
    -> failure: CommonError.jsonOperationError("StarRocks", "invalid JSON value", e)  :67
  Snowflake: JdbcSink constructor -> dialect.validateUserDefinedQuery(query, tableSchema)  JdbcSink.java:115 -> SnowflakeDialect.java:131-151
    -> generated SQL: getInsertIntoStatement() builds INSERT ... SELECT with PARSE_JSON(:field)  SnowflakeDialect.java:67-87, 154-158

Findings

Issue 1: Doris JSON/JSONB and Snowflake VARIANT source columns switch from STRING to JSON by default, and the StarRocks catalog mapping has no opt-out.

  • Location: seatunnel-connectors-v2/connector-doris/src/main/java/org/apache/seatunnel/connectors/doris/config/DorisSourceOptions.java:108
  • Why it matters: Root cause: both handle_json_as_string options default to false, while AbstractDorisTypeConverter, SnowflakeTypeConverter and StarRocksCatalog now return BasicType.JSON_TYPE for columns that used to be STRING.
  • An unchanged job config therefore gets a different source schema on upgrade.
  • A sink without a JSON branch fails or degrades. The incompatible-changes entry itself lists Qdrant rejecting the field and the generic MySQL/PostgreSQL JDBC auto-create not mapping the type.
  • StarRocksCatalog has no equivalent option. The docs say the StarRocks source uses the user-declared schema, so the exposure there is the catalog and automatic table creation, but it is still an unconditional change.
  • The entry now documents the opt-out and a migration path, which is what we require for an incompatible change. The remaining question is the default.

Suggested fix: default handle_json_as_string to true for one release so that the new type is opt-in, then flip the default later with a deprecation note. If the default stays false, please make the case for that explicitly in the PR description.

  • Evidence: seatunnel-connectors-v2/connector-doris/src/main/java/org/apache/seatunnel/connectors/doris/datatype/AbstractDorisTypeConverter.java:198 builder.dataType(BasicType.JSON_TYPE);; seatunnel-connectors-v2/connector-starrocks/src/main/java/org/apache/seatunnel/connectors/seatunnel/starrocks/catalog/StarRocksCatalog.java:326 return BasicType.JSON_TYPE;; docs/en/introduction/concepts/incompatible-changes.md:15 - **Opt-out**: Set handle_json_as_string = trueon the Doris source or on the Jdbc source (SnowflakeVARIANT) to keep exposing these columns as STRING, exactly as before this change.
  • Suggested fix: With defaultValue(false) here (and on the JDBC option), an unchanged Doris/Snowflake job gets JSON instead of STRING after upgrade, and any sink without a JSON branch fails or degrades. Could we default this to true for one release so the new type is opt-in, and flip it later with a deprecation note? Also note that the StarRocksCatalog mapping change has no equivalent switch.
  • Priority: P0 — must fix before merge
  • I traced this in the code.
  • When it happens: Take an existing job with a Doris source reading a table that has a JSON or JSONB column, a Qdrant sink using that column as a payload field, and no handle_json_as_string in the config. Before this PR the column is STRING and Qdrant writes it via ValueFactory.value(value.toString()). At this head the column is JSON and QdrantBatchWriter.buildPayload throws QdrantConnectorException (UNSUPPORTED_DATA_TYPE). The same unchanged config with a Jdbc Snowflake source and a VARIANT column also yields JSON instead of STRING.

Issue 2: The JSON format and StarRocks JSON Stream Load re-parse the document without USE_BIG_DECIMAL_FOR_FLOATS and re-serialize the tree, so high-precision fractional numbers are silently rounded to double.

  • Location: seatunnel-formats/seatunnel-format-json/src/main/java/org/apache/seatunnel/format/json/RowToJsonConverters.java:201
  • Why it matters: Root cause: both new JSON write paths turn the String-backed value into a Jackson tree and write the tree, not the original text.
  • RowToJsonConverters parses with the JsonSerializationSchema mapper, which only sets WRITE_BIGDECIMAL_AS_PLAIN. StarRocksJsonSerializer uses a bare new ObjectMapper(). Neither enables USE_BIG_DECIMAL_FOR_FLOATS, so every fractional number becomes a DoubleNode.
  • The read side is not symmetric: JsonDeserializationSchema (lines 87 and 108) does enable USE_BIG_DECIMAL_FOR_FLOATS.
  • The Doris serializer in this PR avoids the problem, because buildJsonString puts the original text back with node.put(fieldName, (String) row.getField(i)) after validation.
  • Example: {"amount":12345678901234567890.123456789} is written back with the low digits lost, and no error is raised.

Suggested fix: parse with USE_BIG_DECIMAL_FOR_FLOATS on the reader in both places, or validate and then emit the original text as the Doris path does. Please add a test with a number beyond double precision for the JSON format and for the StarRocks serializer.

  • Evidence: seatunnel-formats/seatunnel-format-json/src/main/java/org/apache/seatunnel/format/json/RowToJsonConverters.java:201 .readTree((String) value);; seatunnel-connectors-v2/connector-starrocks/src/main/java/org/apache/seatunnel/connectors/seatunnel/starrocks/serialize/StarRocksJsonSerializer.java:43 private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();; seatunnel-connectors-v2/connector-starrocks/src/main/java/org/apache/seatunnel/connectors/seatunnel/starrocks/serialize/StarRocksJsonSerializer.java:101 .readTree(value);
  • Suggested fix: This readTree runs on the serialization mapper, which does not enable USE_BIG_DECIMAL_FOR_FLOATS, so every fractional number in the document becomes a DoubleNode and is written back rounded. For example {"amount":12345678901234567890.123456789} loses its low digits with no error. JsonDeserializationSchema enables that feature on the read side, and the Doris serializer in this PR re-emits the original text after validation, so only this path and StarRocksJsonSerializer (bare new ObjectMapper()) are affected. Could you add .with(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS) to the reader in both places, plus a test with a number beyond double precision?
  • Priority: P1 — should fix in this PR
  • I traced this in the code.
  • When it happens: Use a row type {payload: JSON} with the field value {"rate":0.1234567890123456789}. Serialize it with new JsonSerializationSchema(rowType).serialize(row) (Kafka or File JSON format), or with new StarRocksJsonSerializer(rowType, false).serialize(row). The output is {"payload":{"rate":0.12345678901234568}}. With {"amount":12345678901234567890.123456789} the output is 1.2345678901234567E19. No exception or warning is raised.

Issue 3: Invalid-JSON failures do not name the field, and the payload slot of jsonOperationError is filled with a fixed phrase, so the bad record is hard to locate.

  • Location: seatunnel-connectors-v2/connector-starrocks/src/main/java/org/apache/seatunnel/connectors/seatunnel/starrocks/serialize/StarRocksJsonSerializer.java:67
  • Why it matters: Root cause: readJsonValue parses the row value from a String, and the catch block passes the Jackson exception straight into CommonError.jsonOperationError("StarRocks", "invalid JSON value", e).
  • JSON_OPERATION_FAILED renders as <identifier> JSON convert/parse '<payload>' operation failed., so the top-level message is always StarRocks JSON convert/parse 'invalid JSON value' operation failed. with no column name.
  • The only locating information is whatever Jackson puts in the cause. The shaded Jackson is 2.15.4 (seatunnel.shade.jackson.version in the root pom.xml), where INCLUDE_SOURCE_IN_LOCATION is still on by default, and OBJECT_MAPPER is a bare new ObjectMapper(). A parse error therefore carries a [Source: (String)"..."] excerpt of the raw document. That puts row data in the log that we do not control, and it still does not say which column failed.
  • The JSON value is empty branch carries neither a field name nor a source excerpt.
  • RowToJsonConverters has the same pattern with jsonOperationError("Common", "invalid JSON value", e).

Suggested fix: put the field name into the message. seaTunnelRowType.getFieldName(i) is available at the StarRocks call site, and fieldNames[i] is available in createRowConverter for the JSON format. If a content excerpt is wanted, make it a length-bounded one that we build ourselves.

  • Evidence: seatunnel-formats/seatunnel-format-json/src/main/java/org/apache/seatunnel/format/json/RowToJsonConverters.java:207 throw CommonError.jsonOperationError("Common", "invalid JSON value", e);; seatunnel-connectors-v2/connector-starrocks/src/main/java/org/apache/seatunnel/connectors/seatunnel/starrocks/serialize/StarRocksJsonSerializer.java:43 private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
  • Suggested fix: jsonOperationError renders its second argument as the offending payload, so this produces StarRocks JSON convert/parse 'invalid JSON value' operation failed. with no column name. A malformed document fails the job and will be hit again on restart, so the operator needs to be able to find it. Please include seaTunnelRowType.getFieldName(i) here (and, if you want content in the message, a length-bounded excerpt of the value), and do the same in RowToJsonConverters, where createRowConverter has the field name.
  • Priority: P1 — should fix in this PR
  • I traced this in the code.
  • When it happens: StarRocks sink with starrocks.config.format = JSON and a row type with two JSON-typed fields a and b. Send a row where a = "{}" and b = "{bad". StarRocksJsonSerializer.serialize throws a SeaTunnelRuntimeException with COMMON-02 and the text StarRocks JSON convert/parse 'invalid JSON value' operation failed.. Neither a nor b appears in the SeaTunnel message, so the failing column is not identified.

Issue 4: JSON-format sinks silently change their output for these columns (nested value instead of escaped string, key omitted for SQL NULL), and the incompatible-changes entry does not mention it.

  • Location: seatunnel-formats/seatunnel-format-json/src/main/java/org/apache/seatunnel/format/json/RowToJsonConverters.java:315
  • Why it matters: Root cause: the new case JSON converter in RowToJsonConverters parses the text and emits a structured node, and the row converter removes the key when a JSON field is SQL NULL.
  • A Doris JSON or Snowflake VARIANT column written through the JSON format used to produce "payload":"{\"a\":1}", and "payload":null for NULL.
  • It now produces "payload":{"a":1}, and no payload key at all for NULL.
  • Other types still go through wrapIntoNullableConverter and emit an explicit null node, so JSON columns are the only ones whose key disappears from the record.
  • The incompatible-changes entry describes the schema type change but not this change in serialized output, which affects every consumer of JSON-format sinks.

Suggested fix: document both output changes in the en and zh incompatible-changes entry. Please also reconsider dropping the key: emitting "field":null for SQL NULL would stay consistent with every other type. If the omission is needed to distinguish SQL NULL from the JSON text null, say so in the entry.

  • Evidence: seatunnel-formats/seatunnel-format-json/src/main/java/org/apache/seatunnel/format/json/RowToJsonConverters.java:311 if (fieldTypes[i].getSqlType() == SqlType.JSON && row.getField(i) == null) {; seatunnel-formats/seatunnel-format-json/src/main/java/org/apache/seatunnel/format/json/RowToJsonConverters.java:315 node.remove(fieldName);; docs/en/introduction/concepts/incompatible-changes.md:13 - **Impact**: Pipelines that inspect the source schema or write to a sink without JSON support can observe a different type or receive an unsupported-type error.
  • Suggested fix: node.remove(fieldName) makes JSON columns the only type whose key disappears from the record on SQL NULL; every other type emits "field":null. Together with the new case JSON converter, an existing Doris JSON / Snowflake VARIANT to JSON-format pipeline changes from "payload":"{\"a\":1}" to "payload":{"a":1}, and from "payload":null to no key, with no error. Please document both changes in the en and zh incompatible-changes entry. Could we also emit an explicit null here to stay consistent with the other types, or explain in the entry why the key has to be omitted?
  • Priority: P1 — should fix in this PR
  • I traced this in the code.
  • When it happens: Run Doris source (column payload JSON) to a Kafka sink with format = json and no handle_json_as_string. For a row with payload {"a":1}, the record was {"id":1,"payload":"{\"a\":1}"} before this PR and is {"id":1,"payload":{"a":1}} at this head. For a row with SQL NULL payload, the record was {"id":2,"payload":null} before and is {"id":2} at this head, with no error raised.

Issue 5: validateUserDefinedQuery is a substring match driven by the upstream schema: it rejects valid custom queries with no override and accepts ones that do not wrap the JSON placeholder.

  • Location: seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/internal/dialect/snowflake/SnowflakeDialect.java:140
  • Why it matters: The fail-fast check is query.toUpperCase(Locale.ROOT).contains("PARSE_JSON"), evaluated against the upstream tableSchema in the JdbcSink constructor.
  • False positive: it never looks at the target column type. A custom query that writes an upstream JSON field into a VARCHAR/TEXT column is now refused at submission. So is a query that deliberately handles the value another way, for example TO_VARIANT(?) or a stored procedure call. There is no option to bypass the check.
  • False negative: a query that only mentions PARSE_JSON in a comment, or wraps one of several JSON placeholders, passes the check and still stores escaped strings for the unwrapped fields.

Suggested fix: downgrade the check to a WARN that names the JSON fields, or keep the failure and add an explicit way to opt out. Either way, please describe it in the Snowflake sink doc as a heuristic.

  • Evidence: seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/internal/dialect/snowflake/SnowflakeDialect.java:137 .filter(column -> column.getDataType().getSqlType() == SqlType.JSON); seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/sink/JdbcSink.java:115 dialect.validateUserDefinedQuery(jdbcSinkConfig.getSimpleSql(), this.tableSchema);
  • Suggested fix: A substring test on the whole query, driven only by the upstream schema, fails in both directions. It refuses a legitimate custom query that writes a JSON field into a VARCHAR column or uses TO_VARIANT(?), and there is no way to override it. It also accepts a query that only mentions PARSE_JSON in a comment or wraps one of several JSON placeholders. I would downgrade this to a WARN that names the JSON fields, or keep the failure but add an explicit opt-out, and document it as a heuristic.
  • Priority: P1 — should fix in this PR
  • I traced this in the code.
  • When it happens: Snowflake VARIANT source with default handle_json_as_string = false, so column payload arrives as JSON. Jdbc sink to Snowflake with query = "INSERT INTO t (id, payload) VALUES (?, ?)", where t.payload is VARCHAR. The JdbcSink constructor throws JdbcConnectorException Snowflake sink: the user-defined query does not apply PARSE_JSON to the JSON field(s) [payload]..., although no VARIANT column is involved. Conversely, query = "INSERT INTO t (a, b) SELECT PARSE_JSON(?), ?" with two JSON fields a and b, or a plain query containing /* PARSE_JSON */, passes the check and binds the unwrapped field as plain text.

Issue 6: The StarRocks sink doc says CSV is the default Stream Load format, but the code default for starrocks.config.format is JSON.

  • Location: docs/en/connectors/sink/StarRocks.md:243
  • Why it matters: Root cause: the new paragraph describes the fail-fast as triggering for "CSV (the default)", but StarRocksSinkOptions.LOAD_FORMAT (key starrocks.config.format) declares .defaultValue(StreamLoadFormat.JSON), and SinkConfig.of reads that option before the new format override.
  • A user who leaves the format unset gets JSON Stream Load, so the new validateJsonColumnsAgainstLoadFormat check never fires for them.
  • The doc tells them the opposite: that a default config with JSON columns fails at submission and that they must set the format explicitly.
  • The zh paragraph at docs/zh/connectors/sink/StarRocks.md:238 makes the same claim.

Suggested fix: remove "(the default)" from the en and zh paragraphs and state that the default is JSON, so that only an explicit CSV setting is rejected.

  • Evidence: seatunnel-connectors-v2/connector-starrocks/src/main/java/org/apache/seatunnel/connectors/seatunnel/starrocks/config/SinkConfig.java:100 Object legacyFormat = sinkConfig.getStreamLoadProps().get("format");; seatunnel-connectors-v2/connector-starrocks/src/main/java/org/apache/seatunnel/connectors/seatunnel/starrocks/config/SinkConfig.java:103 StreamLoadFormat.valueOf(; docs/zh/connectors/sink/StarRocks.md:238 the added paragraph carries the same "CSV (default value)" wording in Chinese
  • Suggested fix: "CSV (the default)" does not match the code: StarRocksSinkOptions.LOAD_FORMAT (starrocks.config.format) has .defaultValue(StreamLoadFormat.JSON), so with no format set the sink uses JSON Stream Load and this check never fires. Please correct the default here; the zh paragraph at docs/zh/connectors/sink/StarRocks.md:238 makes the same claim and needs the same fix.
  • Priority: P2 — optional
  • I traced this in the code.
  • When it happens: Configure a StarRocks sink with an upstream schema containing a JSON column and no format under starrocks.config. The doc says the job fails at submission and that starrocks.config.format = "JSON" must be set. In fact SinkConfig.of yields loadFormat = JSON, the constructor check returns at StarRocksSink.java:149-151, and the job runs with JSON Stream Load.

Issue 7: The incompatible-changes entry differs in structure between en and zh, and its Databend/Easysearch statements have no code or test in this PR behind them.

  • Location: docs/en/introduction/concepts/incompatible-changes.md:14
  • Why it matters: The entry now has the opt-out and migration guide, which meets our rule for documented incompatible changes. What remains is consistency and accuracy.
  • In docs/en the "JDBC auto-create limitation" is a sub-bullet of the breaking-change item (line 14). In docs/zh the same content is a detached paragraph after the migration guide (line 16), outside the bullet list and without the label. Please use the same bullet in both.
  • Line 13 says "Databend creates a STRING column and logs a warning, and Easysearch maps the field to its string type". Neither connector is changed or tested in this PR, so nothing here backs those statements. Please confirm them against the current connector code, or drop them and keep only the behavior this PR covers (Qdrant).
  • Evidence: docs/en/introduction/concepts/incompatible-changes.md:13 Sinks without a JSON mapping behave as follows: Qdrant rejects a JSON payload field with an unsupported-type error, Databend creates a STRING column and logs a warning, and Easysearch maps the field to its string type.; docs/zh/introduction/concepts/incompatible-changes.md:16 the JDBC auto-create limitation is added as a standalone paragraph after the migration-guide bullet instead of a sub-bullet
  • Suggested fix: Two small things on this entry. (1) Here the JDBC auto-create limitation is a sub-bullet, but in docs/zh/introduction/concepts/incompatible-changes.md:16 it is a detached paragraph after the migration guide; please make the two pages structurally identical. (2) The line above states specific behavior for Databend ("creates a STRING column and logs a warning") and Easysearch, but neither connector is changed or tested in this PR. Could you confirm those statements against the current code, or drop them?
  • Priority: P2 — optional
  • I traced this in the code.
  • When it happens: Open the two files side by side at the dev section. The en entry has six sub-bullets, including JDBC auto-create limitation. The zh entry has five sub-bullets followed by a detached paragraph at line 16.

Issue 8: The new format override in StarRocks SinkConfig is uncommented, misleadingly named, and can fail with a bare enum error that names no config key.

  • Location: seatunnel-connectors-v2/connector-starrocks/src/main/java/org/apache/seatunnel/connectors/seatunnel/starrocks/config/SinkConfig.java:100
  • Why it matters: SinkConfig.of now re-reads format from the starrocks.config map after config.get(StarRocksSinkOptions.LOAD_FORMAT) and overrides loadFormat through StreamLoadFormat.valueOf(...).
  • The variable is called legacyFormat, yet starrocks.config { format = ... } is the form the sink docs and the new fail-fast error message tell users to set.
  • There is no comment saying which case this covers that the starrocks.config.format option lookup on line 99 does not, or that the map value wins when both are present. I assume it is for configs where the nested block is not resolved by the dotted option key; please state it.
  • StreamLoadFormat.valueOf(...) on an unsupported value throws a bare No enum constant ... IllegalArgumentException. It does not mention starrocks.config.format or the accepted values (CSV, JSON).

Suggested fix: add a short comment on the purpose and precedence, rename the variable to something neutral such as streamLoadFormat, and wrap the valueOf failure in an error that names the config key and the accepted values.

  • Evidence: seatunnel-connectors-v2/connector-starrocks/src/main/java/org/apache/seatunnel/connectors/seatunnel/starrocks/config/SinkConfig.java:103 StreamLoadFormat.valueOf(
  • Suggested fix: Could you add a comment explaining which case this second lookup covers that config.get(StarRocksSinkOptions.LOAD_FORMAT) on the line above does not, and which one wins? legacyFormat is a confusing name, since starrocks.config { format = ... } is the documented way to set it. Also, StreamLoadFormat.valueOf(...) on an unsupported value throws a bare No enum constant error; please wrap it in an error that names starrocks.config.format and the accepted values (CSV, JSON).
  • Priority: P2 — optional
  • I traced this in the code.
  • When it happens: Build the config so that starrocks.config is one flat key, for example ReadonlyConfig.fromMap with "starrocks.config" -> {"format": "parquet"} (a quoted key in a JSON job file is expected to produce the same shape, not verified here). SinkConfig.of(config) throws IllegalArgumentException: No enum constant org.apache.seatunnel.connectors.seatunnel.starrocks.config.SinkConfig.StreamLoadFormat.PARQUET. The message does not mention starrocks.config.format. At the merge base the same input left loadFormat at the default JSON and did not throw.

Review conclusion

Conclusion: can merge after the blocking items are fixed

1. Blocking items

  • Issue 1: Doris JSON/JSONB and Snowflake VARIANT source columns switch from STRING to JSON by default, and the StarRocks catalog mapping has no opt-out.

2. Remaining follow-ups

  • Issue 2: The JSON format and StarRocks JSON Stream Load re-parse the document without USE_BIG_DECIMAL_FOR_FLOATS and re-serialize the tree, so high-precision fractional numbers are silently rounded to double.
  • Issue 3: Invalid-JSON failures do not name the field, and the payload slot of jsonOperationError is filled with a fixed phrase, so the bad record is hard to locate.
  • Issue 4: JSON-format sinks silently change their output for these columns (nested value instead of escaped string, key omitted for SQL NULL), and the incompatible-changes entry does not mention it.
  • Issue 5: validateUserDefinedQuery is a substring match driven by the upstream schema: it rejects valid custom queries with no override and accepts ones that do not wrap the JSON placeholder.
  • Issue 6: The StarRocks sink doc says CSV is the default Stream Load format, but the code default for starrocks.config.format is JSON.
  • Issue 7: The incompatible-changes entry differs in structure between en and zh, and its Databend/Easysearch statements have no code or test in this PR behind them.
  • Issue 8: The new format override in StarRocks SinkConfig is uncommented, misleadingly named, and can fail with a bare enum error that names no config key.

Thanks for the updates so far. Happy to discuss the remaining points.

@DanielLeens DanielLeens left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks, @SEZ9. The TEXT follow-up does resolve the old null-record assertion. I rechecked the complete Apache SeaTunnel type, connector, format and engine-adapter patch. I agree with the remaining release-compatibility, precision and custom-query blockers in your current review.

What problem does this PR solve?

User pain. Native database JSON and VARIANT columns travel as generic strings, so sinks and formats cannot tell an embedded JSON value from ordinary text.

Fix. Add a String-backed JSON logical type and handle its distinct serialization and database binding in supported paths.

Example. A JSON object can be emitted as a nested document in JSON output and parsed as a Snowflake VARIANT through generated SQL.

1. Code changes

1.1 Core logic

Previously, the format writer used textNode((String) value) for these source fields. The new logical type drives a JSON tree read at seatunnel-formats/seatunnel-format-json/src/main/java/org/apache/seatunnel/format/json/RowToJsonConverters.java:193. The source schema and the actual Java String representation are separate contracts.

Connector discovers schema -> maps native JSON/VARIANT or legacy STRING
 -> SeaTunnelRow carries the document as String with JSON logical type
 -> schema-aware formats and transforms choose the JSON branch
 -> Avro/CSV/TEXT or Spark adapters preserve text where applicable
 -> JSON format and StarRocks JSON load parse nested values
 -> Doris uses the text representation expected by the native loader
 -> generated Snowflake write binds the text through PARSE_JSON
 -> output distinguishes JSON null and SQL NULL according to each format

The new mapping is reached through normal Doris and Snowflake source discovery. Legacy opt-outs exist for those sources and default to false. StarRocks catalog inference is also affected. StarRocks CSV rejection is performed by sink initialization. Snowflake attempts custom-query validation before writing, but the check has no per-parameter semantics.

1.2 Compatibility

Partially incompatible. Existing configs can infer JSON instead of STRING and JSON-format output can move from escaped text to nested values, with omitted SQL-NULL keys. Retain the historical source mapping by default for one release or require a deliberate migration, including StarRocks catalog inference. Document the JSON output changes and test consumers that still expect STRING.

1.3 Performance and side effects

JSON output now parses and writes nested trees. This adds per-value allocation and CPU, while String-backed adapters do not need extra round trips. Preserve decimal accuracy regardless of output path. Unsupported types and invalid values must fail before irreversible writes where possible.

1.4 Errors, logging, and findings

+1 to @SEZ9's current findings.

  • Issues 1 and 4: seatunnel-connectors-v2/connector-doris/src/main/java/org/apache/seatunnel/connectors/doris/config/DorisSourceOptions.java:105 and the Snowflake option default expose the new schema on existing jobs. At seatunnel-formats/seatunnel-format-json/src/main/java/org/apache/seatunnel/format/json/RowToJsonConverters.java:311, a SQL-NULL logical JSON field loses its output key. Existing consumers encounter both schema and wire-shape changes. Preserve a legacy default or ship the documented opt-out with a complete migration procedure and output contract.
  • Issue 2: seatunnel-formats/seatunnel-format-json/src/main/java/org/apache/seatunnel/format/json/RowToJsonConverters.java:201 and seatunnel-connectors-v2/connector-starrocks/src/main/java/org/apache/seatunnel/connectors/seatunnel/starrocks/serialize/StarRocksJsonSerializer.java:43 use serialization-side Jackson mappers without exact fractional-number parsing. A high-precision decimal in a document can be rounded silently even though the source representation preserved its value. Use exact number parsing or preserve validated text and verify both sinks.
  • Issue 5: seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/internal/dialect/snowflake/SnowflakeDialect.java:140 accepts any query with a PARSE_JSON substring and rejects every other query with an upstream JSON field. It can miss unwrapped binds and reject deliberate text targets. Use actual bind/target semantics or restrict the automatic contract to generated SQL.
  • Issues 3 and 6–8: add field context without raw payload in errors, reconcile the StarRocks format option and defaults in both languages, and scope migration claims to verified implementations.

The revised TEXT test closes the earlier empty-record dereference. Native storage/read-back remains important: verify actual Doris JSON and Snowflake VARIANT type and contents, beyond successful submission or text-equivalent output.

2. Code quality

2.1 Conventions

The new logical type is reflected in the changed switch paths. Improve the StarRocks load-format override documentation and validation wording so operators can identify the setting that failed.

2.2 Test coverage and stability

Stability: Stable for the corrected TEXT test. TextFormatSchemaTest.java:187 keeps a populated field while testing SQL NULL and asserts the empty-record behavior separately. The JSON serializer tests should add high-precision fractional values. Keep the Doris/LocalFile checks and native storage read-back as acceptance evidence. The fork Build currently fails in Ubuntu JDK 11 unit tests.

2.3 Documentation

Update the English and Chinese migration notes together. State JSON nested output versus legacy strings, SQL NULL versus JSON null, available source opt-outs, and the custom-query and CSV restrictions. Keep StarRocks examples aligned to the actual option defaults.

3. Architecture

3.1 Change location

A logical JSON type is the right long-term direction. Make native document precision and representation explicit across engine and connector boundaries.

3.2 Maintainability

Keep generic validation and exact JSON parsing reusable. Avoid guessing database query correctness from a substring.

3.3 Extensibility

Add new native JSON mappings behind clear compatibility and capability tests, so downstream sinks can opt into the type safely.

3.4 Upgrade impact

Existing JSON documents are still represented as String values. Set handle_json_as_string where supported before upgrading a dependent legacy pipeline. StarRocks catalog consumers need an equivalent strategy or an explicit schema.

4. Findings summary

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

5. Merge recommendation

Ready to merge after fixes

Blocking items: Address @SEZ9's default-mapping, fractional precision, wire compatibility and Snowflake custom-query blockers. Prove native storage and exact-head format/connector validation. Resolve the currently reported dev conflicts.

Non-blocking suggestions: Keep the fixture corrections and improve field-level failures without exposing documents.

The exact-head fork Build failed in the Ubuntu JDK 11 all-module unit stage. There is no Apache rollup for this head. The IRIS image refresh already matches current dev via #13285, so that change does not explain this lane. An independent maintainer still needs to review the resulting non-conflicting head.

CI and repository state: no check reported in the Apache rollup; Build: failure. GitHub reports DIRTY / REVIEW_REQUIRED.

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

@DanielLeens DanielLeens left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Sorry that my previous review implied the JSON input mapper always enabled exact decimal parsing; it does so only when a DECIMAL schema field is reachable. That was a carryover omission, and the expanded evidence below belongs to the existing precision concern rather than a newly introduced defect. Thanks for the native Doris/StarRocks and format coverage: I re-read the complete current patch and consolidated the remaining merge bar here.

What problem does this PR solve?

Native Snowflake VARIANT, Doris JSON/JSONB and StarRocks JSON otherwise lose their logical document identity as ordinary STRING. This PR adds a String-backed JSON type across supported readers, formats, transforms and database writers. Example: JSON output can write payload as a nested object instead of an escaped document string; legacy pipelines can cast or use the documented source opt-out.

1. Code changes

1.1 Core logic

Complete runtime path:

Source/catalog inference or declared schema -> SqlType.JSON / BasicType.JSON_TYPE (physical String)
 -> optional Doris/JDBC legacy projection copies metadata and exposes STRING
 -> JDBC getString / Arrow text -> SeaTunnelRow
 -> Copy/JsonPath/Calcite project or explicit CAST -> schema-aware downstream
 -> JSON format parses tree / Avro, CSV, Text carry strings / Spark UTF8String adapter
 -> Doris JSON load validates then re-encodes document string for native parser
 -> StarRocks initialization rejects CSV+JSON; JSON loader parses structured nodes
 -> Snowflake generated INSERT SELECT and UPDATE wrap JSON binds with PARSE_JSON
 -> Qdrant rejects JSON explicitly; unsupported generic JDBC auto-create needs cast
JSON input -> JsonDeserializationSchema mapper -> JsonToRowConverters JSON node.toString
 -> precision may already be lost unless a DECIMAL type enabled exact parsing

Key findings and correctness:

  1. All 114 changed files were covered, including the new native/format/transform IT configurations. SqlType.JSON is appended, preserving prior enum ordinals. Java physical representation remains String; declaration parsing and array are added without a new object wrapper. Existing actual engine row serialization uses that physical value contract.
  2. Normal inferred Doris/Snowflake paths adopt JSON by default; opt-out is defined as an Option and wired through factory validation, runtime schema and JDBC dry-run. LegacyJsonTypeUtil preserves keys, metadata schema, partitions/options/comments; JdbcSourceTable copy preserves its split metadata. StarRocks source is declared-schema based, distinct from catalog inference.
  3. String-backed Avro/CSV/Text and Spark mappings are coherent in the inspected paths. Top-level CSV JSON arrays now quote the whole complex field. Calcite projection tests preserve logical JSON; explicit VARCHAR cast tests remove it while keeping the text.
  4. Native Doris transport deliberately validates with the JSON converter then restores the original document string to avoid native scalar coercion. The IT now compares all JSON value categories separately, not merely text formatting. StarRocks catalog probes information_schema because its MySQL metadata may disguise JSON as text; native catalog and Stream Load tests are added.
  5. The existing precision and Snowflake query-validation blockers remain. I also correct my previous implication that JSON input is always exact: JsonDeserializationSchema only enables USE_BIG_DECIMAL_FOR_FLOATS when hasDecimalType finds DECIMAL, not JSON. A payload-only JSON schema can therefore round a fraction on input before JsonToRowConverters returns its String.

Before:

case STRING: return mapper.getNodeFactory().textNode((String) value);

After:

case JSON:
    return mapper.reader()
        .with(DeserializationFeature.FAIL_ON_TRAILING_TOKENS)
        .readTree((String) value);
// Exact fractional-number parsing is still missing here.

Current exact-head Build 44883059664 is queued. This supersedes the earlier failed unit-test head I cited; its result is not acceptance of this commit. I did not retrigger workflows, change the contributor branch or run local tests. The source/compatibility blockers remain independent of the eventual CI outcome.

1.2 Compatibility

Partially incompatible. Doris/Snowflake inference and StarRocks catalog mapping change STRING to JSON by default; existing native destinations do not imply generic JDBC auto-create support. handle_json_as_string=true on supported sources or CAST(... AS VARCHAR) restores the legacy schema/value path. JSON-format output also changes escaped documents to nested values and omits SQL-null JSON keys; that wire shape needs explicit bilingual migration guidance. Enum append preserves old ordinals but old binaries do not understand the new enum constant. Supported native mappings are scoped, not a guarantee that every connector accepts JSON.

1.3 Performance and side effects

Parsing documents into Jackson trees adds per-value CPU, allocation and GC; Doris parses for validation then encodes original text, while Avro/CSV/Text retain text. StarRocks adds one native metadata query per catalog lookup with try-with-resources. No unbounded queue, new thread, checkpoint cadence or retry policy is added. Default mapper causes can expose raw malformed documents and omit field identity; use safe contextual diagnostics as described in the peer findings. No throughput, native database acceptance or recovery claim is inferred from source inspection.

1.4 Errors, logging, and findings

Issue 1: Document the native catalog probe boundary

  • Location: seatunnel-connectors-v2/connector-starrocks/src/main/java/org/apache/seatunnel/connectors/seatunnel/starrocks/catalog/StarRocksCatalog.java:394.
  • Description and risk: The new getNativeColumnTypes core helper adds a metadata round trip for every catalog table, normalizes names and makes JSON inference depend on native information_schema results, but has no method contract comment explaining why ResultSetMetaData is insufficient, what names/namespace it expects, or how missing metadata and SQL failure should behave. This is a source review delivery requirement, not a claim of a reproduced permission failure.
  • Best improvement: Add a concise method contract covering native-JSON disambiguation, table/schema and case normalization, absence fallback vs propagated query failure, and resource ownership. Keep the correction in the StarRocks catalog.
  • Responsibility and trade-off: The affected component owns this behavior. Keep the smallest complete correction there; a wider engine or connector redesign is not justified by this diff.
  • Severity: Medium; blocking: true.
  • Previously raised by another reviewer: No, unless explicitly attributed above.

Issue 2: Replace the constructor-only positive acceptance test

  • Location: seatunnel-connectors-v2/connector-starrocks/src/test/java/org/apache/seatunnel/connectors/seatunnel/starrocks/sink/StarRocksSinkTest.java:81.
  • Description and risk: The new positive test only uses assertDoesNotThrow around new StarRocksSink. It observes neither the selected serializer/load format nor an actual JSON value. The native IT is useful complementary coverage, but this standalone case itself has no exact outcome assertion and hits the prohibited constructor/existence-only acceptance pattern. I should have flagged this carryover test-quality gap earlier.
  • Best improvement: Assert the supported public writer/serialization outcome or selected load contract and exact structured payload, preserving the negative CSV constructor regression. Consolidate into an existing meaningful test rather than adding a vacuous standalone case.
  • Responsibility and trade-off: The affected component owns this behavior. Keep the smallest complete correction there; a wider engine or connector redesign is not justified by this diff.
  • Severity: Medium; blocking: true.
  • Previously raised by another reviewer: No, unless explicitly attributed above.

I read @SEZ9's CHANGES_REQUESTED review and follow-up. +1 to SEZ9-2, the precision blocker: RowToJsonConverters and StarRocksJsonSerializer still parse fractional tokens without exact-number configuration. This extends to the JSON read boundary: JsonDeserializationSchema:86-88/:107-109 gates exact parsing on hasDecimalType:120-136, which recognizes DECIMAL and nested DECIMAL but not JSON; JsonToRowConverters:98 then serializes the already-rounded node. Fixing only output mappers is insufficient. Add exact high-precision input/output/native-loader regressions, including a JSON-only schema.

+1 to SEZ9-5, the Snowflake custom-query blocker: SnowflakeDialect:140 accepts a comment mentioning PARSE_JSON or one wrapped bind among several, and rejects a deliberate VARCHAR target or different conversion with no per-bind target evidence. The new documentation admits the heuristic; it still cannot serve as mandatory correctness validation. Prefer generated SQL for the automatic contract; make custom-query behavior explicit without claiming substring presence proves safe binding.

+1 to SEZ9-4, the missing wire migration: document escaped-string to nested-document and SQL-null key omission in both incompatible-changes pages, alongside the source opt-out. SEZ9-1 requires an explicit maintainer decision on default-false source opt-outs; this is a deliberate documented schema break, so I do not recast it as an accidental P0, but an unchanged Qdrant pipeline genuinely changes from legacy string payload to rejection. SEZ9-3/6/8 remain actionable field-safe diagnostics and StarRocks format/default documentation concerns. Initial StarRocks CSV fail-fast and native Doris invalid-document/read-back coverage are now present; please do not reopen those as if absent. No independent maintainer approval supersedes the recorded change request.

2. Code quality

2.1 Conventions

Reviewed all changed files for license, imports, naming, core-method and state-field comments. See the numbered findings for the required changes.

2.2 Test coverage and stability

Stability rating: Stable. Stable for the inspected deterministic structures; remaining coverage gaps are stated explicitly. Type/schema/format UTs assert exact values and logical types, and malformed/trailing JSON fails. TEXT retains an ID field for the SQL-null case and separately checks empty records. Doris replaces raw JSON-string comparisons with structural equality plus required object/array/scalar/JSON-null/SQL-null categories and complete row cardinality; this is justified semantic coverage, not simply deleting those columns. LocalFile recreates its fixture directories with checked exit status; Kafka uses per-container topics and exact decoded records; StarRocks reads real JSON values and tests CSV rejection at initialization. Shared test resources use the existing sequential fixture model; no new hardcoded host port is introduced. High-precision fractions are absent from current document tests, Snowflake has no native storage/read-back IT here, and the positive StarRocks constructor test has no result assertion (Issue 2). Existing Calcite test engines close after assertions rather than finally; improve that cleanup when editing those fixtures. No local test/build/runtime was executed.

2.3 Documentation

English/Chinese type/connector guides describe physical String, validation boundaries, legacy opt-outs and generated Snowflake SQL. The Snowflake page now honestly calls the substring check a heuristic, which does not correct its false rejection/acceptance behavior. Both StarRocks sink pages still incorrectly call CSV the default; actual LOAD_FORMAT default is JSON. Migration notes still omit the exact nested-output/key-omission change and include Databend/Easysearch claims that must be substantiated from their actual type/value paths. Keep both languages consistent and scope claims to verified adapters.

3. Architecture

3.1 Change location

The affected component owns this behavior. Keep the smallest complete correction there; a wider engine or connector redesign is not justified by this diff.

3.2 Maintainability

Keep the behavior, lifecycle ownership, and failure contract together. The affected component owns this behavior. Keep the smallest complete correction there; a wider engine or connector redesign is not justified by this diff.

3.3 Extensibility

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

3.4 Upgrade impact

Partially incompatible. Doris/Snowflake inference and StarRocks catalog mapping change STRING to JSON by default; existing native destinations do not imply generic JDBC auto-create support. handle_json_as_string=true on supported sources or CAST(... AS VARCHAR) restores the legacy schema/value path. JSON-format output also changes escaped documents to nested values and omits SQL-null JSON keys; that wire shape needs explicit bilingual migration guidance. Enum append preserves old ordinals but old binaries do not understand the new enum constant. Supported native mappings are scoped, not a guarantee that every connector accepts JSON.

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
1 Document the native catalog probe boundary seatunnel-connectors-v2/connector-starrocks/src/main/java/org/apache/seatunnel/connectors/seatunnel/starrocks/catalog/StarRocksCatalog.java:394 Medium
2 Replace the constructor-only positive acceptance test seatunnel-connectors-v2/connector-starrocks/src/test/java/org/apache/seatunnel/connectors/seatunnel/starrocks/sink/StarRocksSinkTest.java:81 Medium

5. Merge recommendation

Merge after fixes

Blocking items: Issues 1, 2 and peer findings SEZ9-2 (precision), SEZ9-4 (wire migration), SEZ9-5 (custom-query contract), plus the explicit default-mapping decision and contextual diagnostics. Current-head CI and write-capable maintainer review remain independent requirements.

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

Overall: the approach addresses a real path, but the listed blockers must be closed. Daniel has READ permission, so this COMMENT cannot dismiss historical requested changes or satisfy a write-capable maintainer approval gate.

CI and repository state: no check reported in the Apache rollup; Build: queued. GitHub reports BLOCKED / REVIEW_REQUIRED.

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

Review time: 2026-11-21T08:20:54.212441-05:00

Local evidence: git fetch obtained head eda4d24acaa931e6275b725f6c80da67b75a112c; git merge-base returned c8e7a262897f341361094f158ffd4f60ae466b80; git diff --stat reports 114 files changed, 2835 insertions(+), 69 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.

@SEZ9 SEZ9 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for the follow-up. I checked the latest changes at eda4d24acaa9 against my previous review comments.

The scope of this pass is limited to the findings from the previous review; it does not introduce a new set of review items.

What this PR fixes

The PR adds a String-backed JSON logical type and maps Doris JSON/JSONB, Snowflake VARIANT and StarRocks JSON columns to it. The JSON format, the StarRocks JSON Stream Load serializer and the Snowflake dialect then write the value as a document instead of an escaped string. The remaining concerns fall into four groups:

  • The new mapping is on by default.
  • Two write paths re-serialize a parsed tree and can change numeric values.
  • The JSON-format output shape changes without being documented.
  • Several error messages, checks and doc statements do not match what the code does.

Runtime chain I rechecked

1. Source schema: `AbstractDorisTypeConverter`, `SnowflakeTypeConverter` and `StarRocksCatalog.fromJdbcType` return `BasicType.JSON_TYPE`. `handle_json_as_string` (default `false`) on the Doris and Jdbc sources maps the columns back to `STRING`.
2. Sink creation: the `JdbcSink` constructor calls `dialect.validateUserDefinedQuery(...)`, and the `StarRocksSink` constructor calls `validateJsonColumnsAgainstLoadFormat(...)`, which only throws when `SinkConfig.getLoadFormat()` is `CSV`.
3. Row write, JSON format: the `case JSON` converter in `RowToJsonConverters` calls `mapper.reader().with(FAIL_ON_TRAILING_TOKENS).readTree((String) value)` and returns the tree. The row converter removes the key when a JSON field is null.
4. Row write, StarRocks: `StarRocksJsonSerializer.serialize` calls `readJsonValue`, puts the resulting `JsonNode` into the row map, and serializes the map with `JsonUtils.toJsonString(rowMap)`.

Previous findings still requiring follow-up

Issue 1: PR11493-F1: Doris JSON/JSONB and Snowflake VARIANT source columns switch from STRING to JSON by default, and the StarRocks catalog mapping has no opt-out.

  • Location: seatunnel-connectors-v2/connector-doris/src/main/java/org/apache/seatunnel/connectors/doris/config/DorisSourceOptions.java:108
  • Why it matters: Root cause: both handle_json_as_string options (DorisSourceOptions and JdbcSourceOptions) default to false, while AbstractDorisTypeConverter, SnowflakeTypeConverter and StarRocksCatalog.fromJdbcType now return BasicType.JSON_TYPE for columns that used to be STRING.
  • An unchanged job config therefore gets a different source schema on upgrade.
  • A sink without a JSON branch fails or degrades. The incompatible-changes entry itself lists Qdrant rejecting the field and the generic MySQL/PostgreSQL JDBC auto-create not mapping the type.
  • StarRocksCatalog returns JSON_TYPE unconditionally. The entry says the StarRocks source uses the user-declared schema, but the catalog and automatic table creation have no switch.

Our compatibility rule asks that defaults are not changed casually. Documenting the break is necessary, but the safer rollout is to make the new type opt-in first.

Suggested fix: default handle_json_as_string to true for one release (or introduce the type behind an explicit enable option) and flip it later with a deprecation note. Give the StarRocks catalog path the same switch, or state clearly in the entry why none is needed.

  • Evidence: seatunnel-connectors-v2/connector-doris/src/main/java/org/apache/seatunnel/connectors/doris/datatype/AbstractDorisTypeConverter.java:198 builder.dataType(BasicType.JSON_TYPE);; seatunnel-connectors-v2/connector-starrocks/src/main/java/org/apache/seatunnel/connectors/seatunnel/starrocks/catalog/StarRocksCatalog.java:326 return BasicType.JSON_TYPE;; docs/en/introduction/concepts/incompatible-changes.md:15 - **Opt-out**: Set handle_json_as_string = trueon the Doris source or on the Jdbc source (SnowflakeVARIANT) to keep exposing these columns as STRING, exactly as before this change.
  • Suggested fix: With defaultValue(false) here (and on the Jdbc option), an unchanged Doris/Snowflake job gets JSON instead of STRING after upgrade, and any sink without a JSON branch fails or degrades. Could we default this to true for one release so the new type is opt-in, and flip it later with a deprecation note? Also note that the StarRocksCatalog mapping change has no equivalent switch.
  • Priority: P0 — must fix before merge
  • I traced this in the code.
  • When it happens: Take an existing job with a Doris source reading a table that has a JSON or JSONB column, a Qdrant sink using that column as a payload field, and no handle_json_as_string in the config. Before this PR the column is STRING and Qdrant writes it via ValueFactory.value(value.toString()). At this head the column is JSON and QdrantBatchWriter.buildPayload throws QdrantConnectorException (UNSUPPORTED_DATA_TYPE). The same unchanged config with a Jdbc Snowflake source and a VARIANT column also yields JSON instead of STRING.

Issue 2: PR11493-F2: The JSON format and StarRocks JSON Stream Load re-parse the document without USE_BIG_DECIMAL_FOR_FLOATS and re-serialize the tree, so high-precision fractional numbers are silently rounded to double.

  • Location: seatunnel-formats/seatunnel-format-json/src/main/java/org/apache/seatunnel/format/json/RowToJsonConverters.java:201
  • Why it matters: Root cause: both new JSON write paths turn the String-backed value into a Jackson tree and write the tree, not the original text.
  • RowToJsonConverters parses with the mapper it is given. JsonSerializationSchema configures its mapper with WRITE_BIGDECIMAL_AS_PLAIN but never enables USE_BIG_DECIMAL_FOR_FLOATS.
  • StarRocksJsonSerializer uses a bare new ObjectMapper() and then serializes the row map with JsonUtils.toJsonString(rowMap).
  • Without that feature Jackson reads every fractional number as a DoubleNode.
  • The read side is not symmetric: JsonDeserializationSchema can enable USE_BIG_DECIMAL_FOR_FLOATS (lines 87 and 108), while the write side never does.

Impact: a document such as {"amount":12345678901234567890.123456789} is written back with its low digits lost. There is no error, so the corruption is silent, and it affects exactly the columns this PR promotes to native JSON.

Suggested fix: add .with(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS) to both readers, and check that the output keeps the digits. Alternatively, validate the text and emit the original text as raw JSON instead of the re-serialized tree. Please add a unit test with a fractional number beyond double precision for both paths.

  • Evidence: seatunnel-formats/seatunnel-format-json/src/main/java/org/apache/seatunnel/format/json/RowToJsonConverters.java:201 .readTree((String) value);; seatunnel-connectors-v2/connector-starrocks/src/main/java/org/apache/seatunnel/connectors/seatunnel/starrocks/serialize/StarRocksJsonSerializer.java:43 private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();; seatunnel-connectors-v2/connector-starrocks/src/main/java/org/apache/seatunnel/connectors/seatunnel/starrocks/serialize/StarRocksJsonSerializer.java:101 .readTree(value);
  • Suggested fix: This readTree runs on the serialization mapper, which does not enable USE_BIG_DECIMAL_FOR_FLOATS, so every fractional number in the document becomes a DoubleNode and is written back rounded. For example {"amount":12345678901234567890.123456789} loses its low digits with no error. JsonDeserializationSchema can enable that feature on the read side, so the two directions are not symmetric. Please add .with(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS) here and in StarRocksJsonSerializer.readJsonValue (or emit the validated original text as raw JSON), and add a test with a number beyond double precision.
  • Priority: P1 — should fix in this PR
  • I traced this in the code.
  • When it happens: Use a row type {payload: JSON} with the field value {"rate":0.1234567890123456789}. Serialize it with new JsonSerializationSchema(rowType).serialize(row) (Kafka or File JSON format), or with new StarRocksJsonSerializer(rowType, false).serialize(row). The output is {"payload":{"rate":0.12345678901234568}}. With {"amount":12345678901234567890.123456789} the output is 1.2345678901234567E19. No exception or warning is raised.

Issue 3: PR11493-F7: Invalid-JSON failures do not name the field, and the payload slot of jsonOperationError is filled with a fixed phrase, so the bad record is hard to locate.

  • Location: seatunnel-connectors-v2/connector-starrocks/src/main/java/org/apache/seatunnel/connectors/seatunnel/starrocks/serialize/StarRocksJsonSerializer.java:67
  • Why it matters: Root cause: readJsonValue parses the row value from a String, and the catch block passes the exception straight into CommonError.jsonOperationError("StarRocks", "invalid JSON value", e). RowToJsonConverters does the same with "Common".
  • JSON_OPERATION_FAILED renders as <identifier> JSON convert/parse '<payload>' operation failed., so the top-level message is always StarRocks JSON convert/parse 'invalid JSON value' operation failed. (or the Common variant), with no column name.
  • The only locating information is whatever Jackson puts in the cause, and that does not include the column or table.
  • In StarRocksJsonSerializer the field name is available at the throw site through seaTunnelRowType.getFieldName(i). In RowToJsonConverters the row converter has fieldNames[i], but the case JSON converter does not.

Impact: a malformed document fails the job, and the operator cannot tell which column caused it from the message. Our error-handling rule asks for exceptions to carry enough context (table, task, config key).

Suggested fix: put the field name into the message in both places. In the JSON format, catch and rethrow in createRowConverter, or pass the field name down to the converter. If you want content in the message, use a length-capped excerpt rather than the full value, since the document may contain sensitive data.

  • Evidence: seatunnel-formats/seatunnel-format-json/src/main/java/org/apache/seatunnel/format/json/RowToJsonConverters.java:207 throw CommonError.jsonOperationError("Common", "invalid JSON value", e);; seatunnel-connectors-v2/connector-starrocks/src/main/java/org/apache/seatunnel/connectors/seatunnel/starrocks/serialize/StarRocksJsonSerializer.java:43 private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
  • Suggested fix: jsonOperationError renders its second argument as the offending payload, so this produces StarRocks JSON convert/parse 'invalid JSON value' operation failed. with no column name. A malformed document fails the job, so the operator needs to be able to find it. Please include seaTunnelRowType.getFieldName(i) here (and, if you want content in the message, a length-capped excerpt rather than the full value). The same applies to the "Common" throw in RowToJsonConverters, where the field name is only known in the row converter.
  • Priority: P1 — should fix in this PR
  • I traced this in the code.
  • When it happens: StarRocks sink with starrocks.config.format = JSON and a row type with two JSON-typed fields a and b. Send a row where a = "{}" and b = "{bad". StarRocksJsonSerializer.serialize throws a SeaTunnelRuntimeException with COMMON-02 and the text StarRocks JSON convert/parse 'invalid JSON value' operation failed.. Neither a nor b appears in the SeaTunnel message, so the failing column is not identified.

Issue 4: PR11493-F4: JSON-format sinks silently change their output for these columns (nested value instead of escaped string, key omitted for SQL NULL), and the incompatible-changes entry does not mention it.

  • Location: seatunnel-formats/seatunnel-format-json/src/main/java/org/apache/seatunnel/format/json/RowToJsonConverters.java:315
  • Why it matters: Root cause: the new case JSON converter in RowToJsonConverters parses the text and emits a structured node, and the row converter removes the key when a JSON field is SQL NULL.
  • A Doris JSON or Snowflake VARIANT column written through the JSON format used to go through the STRING converter, producing "payload":"{\"a\":1}", and "payload":null for NULL.
  • It now produces "payload":{"a":1}, and no payload key at all for NULL.
  • Other types still go through wrapIntoNullableConverter and emit an explicit null node, or the configured nullValue text. JSON fields skip that wrapper, so they are the only type whose key disappears, and a configured nullValue is not applied to them.
  • The incompatible-changes entry says the JSON format supports the new type, but it does not describe either output change.

Impact: downstream consumers of Kafka or file JSON output that decode the field as a string, or expect the key to be present, break without any error on the SeaTunnel side.

Suggested fix: document both changes in docs/en and docs/zh incompatible-changes.md, with before/after examples and the handle_json_as_string = true opt-out. Please also reconsider dropping the key: emitting "field":null like every other type would be less surprising. If the omission is intentional, say so in the docs and explain how it interacts with nullValue.

  • Evidence: seatunnel-formats/seatunnel-format-json/src/main/java/org/apache/seatunnel/format/json/RowToJsonConverters.java:311 if (fieldTypes[i].getSqlType() == SqlType.JSON && row.getField(i) == null) {; seatunnel-formats/seatunnel-format-json/src/main/java/org/apache/seatunnel/format/json/RowToJsonConverters.java:315 node.remove(fieldName);; docs/en/introduction/concepts/incompatible-changes.md:13 - **Impact**: Pipelines that inspect the source schema or write to a sink without JSON support can observe a different type or receive an unsupported-type error.
  • Suggested fix: node.remove(fieldName) makes JSON columns the only type whose key disappears from the record on SQL NULL; every other type emits "field":null (or the configured nullValue). Together with the new case JSON converter, an existing Doris JSON / Snowflake VARIANT to JSON-format pipeline changes from "payload":"{\"a\":1}" to "payload":{"a":1}, and from "payload":null to no key, with no error. Please document both changes in the en and zh incompatible-changes entry with before/after examples, and consider emitting an explicit null here to stay consistent with the other types.
  • Priority: P1 — should fix in this PR
  • I traced this in the code.
  • When it happens: Run Doris source (column payload JSON) to a Kafka sink with format = json and no handle_json_as_string. For a row with payload {"a":1}, the record was {"id":1,"payload":"{\"a\":1}"} before this PR and is {"id":1,"payload":{"a":1}} at this head. For a row with SQL NULL payload, the record was {"id":2,"payload":null} before and is {"id":2} at this head, with no error raised.

Issue 5: PR11493-F8: validateUserDefinedQuery is a substring match driven by the upstream schema: it rejects valid custom queries with no override and accepts ones that do not wrap the JSON placeholder.

  • Location: seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/internal/dialect/snowflake/SnowflakeDialect.java:140
  • Why it matters: The fail-fast check is query.toUpperCase(Locale.ROOT).contains(PARSE_JSON_FUNCTION), evaluated against the upstream tableSchema in the JdbcSink constructor.
  • False positive: it never looks at the target column type. A custom query that writes an upstream JSON field into a VARCHAR/TEXT column is now refused at submission. So is a query that deliberately handles the value another way, for example TO_VARIANT(?) or a stored procedure call. The method only receives the query and the schema, so there is no way to bypass it.
  • False negative: any occurrence of the text PARSE_JSON passes. A query that mentions it only in a comment or a string literal is accepted, and so is one that wraps one of several JSON placeholders.

Impact: the check blocks legitimate jobs at submission, yet it does not guarantee what its error message promises, namely that each JSON placeholder is wrapped.

Suggested fix: downgrade it to a WARN that names the JSON fields and explains the escaped-string risk, or keep the failure but add an explicit option to skip the validation. If it stays a hard failure, please document the limitation in the Jdbc sink docs.

  • Evidence: seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/internal/dialect/snowflake/SnowflakeDialect.java:137 .filter(column -> column.getDataType().getSqlType() == SqlType.JSON); seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/sink/JdbcSink.java:115 dialect.validateUserDefinedQuery(jdbcSinkConfig.getSimpleSql(), this.tableSchema);
  • Suggested fix: A substring test on the whole query, driven only by the upstream schema, fails in both directions. It refuses a legitimate custom query that writes a JSON field into a VARCHAR column or uses TO_VARIANT(?), and there is no way to override it. It also accepts a query that only mentions PARSE_JSON in a comment or wraps one of several JSON placeholders. I would downgrade this to a WARN that names the JSON fields, or keep the failure and add an option to skip the check.
  • Priority: P1 — should fix in this PR
  • I traced this in the code.
  • When it happens: Snowflake VARIANT source with default handle_json_as_string = false, so column payload arrives as JSON. Jdbc sink to Snowflake with query = "INSERT INTO t (id, payload) VALUES (?, ?)", where t.payload is VARCHAR. The JdbcSink constructor throws JdbcConnectorException Snowflake sink: the user-defined query does not apply PARSE_JSON to the JSON field(s) [payload]..., although no VARIANT column is involved. Conversely, query = "INSERT INTO t (a, b) SELECT PARSE_JSON(?), ?" with two JSON fields a and b, or a plain query containing /* PARSE_JSON */, passes the check and binds the unwrapped field as plain text.

Issue 6: PR11493-F6: The StarRocks sink doc says CSV is the default Stream Load format, but the code default for starrocks.config.format is JSON.

  • Location: docs/en/connectors/sink/StarRocks.md:243
  • Why it matters: Root cause: the new paragraph describes the fail-fast as triggering for "CSV (the default)", but StarRocksSinkOptions.LOAD_FORMAT (key starrocks.config.format) declares .defaultValue(StreamLoadFormat.JSON), and SinkConfig.of reads that option before the new format override.
  • A user who leaves the format unset gets JSON Stream Load, so validateJsonColumnsAgainstLoadFormat returns early and the check never fires for them.
  • The doc tells them the opposite: that a default config with JSON columns fails at submission and that they must set the format explicitly.
  • docs/zh/connectors/sink/StarRocks.md:238 makes the same claim.

Our docs rule requires config defaults in the docs to match the code exactly.

Suggested fix: remove "(the default)" from both pages and state that JSON is the default, so the check only applies when the format is explicitly set to CSV.

  • Evidence: seatunnel-connectors-v2/connector-starrocks/src/main/java/org/apache/seatunnel/connectors/seatunnel/starrocks/config/SinkConfig.java:100 Object legacyFormat = sinkConfig.getStreamLoadProps().get("format");; seatunnel-connectors-v2/connector-starrocks/src/main/java/org/apache/seatunnel/connectors/seatunnel/starrocks/config/SinkConfig.java:103 StreamLoadFormat.valueOf(; docs/zh/connectors/sink/StarRocks.md:238 the added paragraph carries the same "CSV (default value)" wording in Chinese
  • Suggested fix: "CSV (the default)" does not match the code: StarRocksSinkOptions.LOAD_FORMAT (starrocks.config.format) has .defaultValue(StreamLoadFormat.JSON), so with no format set the sink uses JSON Stream Load and this check never fires. Please correct the default here; the zh paragraph at docs/zh/connectors/sink/StarRocks.md:238 makes the same claim and needs the same fix.
  • Priority: P2 — optional
  • I traced this in the code.
  • When it happens: Configure a StarRocks sink with an upstream schema containing a JSON column and no format under starrocks.config. The doc says the job fails at submission and that starrocks.config.format = "JSON" must be set. In fact SinkConfig.of yields loadFormat = JSON, the constructor check returns at StarRocksSink.java:149-151, and the job runs with JSON Stream Load.

Issue 7: PR11493-F9: The incompatible-changes entry differs in structure between en and zh, and its Databend/Easysearch statements have no code or test in this PR behind them.

  • Location: docs/en/introduction/concepts/incompatible-changes.md:14
  • Why it matters: The entry now has the opt-out and migration guide, which meets our rule for documented incompatible changes. What remains is consistency and accuracy.
  • In docs/en the "JDBC auto-create limitation" is a sub-bullet of the breaking-change item (line 14). In docs/zh the same content is a detached paragraph after the migration guide (line 16), outside the bullet list and without the label. Please use the same bullet in both.
  • Line 13 says "Databend creates a STRING column and logs a warning, and Easysearch maps the field to its string type". I could not find a JSON-specific branch in the main code of connector-databend or connector-easysearch. If these sentences describe an existing fallback, please point to the code or add a test that pins the behavior. Otherwise remove them, so the page only states what is verified.
  • Evidence: docs/en/introduction/concepts/incompatible-changes.md:13 Sinks without a JSON mapping behave as follows: Qdrant rejects a JSON payload field with an unsupported-type error, Databend creates a STRING column and logs a warning, and Easysearch maps the field to its string type.; docs/zh/introduction/concepts/incompatible-changes.md:16 the JDBC auto-create limitation is added as a standalone paragraph after the migration-guide bullet instead of a sub-bullet
  • Suggested fix: Two small things on this entry. (1) Here the JDBC auto-create limitation is a sub-bullet, but in docs/zh/introduction/concepts/incompatible-changes.md:16 it is a detached paragraph after the migration guide; please make the two pages structurally identical. (2) The line above states specific behavior for Databend ("creates a STRING column and logs a warning") and Easysearch, but I could not find a JSON-specific branch in either connector. Could you point to the code or add a test that pins it, or drop those two statements?
  • Priority: P2 — optional
  • I traced this in the code.
  • When it happens: Open the two files side by side at the dev section. The en entry has six sub-bullets, including JDBC auto-create limitation. The zh entry has five sub-bullets followed by a detached paragraph at line 16.

Issue 8: PR11493-F10: The new format override in StarRocks SinkConfig is uncommented, misleadingly named, and can fail with a bare enum error that names no config key.

  • Location: seatunnel-connectors-v2/connector-starrocks/src/main/java/org/apache/seatunnel/connectors/seatunnel/starrocks/config/SinkConfig.java:100
  • Why it matters: SinkConfig.of now re-reads format from the starrocks.config map after config.get(StarRocksSinkOptions.LOAD_FORMAT) and overrides loadFormat through StreamLoadFormat.valueOf(...).
  • The variable is called legacyFormat, yet the sink doc examples set format inside starrocks.config, and the new fail-fast error message tells users to set starrocks.config.format. Nothing about this form is legacy.
  • There is no comment saying which case this covers that the starrocks.config.format option lookup on line 99 does not, or that the map value wins when both are present.
  • StreamLoadFormat.valueOf(...) throws a plain IllegalArgumentException (No enum constant ...) for an unsupported value. The message names neither the config key nor the accepted values.

Suggested fix: add a short comment explaining the case and the precedence, and rename the variable (for example propsFormat). Wrap the conversion so an invalid value fails with a connector exception that names starrocks.config.format and lists CSV/JSON.

  • Evidence: seatunnel-connectors-v2/connector-starrocks/src/main/java/org/apache/seatunnel/connectors/seatunnel/starrocks/config/SinkConfig.java:103 StreamLoadFormat.valueOf(
  • Suggested fix: Could you add a comment explaining which case this second lookup covers that config.get(StarRocksSinkOptions.LOAD_FORMAT) on the line above does not, and which one wins? legacyFormat is a confusing name, since starrocks.config { format = ... } is the documented way to set it. Also, StreamLoadFormat.valueOf(...) on an unsupported value throws a bare No enum constant error; please wrap it so the message names starrocks.config.format and lists the accepted values (CSV, JSON).
  • Priority: P2 — optional
  • I traced this in the code.
  • When it happens: Build the config so that starrocks.config is one flat key, for example ReadonlyConfig.fromMap with "starrocks.config" -> {"format": "parquet"} (a quoted key in a JSON job file is expected to produce the same shape, not verified here). SinkConfig.of(config) throws IllegalArgumentException: No enum constant org.apache.seatunnel.connectors.seatunnel.starrocks.config.SinkConfig.StreamLoadFormat.PARQUET. The message does not mention starrocks.config.format. At the merge base the same input left loadFormat at the default JSON and did not throw.

Review conclusion

Conclusion: verification is incomplete; approval is not ready

1. Blocking items

  • Issue 1: Doris JSON/JSONB and Snowflake VARIANT source columns switch from STRING to JSON by default, and the StarRocks catalog mapping has no opt-out.

2. Remaining follow-ups

  • Issue 2: The JSON format and StarRocks JSON Stream Load re-parse the document without USE_BIG_DECIMAL_FOR_FLOATS and re-serialize the tree, so high-precision fractional numbers are silently rounded to double.
  • Issue 3: Invalid-JSON failures do not name the field, and the payload slot of jsonOperationError is filled with a fixed phrase, so the bad record is hard to locate.
  • Issue 4: JSON-format sinks silently change their output for these columns (nested value instead of escaped string, key omitted for SQL NULL), and the incompatible-changes entry does not mention it.
  • Issue 5: validateUserDefinedQuery is a substring match driven by the upstream schema: it rejects valid custom queries with no override and accepts ones that do not wrap the JSON placeholder.
  • Issue 6: The StarRocks sink doc says CSV is the default Stream Load format, but the code default for starrocks.config.format is JSON.
  • Issue 7: The incompatible-changes entry differs in structure between en and zh, and its Databend/Easysearch statements have no code or test in this PR behind them.
  • Issue 8: The new format override in StarRocks SinkConfig is uncommented, misleadingly named, and can fail with a bare enum error that names no config key.

Thanks for the updates so far. Happy to discuss the remaining points.

@DanielLeens

Copy link
Copy Markdown
Contributor Author

Thanks @SEZ9 for the detailed follow-up. The head is unchanged, and my earlier compatibility/source blockers remain open; passing checks or a discussion summary cannot close them. In particular, unchanged jobs must not silently switch JSON-column types or round their numeric payloads. The next revision should reconcile your attributed points with the existing review in one implementation, including the actual serializer output and bilingual migration contract. GitHub also currently reports a merge conflict, so the author needs to resolve that against dev before the next complete review. This reply does not add a second numbered source review for the same head.

This branch has not been deployed

No deployments
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.

[Discuss] Discuss adding VARIANT SqlType for semi-structured data

4 participants