@@ -120,7 +120,7 @@ class SqlParser extends StandardTokenParsers with PackratParsers {
120120 protected val WHERE = Keyword (" WHERE" )
121121 protected val INTERSECT = Keyword (" INTERSECT" )
122122 protected val EXCEPT = Keyword (" EXCEPT" )
123-
123+ protected val SUBSTR = Keyword ( " SUBSTR " )
124124
125125 // Use reflection to find the reserved words defined in this class.
126126 protected val reservedWords =
@@ -316,6 +316,12 @@ class SqlParser extends StandardTokenParsers with PackratParsers {
316316 IF ~> " (" ~> expression ~ " ," ~ expression ~ " ," ~ expression <~ " )" ^^ {
317317 case c ~ " ," ~ t ~ " ," ~ f => If (c,t,f)
318318 } |
319+ SUBSTR ~> " (" ~> expression ~ " ," ~ expression <~ " )" ^^ {
320+ case s ~ " ," ~ p => Substring (s,p,Literal (Integer .MAX_VALUE ))
321+ } |
322+ SUBSTR ~> " (" ~> expression ~ " ," ~ expression ~ " ," ~ expression <~ " )" ^^ {
323+ case s ~ " ," ~ p ~ " ," ~ l => Substring (s,p,l)
324+ } |
319325 ident ~ " (" ~ repsep(expression, " ," ) <~ " )" ^^ {
320326 case udfName ~ _ ~ exprs => UnresolvedFunction (udfName, exprs)
321327 }
0 commit comments