Skip to content

Commit 52356cc

Browse files
authored
Merge pull request #500 from s22s/fix/499-raster-join-coalesce
Fix RasterJoin coalesce issue
2 parents e1a727a + f8e3a3b commit 52356cc

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

core/src/main/scala/org/locationtech/rasterframes/extensions/RasterJoin.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ object RasterJoin {
104104
// Assumes all LHS tiles in a row are of the same size.
105105
val destDims =
106106
if (left.tileColumns.nonEmpty)
107-
rf_dimensions(coalesce(left.tileColumns.map(unresolved): _*))
107+
coalesce(left.tileColumns.map(unresolved).map(rf_dimensions): _*)
108108
else
109109
serialized_literal(fallbackDimensions.getOrElse(NOMINAL_TILE_DIMS))
110110

core/src/test/scala/org/locationtech/rasterframes/RasterJoinSpec.scala

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,16 @@ class RasterJoinSpec extends TestEnvironment with TestData with RasterMatchers {
172172
}
173173
}
174174

175+
it("should raster join multiple times on projected raster"){
176+
val df0 = Seq(one).toDF("proj_raster")
177+
val result = df0.select($"proj_raster" as "t1")
178+
.rasterJoin(df0.select($"proj_raster" as "t2"))
179+
.rasterJoin(df0.select($"proj_raster" as "t3"))
180+
181+
result.tileColumns.length should be (3)
182+
result.count() should be (1)
183+
}
184+
175185
it("should honor resampling options") {
176186
// test case. replicate existing test condition and check that resampling option results in different output
177187
val filterExpr = st_intersects(rf_geometry($"tile"), st_point(704940.0, 4251130.0))

core/src/test/scala/org/locationtech/rasterframes/functions/TileFunctionsSpec.scala

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import geotrellis.raster._
2727
import geotrellis.raster.testkit.RasterMatchers
2828
import javax.imageio.ImageIO
2929
import org.apache.spark.sql.Encoders
30-
import org.apache.spark.sql.functions.sum
30+
import org.apache.spark.sql.functions.{count, sum, isnull}
3131
import org.locationtech.rasterframes._
3232
import org.locationtech.rasterframes.ref.RasterRef
3333
import org.locationtech.rasterframes.tiles.ProjectedRasterTile
@@ -354,6 +354,17 @@ class TileFunctionsSpec extends TestEnvironment with RasterMatchers {
354354
t should be(randPRT.dimensions)
355355
checkDocs("rf_dimensions")
356356
}
357+
358+
it("should get null for null tile dimensions") {
359+
val result = (Seq(randPRT) :+ null).toDF("tile")
360+
.select(rf_dimensions($"tile") as "dim")
361+
.select(isnull($"dim").cast("long") as "n")
362+
.agg(sum("n"), count("n"))
363+
.first()
364+
result.getAs[Long](0) should be (1)
365+
result.getAs[Long](1) should be (2)
366+
}
367+
357368
it("should get the Extent of a ProjectedRasterTile") {
358369
val e = Seq(randPRT).toDF("tile").select(rf_extent($"tile")).first()
359370
e should be(extent)

0 commit comments

Comments
 (0)