Repository: spark Updated Branches: refs/heads/master 8d85359f8 -> 8d210560b
[SPARK-2050 - 2][SQL] DIV and BETWEEN should not be case sensitive. Followup: #989 Author: Michael Armbrust <[email protected]> Closes #994 from marmbrus/caseSensitiveFunctions2 and squashes the following commits: 9d9c8ed [Michael Armbrust] Fix DIV and BETWEEN. Project: http://git-wip-us.apache.org/repos/asf/spark/repo Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/8d210560 Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/8d210560 Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/8d210560 Branch: refs/heads/master Commit: 8d210560be8b143e48abfbaca347f383b5aa4798 Parents: 8d85359 Author: Michael Armbrust <[email protected]> Authored: Fri Jun 6 11:31:37 2014 -0700 Committer: Michael Armbrust <[email protected]> Committed: Fri Jun 6 11:31:37 2014 -0700 ---------------------------------------------------------------------- sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveQl.scala | 6 ++++-- .../golden/between-0-570e4c4bf2968368ac2f325c6c940a06 | 1 + .../resources/golden/div-0-5e7fc5719c7265bc1d6af52005ebad03 | 1 + .../org/apache/spark/sql/hive/execution/HiveQuerySuite.scala | 6 ++++-- 4 files changed, 10 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/spark/blob/8d210560/sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveQl.scala ---------------------------------------------------------------------- diff --git a/sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveQl.scala b/sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveQl.scala index c133bf2..7e91c16 100644 --- a/sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveQl.scala +++ b/sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveQl.scala @@ -795,6 +795,8 @@ private[hive] object HiveQl { val RLIKE = "(?i)RLIKE".r val REGEXP = "(?i)REGEXP".r val IN = "(?i)IN".r + val DIV = "(?i)DIV".r + val BETWEEN = "(?i)BETWEEN".r protected def nodeToExpr(node: Node): Expression = node match { /* Attribute References */ @@ -864,7 +866,7 @@ private[hive] object HiveQl { case Token("-", left :: right:: Nil) => Subtract(nodeToExpr(left), nodeToExpr(right)) case Token("*", left :: right:: Nil) => Multiply(nodeToExpr(left), nodeToExpr(right)) case Token("/", left :: right:: Nil) => Divide(nodeToExpr(left), nodeToExpr(right)) - case Token("DIV", left :: right:: Nil) => Divide(nodeToExpr(left), nodeToExpr(right)) + case Token(DIV(), left :: right:: Nil) => Divide(nodeToExpr(left), nodeToExpr(right)) case Token("%", left :: right:: Nil) => Remainder(nodeToExpr(left), nodeToExpr(right)) /* Comparisons */ @@ -885,7 +887,7 @@ private[hive] object HiveQl { case Token("TOK_FUNCTION", Token(IN(), Nil) :: value :: list) => In(nodeToExpr(value), list.map(nodeToExpr)) case Token("TOK_FUNCTION", - Token("between", Nil) :: + Token(BETWEEN(), Nil) :: Token("KW_FALSE", Nil) :: target :: minValue :: http://git-wip-us.apache.org/repos/asf/spark/blob/8d210560/sql/hive/src/test/resources/golden/between-0-570e4c4bf2968368ac2f325c6c940a06 ---------------------------------------------------------------------- diff --git a/sql/hive/src/test/resources/golden/between-0-570e4c4bf2968368ac2f325c6c940a06 b/sql/hive/src/test/resources/golden/between-0-570e4c4bf2968368ac2f325c6c940a06 new file mode 100644 index 0000000..dcd1d86 --- /dev/null +++ b/sql/hive/src/test/resources/golden/between-0-570e4c4bf2968368ac2f325c6c940a06 @@ -0,0 +1 @@ +2 val_2 http://git-wip-us.apache.org/repos/asf/spark/blob/8d210560/sql/hive/src/test/resources/golden/div-0-5e7fc5719c7265bc1d6af52005ebad03 ---------------------------------------------------------------------- diff --git a/sql/hive/src/test/resources/golden/div-0-5e7fc5719c7265bc1d6af52005ebad03 b/sql/hive/src/test/resources/golden/div-0-5e7fc5719c7265bc1d6af52005ebad03 new file mode 100644 index 0000000..06b63ea --- /dev/null +++ b/sql/hive/src/test/resources/golden/div-0-5e7fc5719c7265bc1d6af52005ebad03 @@ -0,0 +1 @@ +0 0 0 http://git-wip-us.apache.org/repos/asf/spark/blob/8d210560/sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveQuerySuite.scala ---------------------------------------------------------------------- diff --git a/sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveQuerySuite.scala b/sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveQuerySuite.scala index 1a2b2f8..125cc18 100644 --- a/sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveQuerySuite.scala +++ b/sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveQuerySuite.scala @@ -25,8 +25,10 @@ import org.apache.spark.sql.hive.test.TestHive._ class HiveQuerySuite extends HiveComparisonTest { createQueryTest("between", - "SELECT * FROM src WHERE key between 1 and 2" - ) + "SELECT * FROM src WHERE key Between 1 and 2") + + createQueryTest("div", + "SELECT 1 DIV 2, 1 div 2, 1 dIv 2 FROM src LIMIT 1") test("Query expressed in SQL") { assert(sql("SELECT 1").collect() === Array(Seq(1)))
