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

   ### What changes were proposed in this pull request?
   This PR proposes to propagate the `isPredicate` info in 
`V2ExpressionBuilder` and wrap the children of CASE WHEN expression (only 
`Predicate`s) with `IIF(<>, 1, 0)` for MsSqlServer. This is done to force 
returning an int instead of a boolean, as SqlServer cannot handle boolean 
expressions as a return type in CASE WHEN.
   
   E.g.
   ```CASE WHEN ... ELSE a = b END```
   
   Old behavior:
   ```CASE WHEN ... ELSE a = b END = 1```
   
   New behavior:
   Since in SqlServer a `= 1` is appended to the CASE WHEN, THEN and ELSE 
blocks must return an int. Therefore the final expression becomes:
   ```CASE WHEN ... ELSE IIF(a = b, 1, 0) END = 1```
   
   ### Why are the changes needed?
   A user cannot work with an MsSqlServer data with CASE WHEN clauses or IF 
clauses if they wish to return a boolean value.
   
   ### Does this PR introduce _any_ user-facing change?
   No
   
   ### How was this patch tested?
   Added tests to MsSqlServerIntegrationSuite
   
   ### Was this patch authored or co-authored using generative AI tooling?
   No
   


-- 
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: reviews-unsubscr...@spark.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to