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
16 changes: 16 additions & 0 deletions sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveQl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,11 @@ private[hive] object HiveQl {
}
} catch {
case e: Exception => throw new ParseException(sql, e)
case e: NotImplementedError => sys.error(
s"""
|Unsupported language features in query: $sql
|${dumpTree(getAst(sql))}
""".stripMargin)
}
}

Expand Down Expand Up @@ -865,6 +870,17 @@ private[hive] object HiveQl {
IsNull(nodeToExpr(child))
case Token("TOK_FUNCTION", Token("IN", Nil) :: value :: list) =>
In(nodeToExpr(value), list.map(nodeToExpr))
case Token("TOK_FUNCTION",
Token("between", Nil) ::
Token("KW_FALSE", Nil) ::
target ::
minValue ::
maxValue :: Nil) =>

val targetExpression = nodeToExpr(target)
And(
GreaterThanOrEqual(targetExpression, nodeToExpr(minValue)),
LessThanOrEqual(targetExpression, nodeToExpr(maxValue)))

/* Boolean Logic */
case Token(AND(), left :: right:: Nil) => And(nodeToExpr(left), nodeToExpr(right))
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
Expand Up @@ -24,6 +24,10 @@ import org.apache.spark.sql.hive.test.TestHive._
*/
class HiveQuerySuite extends HiveComparisonTest {

createQueryTest("between",
"SELECT * FROM src WHERE key between 1 and 2"
)

test("Query expressed in SQL") {
assert(sql("SELECT 1").collect() === Array(Seq(1)))
}
Expand Down