This is an automated email from the ASF dual-hosted git repository.
Yicong-Huang pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/texera.git
The following commit(s) were added to refs/heads/main by this push:
new ca11939481 test(workflow-operator): cover AVERAGE/MIN/MAX and
null-aggFunction in AggregateOpSpec (#4788)
ca11939481 is described below
commit ca119394812c663abe925ca5450be1e4b51176e8
Author: Xinyuan Lin <[email protected]>
AuthorDate: Sun May 3 08:53:27 2026 -0700
test(workflow-operator): cover AVERAGE/MIN/MAX and null-aggFunction in
AggregateOpSpec (#4788)
### What changes were proposed in this PR?
Extend `AggregateOpSpec`
(`common/workflow-operator/src/test/scala/org/apache/texera/amber/operator/aggregate/AggregateOpSpec.scala`)
with the `getAggregationAttribute` cases it was missing. SUM, COUNT, and
CONCAT were already covered there; this PR adds the gaps:
- AVERAGE always produces DOUBLE
- MIN preserves the input type
- MAX preserves the input type
- A null `aggFunction` raises `RuntimeException`
Per review feedback on the original PR (which introduced a separate
`AggregationOperationSpec`), the four cases are merged directly into
`AggregateOpSpec` rather than living in their own file.
### Any related issues, documentation, discussions?
Closes #4787
### How was this PR tested?
`sbt "WorkflowOperator/testOnly
org.apache.texera.amber.operator.aggregate.AggregateOpSpec"` — 21/21
tests pass.
### Was this PR authored or co-authored using generative AI tooling?
Generated-by: Claude Code (Claude Opus 4.7)
---------
Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
---
.../amber/operator/aggregate/AggregateOpSpec.scala | 35 ++++++++++++++++++++++
1 file changed, 35 insertions(+)
diff --git
a/common/workflow-operator/src/test/scala/org/apache/texera/amber/operator/aggregate/AggregateOpSpec.scala
b/common/workflow-operator/src/test/scala/org/apache/texera/amber/operator/aggregate/AggregateOpSpec.scala
index 170efee773..cb7925ec41 100644
---
a/common/workflow-operator/src/test/scala/org/apache/texera/amber/operator/aggregate/AggregateOpSpec.scala
+++
b/common/workflow-operator/src/test/scala/org/apache/texera/amber/operator/aggregate/AggregateOpSpec.scala
@@ -69,6 +69,41 @@ class AggregateOpSpec extends AnyFunSuite {
assert(attr.getType == AttributeType.STRING)
}
+ test("getAggregationAttribute maps AVERAGE result type to DOUBLE regardless
of input") {
+ val operation = makeAggregationOp(AggregationFunction.AVERAGE, "price",
"avg_price")
+ val attr = operation.getAggregationAttribute(AttributeType.LONG)
+
+ assert(attr.getName == "avg_price")
+ assert(attr.getType == AttributeType.DOUBLE)
+ }
+
+ test("getAggregationAttribute keeps original type for MIN") {
+ val operation = makeAggregationOp(AggregationFunction.MIN, "ts", "min_ts")
+ val attr = operation.getAggregationAttribute(AttributeType.TIMESTAMP)
+
+ assert(attr.getName == "min_ts")
+ assert(attr.getType == AttributeType.TIMESTAMP)
+ }
+
+ test("getAggregationAttribute keeps original type for MAX") {
+ val operation = makeAggregationOp(AggregationFunction.MAX, "score",
"max_score")
+ val attr = operation.getAggregationAttribute(AttributeType.DOUBLE)
+
+ assert(attr.getName == "max_score")
+ assert(attr.getType == AttributeType.DOUBLE)
+ }
+
+ test("getAggregationAttribute throws RuntimeException when aggFunction is
null") {
+ val operation = new AggregationOperation()
+ operation.attribute = "src"
+ operation.resultAttribute = "out"
+ // aggFunction left null on purpose
+
+ assertThrows[RuntimeException] {
+ operation.getAggregationAttribute(AttributeType.INTEGER)
+ }
+ }
+
//
---------------------------------------------------------------------------
// Basic DistributedAggregation behaviour via AggregationOperation.getAggFunc
//
---------------------------------------------------------------------------