Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,10 @@ private[sql] class JDBCRDD(
*/
private def compileFilter(f: Filter): String = f match {
case EqualTo(attr, value) => s"$attr = ${compileValue(value)}"
// Since the null-safe equality operator is not a standard SQL operator,
// This was written as using is-null and normal equality.
case EqualNullSafe(attr, value) =>
s"($attr = ${compileValue(value)} OR ($attr IS NULL AND ${compileValue(value)} IS NULL))"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could this be null if attr is null but value is not null?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for my late comment.
Yes.. it looks so. There can be a problem if the query uses the result of comparison <=>.

Let me correct this soon as (NOT ($attr <> ${compileValue(value)} OR $attr IS NULL OR ${compileValue(value)} IS NULL) OR ($attr IS NULL AND ${compileValue(value)} IS NULL)).

(BTW, I found <=> actually a standard but as IS NOT DISTINCT FROM from SQL1999 but not many DBs look supporting this)

case LessThan(attr, value) => s"$attr < ${compileValue(value)}"
case GreaterThan(attr, value) => s"$attr > ${compileValue(value)}"
case LessThanOrEqual(attr, value) => s"$attr <= ${compileValue(value)}"
Expand Down