From 1cb8416ebc4fa642c51e0596fe67c9886ef1b3bd Mon Sep 17 00:00:00 2001 From: Grigory Pomadchin Date: Sat, 9 Apr 2022 15:20:19 -0400 Subject: [PATCH] Refactor packages structure --- .../azavea/hiveless/spark/rules/syntax/syntax.scala} | 6 +++--- .../org/apache/spark/sql/hive/HivelessInternals.scala | 2 +- .../spark/spatial/rules/SpatialFilterPushdownRules.scala | 7 +++---- 3 files changed, 7 insertions(+), 8 deletions(-) rename core/src/main/scala/{org/apache/spark/sql/hive/rules/syntax/package.scala => com/azavea/hiveless/spark/rules/syntax/syntax.scala} (83%) diff --git a/core/src/main/scala/org/apache/spark/sql/hive/rules/syntax/package.scala b/core/src/main/scala/com/azavea/hiveless/spark/rules/syntax/syntax.scala similarity index 83% rename from core/src/main/scala/org/apache/spark/sql/hive/rules/syntax/package.scala rename to core/src/main/scala/com/azavea/hiveless/spark/rules/syntax/syntax.scala index 994fe0e..1be7c2c 100644 --- a/core/src/main/scala/org/apache/spark/sql/hive/rules/syntax/package.scala +++ b/core/src/main/scala/com/azavea/hiveless/spark/rules/syntax/syntax.scala @@ -14,15 +14,15 @@ * limitations under the License. */ -package org.apache.spark.sql.hive.rules +package com.azavea.hiveless.spark.rules -import org.apache.spark.sql.hive.HivelessInternals.GenericUDF import org.apache.spark.sql.catalyst.expressions.{And, Expression} +import org.apache.spark.sql.hive.HivelessInternals.HiveGenericUDF import scala.reflect.{classTag, ClassTag} package object syntax extends Serializable { - implicit class HiveGenericUDFOps(val self: GenericUDF) extends AnyVal { + implicit class HiveGenericUDFOps(val self: HiveGenericUDF) extends AnyVal { def of[T: ClassTag]: Boolean = self.funcWrapper.functionClassName == classTag[T].toString } diff --git a/core/src/main/scala/org/apache/spark/sql/hive/HivelessInternals.scala b/core/src/main/scala/org/apache/spark/sql/hive/HivelessInternals.scala index a853a97..cfc0268 100644 --- a/core/src/main/scala/org/apache/spark/sql/hive/HivelessInternals.scala +++ b/core/src/main/scala/org/apache/spark/sql/hive/HivelessInternals.scala @@ -21,7 +21,7 @@ import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectIn import org.apache.spark.sql.types._ object HivelessInternals extends HiveInspectors with Serializable { - type GenericUDF = org.apache.spark.sql.hive.HiveGenericUDF + type HiveGenericUDF = org.apache.spark.sql.hive.HiveGenericUDF def toWritableInspector(dataType: DataType): ObjectInspector = dataType match { case ArrayType(tpe, _) => diff --git a/spatial-index/src/main/scala/com/azavea/hiveless/spark/spatial/rules/SpatialFilterPushdownRules.scala b/spatial-index/src/main/scala/com/azavea/hiveless/spark/spatial/rules/SpatialFilterPushdownRules.scala index c3b4021..43d260b 100644 --- a/spatial-index/src/main/scala/com/azavea/hiveless/spark/spatial/rules/SpatialFilterPushdownRules.scala +++ b/spatial-index/src/main/scala/com/azavea/hiveless/spark/spatial/rules/SpatialFilterPushdownRules.scala @@ -16,14 +16,13 @@ package com.azavea.hiveless.spark.spatial.rules +import com.azavea.hiveless.spark.rules.syntax._ import com.azavea.hiveless.spatial._ import com.azavea.hiveless.spatial.index.ST_IntersectsExtent import com.azavea.hiveless.serializers.syntax._ -import org.locationtech.jts.geom.Geometry import geotrellis.vector._ import cats.syntax.option._ -import org.apache.spark.sql.hive.HivelessInternals.GenericUDF -import org.apache.spark.sql.hive.rules.syntax._ +import org.apache.spark.sql.hive.HivelessInternals.HiveGenericUDF import org.apache.spark.sql.catalyst.expressions._ import org.apache.spark.sql.SQLContext import org.apache.spark.sql.catalyst.plans.logical.{Filter, LogicalPlan} @@ -34,7 +33,7 @@ object SpatialFilterPushdownRules extends Rule[LogicalPlan] { def apply(plan: LogicalPlan): LogicalPlan = plan.transformDown { // HiveGenericUDF is a private[hive] case class - case Filter(condition: GenericUDF, plan) if condition.of[ST_IntersectsExtent] => + case Filter(condition: HiveGenericUDF, plan) if condition.of[ST_IntersectsExtent] => // extract bbox, snd val Seq(bboxExpr, geometryExpr) = condition.children // extract extent from the right