CryoThrust commented on issue #13404: URL: https://github.com/apache/seatunnel/issues/13404#issuecomment-7163835470
Here is the bounded mapping and fixture matrix. This is a source/specification study, not a runtime checker or an executed MySQL-CDC → JDBC evaluation. I pinned SeaTunnel to [`113cea2a9c`](https://github.com/apache/seatunnel/commit/113cea2a9c67878dd1f21e2e57f3add0f4603a51) and ODCS to [v3.2.0](https://github.com/bitol-io/open-data-contract-standard/blob/f0bdad95346905d500be5ef4b2c2d9b1d95223b7/schema/odcs-json-schema-v3.2.0.json) (schema SHA-256 `edb41f33ec46e84780e99872ab2bd67f074959d2bf3e9c9fc54e61f8982b0d93`). The example consumer is `orders`: `tenant_id BIGINT NOT NULL`, `order_id BIGINT NOT NULL`, `amount DECIMAL(18,4) NOT NULL`, `note VARCHAR(128) NULL`, with ordered key `[tenant_id, order_id]`. ### Mapping and policy boundaries | Element | Proposed rule for this study | Source/evidence boundary | | --- | --- | --- | | Contract identity | Record ODCS `apiVersion=v3.2.0`, contract `id`, contract `version`, and SHA-256 of the exact supplied bytes separately. Same ID/version with different bytes is an explicit identity conflict, not an implicit contract update. | `apiVersion` identifies the standard; `id`/`version` identify the contract. No remote discovery or restore behavior is implemented. | | Table/column names | Use `physicalName`, falling back to `name`, and one explicit database/table binding. The first fixture policy compares names exactly, including case, without trimming or inferred renames. | `Column.name` and the sink `CatalogTable` identify physical fields. This is an explicit study policy, not a claim about MySQL's deployment-dependent identifier folding. Case-folding collisions must not silently choose a field. | | Field presence | Require every field declared in this bounded table contract to exist. A missing nullable field still fails this presence rule. | ODCS property `required` describes whether values may be null; it does **not** define optional schema presence. Presence and extra-field policies are evaluation policies, not invented ODCS fields. | | Extra fields | Evaluate both `allow-extra` and `reject-extra` policies. An added nullable field passes only under `allow-extra`. | Neither `required:false` nor nullability grants permission to add/drop schema fields. | | Nullability | For `required:true`, require `Column.nullable=false`. A non-null producer satisfies a nullable consumer. Do not infer nullability from the key flag or a default expression. | [`Column`](https://github.com/apache/seatunnel/blob/113cea2a9c67878dd1f21e2e57f3add0f4603a51/seatunnel-api/src/main/java/org/apache/seatunnel/api/table/catalog/Column.java#L42-L89) carries type, length, scale, nullable, sourceType and sinkType separately. | | Primary key | Order ODCS `primaryKey:true` fields by positive, unique `primaryKeyPosition`, then compare the list with SeaTunnel's ordered key columns. Missing/ambiguous positions or unavailable observed key metadata yield `unsupported`; a known different key yields `incompatible`. | [`PrimaryKey.columnNames`](https://github.com/apache/seatunnel/blob/113cea2a9c67878dd1f21e2e57f3add0f4603a51/seatunnel-api/src/main/java/org/apache/seatunnel/api/table/catalog/PrimaryKey.java#L29-L41). Do not infer data uniqueness from schema metadata. | | DECIMAL | Use explicit physical `DECIMAL(p,s)` plus typed `DecimalType`, with both integer capacity `p-s` and scale. If redundant metadata disagrees, report unresolved mapping rather than choose silently. | [`DecimalType`](https://github.com/apache/seatunnel/blob/113cea2a9c67878dd1f21e2e57f3add0f4603a51/seatunnel-api/src/main/java/org/apache/seatunnel/api/table/type/DecimalType.java#L58-L63). Logical `number` alone does not establish decimal precision/scale. | | Other scalar types | Begin with signed BIGINT, BOOLEAN, DATE and explicitly described VARCHAR. Check logical family and known physical capacity; character-vs-byte length, charset, unsigned range and timestamp/timezone details without adequate metadata remain `unsupported`. | `columnLength` is documented as bytes for character/binary types. It cannot automatically establish ODCS character counts or value-quality constraints. | | Nested/quality/SLA | Return `unsupported` for object/array/map/vector, value quality/uniqueness assertions, freshness and SLA in this first slice. | Do not omit unsupported obligations and report a whole-contract pass. | The schema boundary also needs two named observations: **S** is the raw source schema; **T** is the post-transform `CatalogTable` supplied to [`TableSinkFactoryContext`](https://github.com/apache/seatunnel/blob/113cea2a9c67878dd1f21e2e57f3add0f4603a51/seatunnel-api/src/main/java/org/apache/seatunnel/api/table/factory/TableSinkFactoryContext.java#L32-L43). T is the relevant input for a sink-schema decision, but it is still not proof of the eventual native DDL: [`MySqlTypeConverter`](https://github.com/apache/seatunnel/blob/113cea2a9c67878dd1f21e2e57f3add0f4603a51/seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/internal/dialect/mysql/MySqlTypeConverter.java#L451-L510) may normalize decimal precision/scale. A future DDL claim needs a separate **D** observation of the actual target definition/DDL. ### Fixture matrix — expected outcomes, not executed results For value-range compatibility against a fixed decimal consumer `(P,S)`, the producer `(p,s)` fits only when `s <= S` and `p-s <= P-S`, with no rounding. This checks **producer → consumer representability**. Exact target-schema conformity is a different rule: D must equal the declared target type; merely widening the target relative to its former schema does not establish either rule. | Fixture | Policy / observed boundary | Expected result and reason | | --- | --- | --- | | Matching `orders` definition | T, exact names/presence/key | `compatible` for the supported schema subset; not proof of value quality or pre-DDL interception. | | `amount DECIMAL(16,2)` → fixed `DECIMAL(18,4)` consumer | T, value-range compatibility | `compatible`: 14 integer digits fit 14, and scale 2 fits 4. | | `amount DECIMAL(18,2)` → same consumer | T, same rule | `incompatible`: 16 integer digits exceed 14, despite equal total precision. | | `amount DECIMAL(16,6)` → same consumer | T, same rule | `incompatible`: scale 6 exceeds 4; no implicit rounding. | | Contract says only logical `number` | T, no reliable physical decimal specification | `unsupported`: insufficient precision/scale information. | | Add `comment VARCHAR(128) NULL` | T, allow-extra / reject-extra | `compatible` / `incompatible` respectively; the policy changes the outcome. | | Remove declared `note`, though nullable | T, all declared fields present | `incompatible`: presence failure, not a null-value failure. | | Remove/rename `order_id` | T, exact names | `incompatible`: report missing `order_id`; do not infer a rename from a new column. | | `order_id` changes to nullable | T, contract `required:true` | `incompatible`; conversely a non-null `note` satisfies its nullable consumer. | | `Orders` vs `orders`, or `Order_ID` vs `order_id` | T, exact-case study policy | `incompatible` with exact names in the reason; a future explicit dialect-folding policy needs separate collision fixtures. | | Key becomes `[order_id, tenant_id]` | T, observed ordered key known | `incompatible`; absent key metadata or missing/duplicate ODCS positions is `unsupported`, not an inferred match. | | S amount `(18,2)`, transform yields T `(18,4)` | Evaluate S and T separately | S is `incompatible`; T is `compatible` under the range rule. This does not prove the transform preserves/rounds input values or D matches. | | S amount `(16,2)`, transform yields T `(18,2)` | Evaluate S and T separately | S is `compatible`; T is `incompatible`. A source-only pass would miss the sink-boundary mismatch. | | T fits, native D differs after conversion/override | T vs D | T's result is not a target-DDL pass; compare D under the explicit target rule or report `unsupported` when D is unavailable. | | Nested field, data-quality predicate or SLA present | Any schema-only observation | `unsupported` for those obligations, even if all scalar schema checks pass. | | Same contract ID/version, different exact bytes | Identity check before schema evaluation | Explicit identity conflict; do not substitute bytes silently. | Each future result should retain the standard version, contract ID/version/digest, SeaTunnel revision, table/field, policy, boundary (S/T/D), observed and expected attributes, and reason. Preserve individual findings: a known mismatch makes the aggregate `incompatible`; otherwise an unevaluated obligation makes it `unsupported`; `compatible` requires every obligation in the declared supported subset to pass. Invalid contract syntax/schema should be reported as a validation error before comparison. This completes the design-only mapping/fixture slice. No parser dependency, runtime hook, CLI invocation, database evaluation, checkpoint recovery behavior or pre-DDL guarantee has been implemented. The next evidence would be to instantiate these fixtures at T, then separately trace/evaluate D and the CDC enforcement boundary after the mapping and policy choices are accepted. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
