Skip to content

Commit 5e7af98

Browse files
committed
Fixes to UserDefinedAggregateFunction implementations so they run in the Databricks environment.
Not sure what the cause is, but this change set seems to fix it.
1 parent 329764b commit 5e7af98

File tree

5 files changed

+15
-9
lines changed

5 files changed

+15
-9
lines changed

core/src/main/scala/org/locationtech/rasterframes/expressions/aggregates/CellStatsAggregate.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,8 @@ object CellStatsAggregate {
123123
import org.locationtech.rasterframes.encoders.StandardEncoders.cellStatsEncoder
124124

125125
def apply(col: Column): TypedColumn[Any, CellStatistics] =
126-
new Column(new CellStatsAggregateUDAF(col.expr))
127-
.as(s"rf_agg_stats($col)") // node renaming in class doesn't seem to propagate
126+
new CellStatsAggregate()(ExtractTile(col))
127+
.as(s"rf_agg_stats($col)")
128128
.as[CellStatistics]
129129

130130
/** Adapter hack to allow UserDefinedAggregateFunction to be referenced as an expression. */

core/src/main/scala/org/locationtech/rasterframes/expressions/aggregates/HistogramAggregate.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@ object HistogramAggregate {
9898
import org.locationtech.rasterframes.encoders.StandardEncoders.cellHistEncoder
9999

100100
def apply(col: Column): TypedColumn[Any, CellHistogram] =
101-
new Column(new HistogramAggregateUDAF(col.expr))
102-
.as(s"rf_agg_approx_histogram($col)") // node renaming in class doesn't seem to propogate
101+
new HistogramAggregate()(ExtractTile(col))
102+
.as(s"rf_agg_approx_histogram($col)")
103103
.as[CellHistogram]
104104

105105
/** Adapter hack to allow UserDefinedAggregateFunction to be referenced as an expression. */

core/src/main/scala/org/locationtech/rasterframes/expressions/aggregates/LocalCountAggregate.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ object LocalCountAggregate {
9292
object LocalDataCellsUDAF {
9393
def apply(child: Expression): LocalDataCellsUDAF = new LocalDataCellsUDAF(child)
9494
def apply(tile: Column): TypedColumn[Any, Tile] =
95-
new Column(new LocalDataCellsUDAF(tile.expr))
95+
new LocalCountAggregate(true)(ExtractTile(tile))
9696
.as(s"rf_agg_local_data_cells($tile)")
9797
.as[Tile]
9898
}
@@ -107,7 +107,7 @@ object LocalCountAggregate {
107107
object LocalNoDataCellsUDAF {
108108
def apply(child: Expression): LocalNoDataCellsUDAF = new LocalNoDataCellsUDAF(child)
109109
def apply(tile: Column): TypedColumn[Any, Tile] =
110-
new Column(new LocalNoDataCellsUDAF(tile.expr))
110+
new LocalCountAggregate(false)(ExtractTile(tile))
111111
.as(s"rf_agg_local_no_data_cells($tile)")
112112
.as[Tile]
113113
}

core/src/main/scala/org/locationtech/rasterframes/expressions/aggregates/LocalStatsAggregate.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ class LocalStatsAggregate() extends UserDefinedAggregateFunction {
146146
object LocalStatsAggregate {
147147

148148
def apply(col: Column): TypedColumn[Any, LocalCellStatistics] =
149-
new Column(LocalStatsAggregateUDAF(col.expr))
149+
new LocalStatsAggregate()(ExtractTile(col))
150150
.as(s"rf_agg_local_stats($col)")
151151
.as[LocalCellStatistics]
152152

core/src/main/scala/org/locationtech/rasterframes/expressions/aggregates/LocalTileOpAggregate.scala

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,10 @@ object LocalTileOpAggregate {
8383
}
8484
object LocalMinUDAF {
8585
def apply(child: Expression): LocalMinUDAF = new LocalMinUDAF(child)
86-
def apply(tile: Column): TypedColumn[Any, Tile] = new Column(new LocalMinUDAF(tile.expr)).as[Tile]
86+
def apply(tile: Column): TypedColumn[Any, Tile] =
87+
new LocalTileOpAggregate(BiasedMin)(ExtractTile(tile))
88+
.as(s"rf_agg_local_min($tile)")
89+
.as[Tile]
8790
}
8891

8992
@ExpressionDescription(
@@ -95,6 +98,9 @@ object LocalTileOpAggregate {
9598
}
9699
object LocalMaxUDAF {
97100
def apply(child: Expression): LocalMaxUDAF = new LocalMaxUDAF(child)
98-
def apply(tile: Column): TypedColumn[Any, Tile] = new Column(new LocalMaxUDAF(tile.expr)).as[Tile]
101+
def apply(tile: Column): TypedColumn[Any, Tile] =
102+
new LocalTileOpAggregate(BiasedMax)(ExtractTile(tile))
103+
.as(s"rf_agg_local_max($tile)")
104+
.as[Tile]
99105
}
100106
}

0 commit comments

Comments
 (0)