Skip to content

Commit

Permalink
[SPARK-4207][SQL] Query which has syntax like 'not like' is not worki…
Browse files Browse the repository at this point in the history
…ng in Spark SQL

Queries which has 'not like' is not working spark sql.

sql("SELECT * FROM records where value not like 'val%'")
 same query works in Spark HiveQL

Author: ravipesala <[email protected]>

Closes #3075 from ravipesala/SPARK-4207 and squashes the following commits:

35c11e7 [ravipesala] Supported 'not like' syntax in sql

(cherry picked from commit 2b6e1ce)
Signed-off-by: Michael Armbrust <[email protected]>
  • Loading branch information
ravipesala authored and marmbrus committed Nov 3, 2014
1 parent fc78289 commit 292da4e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ class SqlParser extends AbstractSparkSQLParser {
| termExpression ~ (RLIKE ~> termExpression) ^^ { case e1 ~ e2 => RLike(e1, e2) }
| termExpression ~ (REGEXP ~> termExpression) ^^ { case e1 ~ e2 => RLike(e1, e2) }
| termExpression ~ (LIKE ~> termExpression) ^^ { case e1 ~ e2 => Like(e1, e2) }
| termExpression ~ (NOT ~ LIKE ~> termExpression) ^^ { case e1 ~ e2 => Not(Like(e1, e2)) }
| termExpression ~ (IN ~ "(" ~> rep1sep(termExpression, ",")) <~ ")" ^^ {
case e1 ~ e2 => In(e1, e2)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -938,4 +938,9 @@ class SQLQuerySuite extends QueryTest with BeforeAndAfterAll {
checkAnswer(sql("SELECT key FROM testData WHERE key not between 0 and 10 order by key"),
(11 to 100).map(i => Seq(i)))
}

test("SPARK-4207 Query which has syntax like 'not like' is not working in Spark SQL") {
checkAnswer(sql("SELECT key FROM testData WHERE value not like '100%' order by key"),
(1 to 99).map(i => Seq(i)))
}
}

0 comments on commit 292da4e

Please sign in to comment.