Github user liancheng commented on a diff in the pull request:
https://github.com/apache/spark/pull/5087#discussion_r26751987
--- Diff: sql/core/src/main/scala/org/apache/spark/sql/jdbc/JDBCRDD.scala
---
@@ -230,13 +231,19 @@ private[sql] class JDBCRDD(
* 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 = $value"
- case LessThan(attr, value) => s"$attr < $value"
- case GreaterThan(attr, value) => s"$attr > $value"
- case LessThanOrEqual(attr, value) => s"$attr <= $value"
- case GreaterThanOrEqual(attr, value) => s"$attr >= $value"
- case _ => null
+ private def compileFilter(f: Filter): String = {
+ def compileValue(value: Any): Any = value match {
+ case stringValue: String => s"'${escapeSql(stringValue)}'"
+ case _ => value
+ }
+ 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)}"
--- End diff --
Please don't align the code vertically, this makes future changes more
difficult.
---
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]