pan3793 opened a new pull request, #57593:
URL: https://github.com/apache/spark/pull/57593

   ### What changes were proposed in this pull request?
   
   1. `Analyzer.trySetAnsiValue`: replace `createSparkVersion.startsWith("4.")` 
with `VersionUtils.majorMinorPatchVersion(createSparkVersion).exists { case 
(major, _, _) => major >= 4 }`. The old check only matched the 4.x major; views 
created by Spark 5.x (ANSI still the default) wrongly fell to ANSI=false.
   2. `ViewResolver.resolve` (single-pass): forward `createSparkVersion = 
unresolvedView.desc.createVersion` to `View.effectiveSQLConf`, matching the 
fixed-point `ViewResolution.resolve`. The single-pass path silently dropped it.
   
   ### Why are the changes needed?
   
   ANSI became the default in 4.0 (SPARK-44444) and remains so in 5.x. 
`trySetAnsiValue`'s `startsWith("4.")` only recognized 4.x, so a 5.x-created 
view with no persisted ANSI value was resolved as LEGACY instead of ANSI — its 
schema-enforcement casts used the wrong eval mode.
   
   The single-pass `ViewResolver` compounded this by dropping `createVersion` 
entirely. This surfaced as a dual-run `LOGICAL_PLAN_COMPARISON_MISMATCH`: the 
two analyzers' plans differed only in `Cast.evalMode`, which `NormalizePlan` 
does not strip. On master the failing test passes only by coincidence 
(`"5.0.0"` and `""` both miss `startsWith("4.")` and both resolve to LEGACY).
   
   ### Does this PR introduce _any_ user-facing change?
   
   Bug fix. Views created by Spark 4.0+ without a persisted ANSI value are now 
resolved with ANSI=true (matching their creating version's default) in both 
analyzers. Empty/unparseable `createVersion` still maps to ANSI=false, as 
documented.
   
   ### How was this patch tested?
   
   Existing tests: `HiveSQLViewSuite`, `AlwaysPersistedConfigsSuite`, 
`SQLViewSuite`, `ViewResolverSuite`, `HybridAnalyzerSuite`.
   
   ### Was this patch authored or co-authored using generative AI tooling?
   
   Yes. Generated-by: GLM 5.2
   


-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to