Github user marmbrus commented on a diff in the pull request:
https://github.com/apache/spark/pull/4685#discussion_r28740529
--- Diff:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/predicates.scala
---
@@ -290,16 +301,20 @@ case class GreaterThan(left: Expression, right:
Expression) extends BinaryCompar
case class GreaterThanOrEqual(left: Expression, right: Expression) extends
BinaryComparison {
def symbol = ">="
- lazy val ordering = {
- if (left.dataType != right.dataType) {
- throw new TreeNodeException(this,
- s"Types do not match ${left.dataType} != ${right.dataType}")
- }
- left.dataType match {
- case i: NativeType => i.ordering.asInstanceOf[Ordering[Any]]
- case other => sys.error(s"Type $other does not support ordered
operations")
+ override lazy val resolved =
+ left.resolved && right.resolved &&
+ left.dataType == right.dataType &&
+ (left.dataType.isInstanceOf[NativeType] ||
left.dataType.isInstanceOf[NullType])
+
+ val ordering =
+ if (resolved) {
+ left.dataType match {
+ case n: NativeType => n.ordering.asInstanceOf[Ordering[Any]]
+ case n: NullType => UnresolvedOrdering
+ }
+ } else {
+ UnresolvedOrdering
}
--- End diff --
Perhaps we could add helper methods to Expression for checking if things
are numeric and for finding the correct ordering / numeric types. This pattern
seems to be repeated quite a bit.
---
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]