diff options
author | jiangxingbo <jiangxb1987@gmail.com> | 2016-08-17 14:22:36 +0200 |
---|---|---|
committer | Herman van Hovell <hvanhovell@databricks.com> | 2016-08-17 14:22:36 +0200 |
commit | 4d0cc84afca9efd4541a2e8d583e3e0f2df37c0d (patch) | |
tree | 649db6532f26655b6cf73511112496c5adb8fa63 /sql/catalyst/src/main | |
parent | 0f6aa8afaacdf0ceca9c2c1650ca26a5c167ae69 (diff) | |
download | spark-4d0cc84afca9efd4541a2e8d583e3e0f2df37c0d.tar.gz spark-4d0cc84afca9efd4541a2e8d583e3e0f2df37c0d.tar.bz2 spark-4d0cc84afca9efd4541a2e8d583e3e0f2df37c0d.zip |
[SPARK-17032][SQL] Add test cases for methods in ParserUtils.
## What changes were proposed in this pull request?
Currently methods in `ParserUtils` are tested indirectly, we should add test cases in `ParserUtilsSuite` to verify their integrity directly.
## How was this patch tested?
New test cases in `ParserUtilsSuite`
Author: jiangxingbo <jiangxb1987@gmail.com>
Closes #14620 from jiangxb1987/parserUtils.
Diffstat (limited to 'sql/catalyst/src/main')
-rw-r--r-- | sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/parser/ParserUtils.scala | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/parser/ParserUtils.scala b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/parser/ParserUtils.scala index bc35ae2f55..cb89a9679a 100644 --- a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/parser/ParserUtils.scala +++ b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/parser/ParserUtils.scala @@ -31,11 +31,7 @@ import org.apache.spark.sql.catalyst.trees.{CurrentOrigin, Origin} object ParserUtils { /** Get the command which created the token. */ def command(ctx: ParserRuleContext): String = { - command(ctx.getStart.getInputStream) - } - - /** Get the command which created the token. */ - def command(stream: CharStream): String = { + val stream = ctx.getStart.getInputStream stream.getText(Interval.of(0, stream.size())) } @@ -74,7 +70,8 @@ object ParserUtils { /** Get the origin (line and position) of the token. */ def position(token: Token): Origin = { - Origin(Option(token.getLine), Option(token.getCharPositionInLine)) + val opt = Option(token) + Origin(opt.map(_.getLine), opt.map(_.getCharPositionInLine)) } /** Validate the condition. If it doesn't throw a parse exception. */ |