douglasdennis commented on code in PR #792:
URL: https://github.com/apache/sedona/pull/792#discussion_r1136510797
##########
sql/src/main/scala/org/apache/spark/sql/sedona_sql/expressions/NullSafeExpressions.scala:
##########
@@ -38,42 +38,85 @@ trait FoldableExpression extends Expression {
override def foldable: Boolean = children.forall(_.foldable)
}
-abstract class UnaryGeometryExpression extends Expression with
ExpectsInputTypes {
+trait SerdeAware {
+ def evalWithoutSerialization(input: InternalRow): Any
+}
+
+abstract class UnaryGeometryExpression extends Expression with SerdeAware with
ExpectsInputTypes {
def inputExpressions: Seq[Expression]
override def nullable: Boolean = true
override def inputTypes: Seq[AbstractDataType] = Seq(GeometryUDT)
override def eval(input: InternalRow): Any = {
- val geometry = inputExpressions.head.toGeometry(input)
+ val result = evalWithoutSerialization(input)
+ serializeResult(result)
+ }
+
+ override def evalWithoutSerialization(input: InternalRow): Any ={
+ val inputExpression = inputExpressions.head
+ val geometry = inputExpression match {
+ case expr: SerdeAware => expr.evalWithoutSerialization(input)
+ case expr: Any => expr.toGeometry(input)
+ }
Review Comment:
That seems to work great. I pulled the trait out into its own file to avoid
a circular dependency.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]