Github user HyukjinKwon commented on a diff in the pull request:

    https://github.com/apache/spark/pull/10470#discussion_r48525943
  
    --- Diff: 
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/jdbc/JDBCRDD.scala
 ---
    @@ -184,16 +185,38 @@ private[sql] object JDBCRDD extends Logging {
        * Turns a single Filter into a String representing a SQL expression.
        * Returns null for an unhandled filter.
        */
    -  private def compileFilter(f: Filter): String = f match {
    -    case EqualTo(attr, value) => s"$attr = ${compileValue(value)}"
    -    case Not(EqualTo(attr, value)) => s"$attr != ${compileValue(value)}"
    -    case LessThan(attr, value) => s"$attr < ${compileValue(value)}"
    -    case GreaterThan(attr, value) => s"$attr > ${compileValue(value)}"
    -    case LessThanOrEqual(attr, value) => s"$attr <= ${compileValue(value)}"
    -    case GreaterThanOrEqual(attr, value) => s"$attr >= 
${compileValue(value)}"
    -    case IsNull(attr) => s"$attr IS NULL"
    -    case IsNotNull(attr) => s"$attr IS NOT NULL"
    -    case _ => null
    +  private def compileFilter(f: Filter): Option[String] = {
    +    Option(f match {
    +      case EqualTo(attr, value) => s"$attr = ${compileValue(value)}"
    +      case LessThan(attr, value) => s"$attr < ${compileValue(value)}"
    +      case GreaterThan(attr, value) => s"$attr > ${compileValue(value)}"
    +      case LessThanOrEqual(attr, value) => s"$attr <= 
${compileValue(value)}"
    +      case GreaterThanOrEqual(attr, value) => s"$attr >= 
${compileValue(value)}"
    +      case IsNull(attr) => s"$attr IS NULL"
    +      case IsNotNull(attr) => s"$attr IS NOT NULL"
    +      case StringStartsWith(attr, value) => s"${attr} LIKE '${value}%'"
    +      case StringEndsWith(attr, value) => s"${attr} LIKE '%${value}'"
    +      case StringContains(attr, value) => s"${attr} LIKE '%${value}%'"
    +      case In(attr, value) => s"$attr IN (${compileValue(value)})"
    +      case Not(f) => compileFilter(f).map(p => s"(NOT 
($p))").getOrElse(null)
    +      case Or(f1, f2) =>
    +        // We can't compile Or filter unless both sub-filters are compiled 
successfully.
    +        // It applies too for the following And filter.
    +        val or = Seq(f1, f2).map(compileFilter(_)).flatten
    +        if (or.size == 2) {
    --- End diff --
    
    Does this work? I mean. It looks the `or.size` is always `2` due to `null`. 
`flatten` does not filter `null`s.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to