diff --git a/src/main/scala/com/databricks/labs/mosaic/core/index/H3IndexSystem.scala b/src/main/scala/com/databricks/labs/mosaic/core/index/H3IndexSystem.scala index ae4812a0e..47e9febbd 100644 --- a/src/main/scala/com/databricks/labs/mosaic/core/index/H3IndexSystem.scala +++ b/src/main/scala/com/databricks/labs/mosaic/core/index/H3IndexSystem.scala @@ -216,6 +216,6 @@ object H3IndexSystem extends IndexSystem(LongType) with Serializable { h3.geoToH3(geo.lat, geo.lng, h3.h3GetResolution(id)) } - override def distance(cellId: Long, cellId2: Long): Long = h3.h3Distance(cellId, cellId2).toLong + override def distance(cellId: Long, cellId2: Long): Long = Try(h3.h3Distance(cellId, cellId2)).map(_.toLong).getOrElse(0) } diff --git a/src/main/scala/com/databricks/labs/mosaic/datasource/multiread/RasterAsGridReader.scala b/src/main/scala/com/databricks/labs/mosaic/datasource/multiread/RasterAsGridReader.scala index dfe33bf25..f2a8a3fdc 100644 --- a/src/main/scala/com/databricks/labs/mosaic/datasource/multiread/RasterAsGridReader.scala +++ b/src/main/scala/com/databricks/labs/mosaic/datasource/multiread/RasterAsGridReader.scala @@ -172,7 +172,7 @@ class RasterAsGridReader(sparkSession: SparkSession) extends MosaicDataFrameRead rasterDf .withColumn("origin_cell_id", col("cell_id")) .withColumn("cell_id", explode(grid_cellkring(col("origin_cell_id"), k))) - .withColumn("weight", lit(k + 1) - grid_distance(col("origin_cell_id"), col("cell_id)"))) + .withColumn("weight", lit(k + 1) - grid_distance(col("origin_cell_id"), col("cell_id"))) .groupBy("band_id", "cell_id") .agg(weighted_sum("measure", "weight")) } else { diff --git a/src/test/scala/com/databricks/labs/mosaic/datasource/multiread/RasterAsGridReaderTest.scala b/src/test/scala/com/databricks/labs/mosaic/datasource/multiread/RasterAsGridReaderTest.scala index 70badb057..6d8a52551 100644 --- a/src/test/scala/com/databricks/labs/mosaic/datasource/multiread/RasterAsGridReaderTest.scala +++ b/src/test/scala/com/databricks/labs/mosaic/datasource/multiread/RasterAsGridReaderTest.scala @@ -25,7 +25,7 @@ class RasterAsGridReaderTest extends MosaicSpatialQueryTest with SharedSparkSess .option("tileSize", "10") .option("readSubdataset", "true") .option("subdataset", "1") - .option("kRingInterpolation", "3") + .option("kRingInterpolate", "3") .load(filePath) .select("measure") .queryExecution @@ -46,7 +46,7 @@ class RasterAsGridReaderTest extends MosaicSpatialQueryTest with SharedSparkSess .option("combiner", "min") .option("retile", "true") .option("tileSize", "10") - .option("kRingInterpolation", "3") + .option("kRingInterpolate", "3") .load(filePath) .select("measure") .take(1) @@ -64,7 +64,7 @@ class RasterAsGridReaderTest extends MosaicSpatialQueryTest with SharedSparkSess .format("raster_to_grid") .option("combiner", "max") .option("tileSize", "10") - .option("kRingInterpolation", "3") + .option("kRingInterpolate", "3") .load(filePath) .select("measure") .take(1) @@ -129,9 +129,9 @@ class RasterAsGridReaderTest extends MosaicSpatialQueryTest with SharedSparkSess .format("invalid") .load(filePath) - an[Exception] should be thrownBy MosaicContext.read + noException should be thrownBy MosaicContext.read .format("raster_to_grid") - .option("kRingInterpolate", "3") // Only works on Databricks Photon Cluster. + .option("kRingInterpolate", "3") .load(filePath) }