garlandz-db opened a new pull request, #54652:
URL: https://github.com/apache/spark/pull/54652

   ### What changes were proposed in this pull request?
                                                                                
   
     Adds a new SQL state `XXSC1` ("Connect Server - Invalid Plan Input") and a 
corresponding error class
     `SPARK_CONNECT_INVALID_PLAN_INPUT` with 65 subclasses covering all 
`InvalidPlanInput` throw sites in the Spark Connect    
     layer.
                                                                                
                                               
     Files changed:                                            
     - **`error-states.json`**: New SQL state `XXSC1` — "Connect Server - 
Invalid Plan Input"
     - **`error-conditions.json`**: New top-level error class 
`SPARK_CONNECT_INVALID_PLAN_INPUT` (sqlState `XXSC1`) with
     alphabetically-sorted subclasses, one per distinct error message
     - **`InvalidInputErrors.scala`**: All methods updated from 
`InvalidPlanInput("plain string")` to
     `InvalidPlanInput("SPARK_CONNECT_INVALID_PLAN_INPUT.<SUBCLASS>", 
Map(...))`. Added `cannotFindCachedLocalRelation`
     factory.
     - **`SparkConnectPlanner.scala`**: Inline throw replaced with 
`InvalidInputErrors.cannotFindCachedLocalRelation`; unused
     `InvalidPlanInput` import removed
     - **`DataTypeProtoConverter.scala`**: 4 inline throws updated to use 
`SPARK_CONNECT_INVALID_PLAN_INPUT.*`
     - **`LiteralValueProtoConverter.scala`**: 9 inline throws updated to use 
`SPARK_CONNECT_INVALID_PLAN_INPUT.*`
     - **`SparkConnectAnalyzeHandler.scala`**: 1 inline throw updated
     - **`SessionHolder.scala`**: 1 inline throw updated
     - **`InvalidInputErrorsSuite.scala`**: Updated 2 existing assertions from 
`INTERNAL_ERROR` to new conditions; added SQL
     state (`XXSC1`) assertion for all `SPARK_CONNECT_INVALID_PLAN_INPUT` test 
cases
   
     ### Why are the changes needed?
   
     `InvalidPlanInput` exceptions in the Connect layer previously defaulted to 
the `INTERNAL_ERROR` condition (SQL state
     `XX000`), which is too broad and indistinguishable from genuine internal 
errors. This makes it harder for clients and
     monitoring systems to classify and handle plan-input validation failures. 
This PR follows the same pattern established in
     #54056 (which added `XXSC0` / `SPARK_CONNECT_ILLEGAL_STATE` for 
`IllegalStateException`).
   
     ### Does this PR introduce _any_ user-facing change?
   
     Yes. `InvalidPlanInput` exceptions thrown from the Connect layer now carry 
SQL state `XXSC1` instead of `XX000`, and have
     structured error conditions 
(`SPARK_CONNECT_INVALID_PLAN_INPUT.<SUBCLASS>`) instead of `INTERNAL_ERROR`. 
Clients that
     inspect `getSqlState()` or `getCondition()` on these exceptions will see 
the new values.
   
     ### How was this patch tested?
   
     Updated `InvalidInputErrorsSuite` to assert the new error conditions and 
verify that `getSqlState()` returns `XXSC1` for
     all affected cases. Existing `IllegalStateErrorsSuite` (17 tests) 
continues to pass with no changes.
   
     sbt "connect/testOnly 
org.apache.spark.sql.connect.planner.InvalidInputErrorsSuite"
     All 5 tests passed
   
     sbt "connect/testOnly org.apache.spark.sql.connect.IllegalStateErrorsSuite"
     All 17 tests passed
   
   
     ### Was this patch authored or co-authored using generative AI tooling?


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