Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,13 @@ case class ReprojectGeometry(geometry: Expression, srcCRS: Expression, dstCRS: E
// Optimized pass-through case.
case (s: LazyCRS, r: LazyCRS) if s.encoded == r.encoded => geometry.eval(input)
case _ =>
val geom = JTSTypes.GeometryTypeInstance.deserialize(geometry.eval(input))
JTSTypes.GeometryTypeInstance.serialize(reproject(geom, src, dst))
if (geometry.eval(input) != null) {
val geom = JTSTypes.GeometryTypeInstance.deserialize(geometry.eval(input))
JTSTypes.GeometryTypeInstance.serialize(reproject(geom, src, dst))
}
else {
null
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
package org.locationtech.rasterframes

import geotrellis.proj4.{CRS, LatLng, Sinusoidal, WebMercator}
import org.apache.spark.sql.functions.lit
import org.apache.spark.sql.Encoders
import org.locationtech.jts.geom._

Expand Down Expand Up @@ -118,5 +119,15 @@ class ReprojectGeometrySpec extends TestEnvironment {

checkDocs("st_reproject")
}

it("should work on null columns") {
val df = Seq(1, 2, 3).toDF("id")

noException shouldBe thrownBy {
df.withColumn("nullId", lit(null))
.select(st_reproject(st_makePoint($"nullId", $"nullId"), WebMercator, Sinusoidal))
.count()
}
}
}
}