Skip to content

Commit 4de6839

Browse files
committed
Propagate errors encountered in RasterSourceToRasterRefs.
Closes #267.

1 parent dba27d1 commit 4de6839

File tree

3 files changed

+20
-5
lines changed

3 files changed

+20
-5
lines changed

core/src/main/scala/org/locationtech/rasterframes/expressions/generators/RasterSourceToRasterRefs.scala

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121

2222
package org.locationtech.rasterframes.expressions.generators
2323

24-
import com.typesafe.scalalogging.LazyLogging
2524
import geotrellis.raster.GridBounds
2625
import geotrellis.vector.Extent
2726
import org.apache.spark.sql.catalyst.InternalRow
@@ -45,7 +44,7 @@ import scala.util.control.NonFatal
4544
* @since 9/6/18
4645
*/
4746
case class RasterSourceToRasterRefs(children: Seq[Expression], bandIndexes: Seq[Int], subtileDims: Option[TileDimensions] = None) extends Expression
48-
with Generator with CodegenFallback with ExpectsInputTypes with LazyLogging {
47+
with Generator with CodegenFallback with ExpectsInputTypes {
4948

5049
override def inputTypes: Seq[DataType] = Seq.fill(children.size)(RasterSourceType)
5150
override def nodeName: String = "rf_raster_source_to_raster_ref"
@@ -77,9 +76,9 @@ case class RasterSourceToRasterRefs(children: Seq[Expression], bandIndexes: Seq[
7776
}
7877
catch {
7978
case NonFatal(ex)
80-
val payload = Try(children.map(c => RasterSourceType.deserialize(c.eval(input)))).toOption.toSeq.flatten
81-
logger.error("Error fetching data for one of: " + payload.mkString(", "), ex)
82-
Traversable.empty
79+
val description = Try(children.map(c => RasterSourceType.deserialize(c.eval(input))))
80+
.toOption.toSeq.flatten.mkString(", ")
81+
throw new java.lang.IllegalArgumentException(description, ex)
8382
}
8483
}
8584
}

core/src/test/scala/org/locationtech/rasterframes/ref/RasterRefSpec.scala

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,11 @@
2121

2222
package org.locationtech.rasterframes.ref
2323

24+
import java.net.URI
25+
2426
import geotrellis.raster.{ByteConstantNoDataCellType, Tile}
2527
import geotrellis.vector.Extent
28+
import org.apache.spark.SparkException
2629
import org.apache.spark.sql.Encoders
2730
import org.locationtech.rasterframes.{TestEnvironment, _}
2831
import org.locationtech.rasterframes.expressions.accessors._
@@ -205,6 +208,16 @@ class RasterRefSpec extends TestEnvironment with TestData {
205208
r.rows should be <= NOMINAL_TILE_SIZE
206209
}
207210
}
211+
it("should throw exception on invalid URI") {
212+
val src = RasterSource(URI.create("http://foo/bar"))
213+
import spark.implicits._
214+
val df = Seq(src).toDF("src")
215+
val refs = df.select(RasterSourceToRasterRefs($"src") as "proj_raster")
216+
logger.warn(Console.REVERSED + "Upcoming 'java.lang.IllegalArgumentException' expected in logs." + Console.RESET)
217+
assertThrows[SparkException] {
218+
refs.first()
219+
}
220+
}
208221
}
209222

210223
describe("RealizeTile") {

docs/src/main/paradox/release-notes.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,13 @@
44

55
### 0.8.2
66

7+
* Fixed issue with `RasterSourceDataSource` swallowing exceptions. ([#267](https://github.com/locationtech/rasterframes/issues/267))
78
* Fixed SparkML memory pressure issue caused by unnecessary reevaluation, overallocation, and primitive boxing. ([#343](https://github.com/locationtech/rasterframes/issues/343))
89
* Fixed Parquet serialization issue with `RasterRef`s ([#338](https://github.com/locationtech/rasterframes/issues/338))
910
* Fixed `TileExploder`, `rf_agg_local_mean` and `TileColumnSupport` to support `proj_raster` struct ([#287](https://github.com/locationtech/rasterframes/issues/287), [#163](https://github.com/locationtech/rasterframes/issues/163), [#333](https://github.com/locationtech/rasterframes/issues/333)).
1011
* Various documentation improvements.
12+
* _Breaking_ (potentially): Synchronized parameter naming in Python and Scala for `spark.read.raster` ([#329](https://github.com/locationtech/rasterframes/pull/329)).
13+
1114

1215
### 0.8.1
1316

0 commit comments

Comments
 (0)