in spark-doris-connector/spark-doris-connector-base/src/main/scala/org/apache/doris/spark/util/DorisDialects.scala [28:68]
def compileFilter(filter: Filter, inValueLengthLimit: Int): Option[String] = {
Option[String](filter match {
case EqualTo(attribute, value) => s"${quote(attribute)} = ${compileValue(value)}"
case Not(EqualTo(attribute, value)) => s"${quote(attribute)} != ${compileValue(value)}"
case GreaterThan(attribute, value) => s"${quote(attribute)} > ${compileValue(value)}"
case GreaterThanOrEqual(attribute, value) => s"${quote(attribute)} >= ${compileValue(value)}"
case LessThan(attribute, value) => s"${quote(attribute)} < ${compileValue(value)}"
case LessThanOrEqual(attribute, value) => s"${quote(attribute)} <= ${compileValue(value)}"
case In(attribute, values) =>
if (values.isEmpty || values.length >= inValueLengthLimit) {
null
} else {
s"${quote(attribute)} IN ${values.map(compileValue).mkString("(",",",")")}"
}
case Not(In(attribute, values)) =>
if (values.isEmpty || values.length >= inValueLengthLimit) {
null
} else {
s"${quote(attribute)} NOT IN ${values.map(compileValue).mkString("(",",",")")}"
}
case IsNull(attribute) => s"${quote(attribute)} IS NULL"
case IsNotNull(attribute) => s"${quote(attribute)} IS NOT NULL"
case And(left, right) =>
val and = Seq(left, right).flatMap(compileFilter(_, inValueLengthLimit))
if (and.size == 2) {
and.map(p => s"($p)").mkString(" AND ")
} else null
case Or(left, right) =>
val or = Seq(left, right).flatMap(compileFilter(_, inValueLengthLimit))
if (or.size == 2) {
or.map(p => s"($p)").mkString(" OR ")
} else null
case StringContains(attribute, value) => s"${quote(attribute)} LIKE '%$value%'"
case Not(StringContains(attribute, value)) => s"${quote(attribute)} NOT LIKE '%$value%'"
case StringEndsWith(attribute, value) => s"${quote(attribute)} LIKE '%$value'"
case Not(StringEndsWith(attribute, value)) => s"${quote(attribute)} NOT LIKE '%$value'"
case StringStartsWith(attribute, value) => s"${quote(attribute)} LIKE '$value%'"
case Not(StringStartsWith(attribute, value)) => s"${quote(attribute)} NOT LIKE '$value%'"
case _ => null
})
}