stefanbuk-db commented on code in PR #45564:
URL: https://github.com/apache/spark/pull/45564#discussion_r1532150421


##########
sql/core/src/main/scala/org/apache/spark/sql/jdbc/MsSqlServerDialect.scala:
##########
@@ -86,6 +86,35 @@ private object MsSqlServerDialect extends JdbcDialect {
       case "STDDEV_SAMP" => "STDEV"
       case _ => super.dialectFunctionName(funcName)
     }
+
+    override def build(expr: Expression): String = {
+      def isChildLikeExpression(child: Expression): Boolean = child match {
+        case gse: GeneralScalarExpression =>
+          gse.name() match {
+            case "STARTS_WITH" | "ENDS_WITH" | "CONTAINS" => true
+            case _ => false
+          }
+        case _ => false
+      }
+
+      // MsSqlServer does not support boolean comparison using standard 
comparison operators
+      // LIKE operator has a boolean result, hence we don't propagate these 
queries to MsSqlServer
+      expr match {
+        case e: GeneralScalarExpression =>
+          e.name() match {
+            case "=" | "<>" | "<=>" | "<" | "<=" | ">" | ">=" =>

Review Comment:
   Problem with overwriting `visitBinaryComparison` is that it takes strings as 
parameters. This leaves us with not much information about child expressions. 
Parsing these strings could be very complex and costly, so overriding this 
function is not the best option here.



##########
sql/core/src/main/scala/org/apache/spark/sql/jdbc/MsSqlServerDialect.scala:
##########
@@ -86,6 +86,35 @@ private object MsSqlServerDialect extends JdbcDialect {
       case "STDDEV_SAMP" => "STDEV"
       case _ => super.dialectFunctionName(funcName)
     }
+
+    override def build(expr: Expression): String = {

Review Comment:
   See comment above.



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