Skip to content
Closed
Show file tree
Hide file tree
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 @@ -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 */
Expand Down Expand Up @@ -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 */
Expand All @@ -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 ::
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2 val_2
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0 0 0
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
Expand Down