Skip to content

Commit

Permalink
Refactor packages structure
Browse files Browse the repository at this point in the history
  • Loading branch information
pomadchin committed Apr 9, 2022
1 parent 059761d commit 1cb8416
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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, _) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand All @@ -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
Expand Down

0 comments on commit 1cb8416

Please sign in to comment.