Skip to content
Closed
Changes from 1 commit
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
Next Next commit
SPARK-2407: Added Parse of SQL SUBSTR()
  • Loading branch information
chutium committed Jul 16, 2014
commit 1de83a7560f85cd347bca6dde256d551da63a144
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ class SqlParser extends StandardTokenParsers with PackratParsers {
protected val WHERE = Keyword("WHERE")
protected val INTERSECT = Keyword("INTERSECT")
protected val EXCEPT = Keyword("EXCEPT")

protected val SUBSTR = Keyword("SUBSTR")

// Use reflection to find the reserved words defined in this class.
protected val reservedWords =
Expand Down Expand Up @@ -316,6 +316,12 @@ class SqlParser extends StandardTokenParsers with PackratParsers {
IF ~> "(" ~> expression ~ "," ~ expression ~ "," ~ expression <~ ")" ^^ {
case c ~ "," ~ t ~ "," ~ f => If(c,t,f)
} |
SUBSTR ~> "(" ~> expression ~ "," ~ expression <~ ")" ^^ {
case s ~ "," ~ p => Substring(s,p,Literal(Integer.MAX_VALUE))
} |
SUBSTR ~> "(" ~> expression ~ "," ~ expression ~ "," ~ expression <~ ")" ^^ {
case s ~ "," ~ p ~ "," ~ l => Substring(s,p,l)
} |
ident ~ "(" ~ repsep(expression, ",") <~ ")" ^^ {
case udfName ~ _ ~ exprs => UnresolvedFunction(udfName, exprs)
}
Expand Down