[SPARK-58116][SDP] Validate user-specified schema for tables fed by a named flow#57245
Open
anew wants to merge 1 commit into
Open
[SPARK-58116][SDP] Validate user-specified schema for tables fed by a named flow#57245anew wants to merge 1 commit into
anew wants to merge 1 commit into
Conversation
… named flow ### What changes were proposed in this pull request? `GraphValidations.validateUserSpecifiedSchemas` looked up a table by the incoming flow's own identifier (`table.get(f.identifier)`). That only matches when the flow is an implicit/default flow whose identifier equals its destination table's. For a named flow (e.g. `CREATE FLOW <name> AS AUTO CDC INTO <target>`, or any explicitly-named flow) the lookup returned `None`, so the table's declared schema was never validated against the inferred schema. This changes the lookup to key on `f.destinationIdentifier` (with `.distinct`, since multiple flows can share a destination), matching the sibling `validateFlowStreamingness` validation. ### Why are the changes needed? An incompatible user-declared schema on a named-flow table went undetected at graph-validation time and surfaced only as a confusing mid-stream runtime failure at materialization. ### Does this introduce _any_ user-facing change? Yes: an incompatible user-specified schema on a table fed by a named flow now fails with `USER_SPECIFIED_AND_INFERRED_SCHEMA_NOT_COMPATIBLE` at validation time, as it already did for the implicit-flow form. ### How was this patch tested? New `UserSpecifiedSchemaValidationSuite` asserts the error is raised for both the implicit- and named-flow forms; confirmed the named-flow case fails without the fix. Ran ConnectValid/Invalid, SqlPipeline, and AutoCdc pipeline suites (130 tests) green. ### Was this patch authored or co-authored using generative AI tooling? Generated-by: Claude Opus 4.8 Co-authored-by: Isaac
f686241 to
be639bc
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this pull request?
GraphValidations.validateUserSpecifiedSchemaslooked up a table by the incoming flow's own identifier (table.get(f.identifier)). That only matches when the flow is an implicit/default flow whose identifier equals its destination table's. For a named flow (e.g.CREATE FLOW <name> AS AUTO CDC INTO <target>, or any explicitly-named flow) the lookup returnedNone, so the table's declared schema was never validated against the inferred schema.This changes the lookup to key on
f.destinationIdentifier(with.distinct, since multiple flows can share a destination), matching the siblingvalidateFlowStreamingnessvalidation.Why are the changes needed?
An incompatible user-declared schema on a named-flow table went undetected at graph-validation time and surfaced only as a confusing mid-stream runtime failure at materialization.
Does this introduce any user-facing change?
Yes: an incompatible user-specified schema on a table fed by a named flow now fails with
USER_SPECIFIED_AND_INFERRED_SCHEMA_NOT_COMPATIBLEat validation time, as it already did for the implicit-flow form.How was this patch tested?
New UserSpecifiedSchemaValidationSuite covers validateUserSpecifiedSchemas across the flow-identity axis (implicit flow, where the flow identifier equals the destination table's, vs. named flow, where it differs) and the schema-compatibility axis, for both plain and AUTO CDC flows:
The named-flow cases fail without the fix (the table lookup returns None, so validation is skipped). The AUTO CDC positive cases derive the expected schema from the resolved graph's inferred schema rather than hardcoding the reserved metadata struct. Also ran ConnectValid/Invalid, SqlPipeline, and AutoCdc pipeline suites green.
Was this patch authored or co-authored using generative AI tooling?
Generated-by: Claude Opus 4.8