yaooqinn commented on code in PR #45564:
URL: https://github.com/apache/spark/pull/45564#discussion_r1535023323
##########
sql/core/src/main/scala/org/apache/spark/sql/jdbc/MsSqlServerDialect.scala:
##########
@@ -86,6 +87,31 @@ private object MsSqlServerDialect extends JdbcDialect {
case "STDDEV_SAMP" => "STDEV"
case _ => super.dialectFunctionName(funcName)
}
+
+ override def build(expr: Expression): String = {
+ def isChildBooleanExpression(child: Expression): Boolean = child match {
+ case _: Predicate => true
+ case _ => false
+ }
+
+ // MsSqlServer does not support boolean comparison using standard
comparison operators
+ // We shouldn't propagate these queries to MsSqlServer
+ expr match {
+ case e: Predicate =>
+ e.name() match {
+ case "=" | "<>" | "<=>" | "<" | "<=" | ">" | ">=" =>
+ if (isChildBooleanExpression(e.children()(0))
+ || isChildBooleanExpression(e.children()(1))) {
+ super.visitUnexpectedExpr(expr)
+ } else {
+ super.build(expr)
+ }
+ case _ => super.build(expr)
+ }
+ case _ =>
+ super.build(expr)
+ }
+ }
Review Comment:
```suggestion
override def build(expr: Expression): String = {
// MsSqlServer does not support boolean comparison using standard
comparison operators
// We shouldn't propagate these queries to MsSqlServer
expr match {
case e: Predicate => e.name() match {
case "=" | "<>" | "<=>" | "<" | "<=" | ">" | ">="
if e.children().exists(_.isInstanceOf[Predicate]) =>
super.visitUnexpectedExpr(expr)
case _ => super.build(expr)
}
case _ => super.build(expr)
}
}
```
--
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]