Skip to content

Commit 9568b21

Browse files
committed
case insensitive matches
1 parent 41f633d commit 9568b21

File tree

1 file changed

+17
-5
lines changed
  • sql/hive/src/main/scala/org/apache/spark/sql/hive

1 file changed

+17
-5
lines changed

sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveQl.scala

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1561,6 +1561,10 @@ https://cwiki.apache.org/confluence/display/Hive/Enhanced+Aggregation%2C+Cube%2C
15611561
""".stripMargin)
15621562
}
15631563

1564+
/* Case insensitive matches for Window Specification */
1565+
val PRECEDING = "(?i)preceding".r
1566+
val FOLLOWING = "(?i)following".r
1567+
val CURRENT = "(?i)current".r
15641568
def nodesToWindowSpecification(nodes: Seq[ASTNode]): WindowSpec = nodes match {
15651569
case Token(windowName, Nil) :: Nil =>
15661570
// Refer to a window spec defined in the window clause.
@@ -1614,11 +1618,19 @@ https://cwiki.apache.org/confluence/display/Hive/Enhanced+Aggregation%2C+Cube%2C
16141618
} else {
16151619
val frameType = rowFrame.map(_ => RowFrame).getOrElse(RangeFrame)
16161620
def nodeToBoundary(node: Node): FrameBoundary = node match {
1617-
case Token("preceding", Token(count, Nil) :: Nil) =>
1618-
if (count == "unbounded") UnboundedPreceding else ValuePreceding(count.toInt)
1619-
case Token("following", Token(count, Nil) :: Nil) =>
1620-
if (count == "unbounded") UnboundedFollowing else ValueFollowing(count.toInt)
1621-
case Token("current", Nil) => CurrentRow
1621+
case Token(PRECEDING(), Token(count, Nil) :: Nil) =>
1622+
if (count.toLowerCase() == "unbounded") {
1623+
UnboundedPreceding
1624+
} else {
1625+
ValuePreceding(count.toInt)
1626+
}
1627+
case Token(FOLLOWING(), Token(count, Nil) :: Nil) =>
1628+
if (count.toLowerCase() == "unbounded") {
1629+
UnboundedFollowing
1630+
} else {
1631+
ValueFollowing(count.toInt)
1632+
}
1633+
case Token(CURRENT(), Nil) => CurrentRow
16221634
case _ =>
16231635
throw new NotImplementedError(
16241636
s"""No parse rules for the Window Frame Boundary based on Node ${node.getName}

0 commit comments

Comments
 (0)