andrej-db commented on code in PR #48621:
URL: https://github.com/apache/spark/pull/48621#discussion_r1813204684


##########
sql/core/src/main/scala/org/apache/spark/sql/jdbc/MsSqlServerDialect.scala:
##########
@@ -73,6 +73,36 @@ private case class MsSqlServerDialect() extends JdbcDialect 
with NoLegacyJDBCErr
       }
     }
 
+    override def visitCaseWhen(children: Array[String]): String = {
+      // Since MsSqlServer cannot handle boolean expressions inside
+      // a CASE WHEN, it is necessary to convert those to an IIF
+      // expression that will return 1 or 0 depending on the result.
+      // Example:
+      // In:  ... CASE WHEN a = b THEN c = d ...
+      // Out: ... CASE WHEN a = b THEN IIF(c = d, 1, 0) ...

Review Comment:
   IIF is more readable. This is only for the MsSql, other dialects will have 
their own implementations.



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