You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sedona.apache.org by "douglasdennis (via GitHub)" <gi...@apache.org> on 2023/03/15 04:06:29 UTC
[GitHub] [sedona] douglasdennis commented on a diff in pull request #792: [SEDONA-231] Redundant Serde Elimination
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: dev-unsubscribe@sedona.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org