Github user liancheng commented on a diff in the pull request:
https://github.com/apache/spark/pull/2816#discussion_r18953268
--- Diff:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/SqlParser.scala ---
@@ -323,11 +373,11 @@ class SqlParser extends AbstractSparkSQLParser {
| cast
| "(" ~> expression <~ ")"
| function
- | "-" ~> literal ^^ UnaryMinus
| dotExpressionHeader
| ident ^^ UnresolvedAttribute
| "*" ^^^ Star(None)
| literal
+ | sign ~ expression ^^ { case s ~ e => if (s == "-") UnaryMinus(e)
else e }
--- End diff --
Sign should be optional. Also I think it would be better to move this rule
to the last alternative of `comparisonExpression`, namely from:
```scala
| termExpression
```
to
```scala
| sign.? ~ termExpression ^^ {
case Some("-") ~ e => UnaryMinus(e)
case _ => e
}
```
The reason is that the type of `termExpression` is guaranteed to be numeric.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]