Skip to content

Commit

Permalink
GEOMESA-3147 Fixed None push-down filter applied in GeoMesaRelation (#…
Browse files Browse the repository at this point in the history
…2810)

* Fixed none push-down geotools filter applied to the relation
5iFish authored Nov 15, 2021
1 parent 5d939b2 commit 09a0a50
Showing 2 changed files with 52 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -279,8 +279,10 @@ object GeoMesaRelation extends LazyLogging {
Some(IndexedRDD(rdd))
}
}

val filter = Option(ECQL.toFilter(params.getOrElse("query", "INCLUDE")))

GeoMesaRelation(sqlContext, sft, schema, params, None, cached, partitioned)
GeoMesaRelation(sqlContext, sft, schema, params, filter, cached, partitioned)
}

/**
Original file line number Diff line number Diff line change
@@ -79,6 +79,55 @@ class SparkSQLDataTest extends Specification with LazyLogging {

dfIndexed.collect.length mustEqual 3
}


"create spatially partitioned relation with date query option" >> {
dfPartitioned = spark.read
.format("geomesa")
.options(dsParams)
.option("geomesa.feature", "chicago")
.option("spatial", "true")
.option("query", "dtg AFTER 2016-01-01T10:00:00.000Z")
.load()
logger.debug(df.schema.treeString)

dfPartitioned.createOrReplaceTempView("chicagoPartitionedWithQuery")

spark.sql("select * from chicagoPartitionedWithQuery")
.collect().map{ r=> r.get(0) } mustEqual Array("2", "3")
}

"create spatially partitioned relation with attribute query option" >> {
dfPartitioned = spark.read
.format("geomesa")
.options(dsParams)
.option("geomesa.feature", "chicago")
.option("spatial", "true")
.option("query", "case_number < 3")
.load()
logger.debug(df.schema.treeString)

dfPartitioned.createOrReplaceTempView("chicagoPartitionedWithQuery")

spark.sql("select * from chicagoPartitionedWithQuery")
.collect().map{ r=> r.get(0) } mustEqual Array("1", "2")
}

"create spatially partitioned relation with spatial query option" >> {
dfPartitioned = spark.read
.format("geomesa")
.options(dsParams)
.option("geomesa.feature", "chicago")
.option("spatial", "true")
.option("query", "BBOX(geom, -76.7, 38.2, -76.2, 38.7)")
.load()
logger.debug(df.schema.treeString)

dfPartitioned.createOrReplaceTempView("chicagoPartitionedWithQuery")

spark.sql("select * from chicagoPartitionedWithQuery")
.collect().map{ r=> r.get(0) } mustEqual Array("1")
}

"create spatially partitioned relation" >> {
dfPartitioned = spark.read

0 comments on commit 09a0a50

Please sign in to comment.