Copilot commented on code in PR #4908:
URL: https://github.com/apache/texera/pull/4908#discussion_r3180071531


##########
common/workflow-operator/src/test/scala/org/apache/texera/amber/operator/aggregate/AggregationOperationSpec.scala:
##########
@@ -0,0 +1,182 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.texera.amber.operator.aggregate
+
+import org.apache.texera.amber.core.tuple.{Attribute, AttributeType, Schema, 
Tuple}
+import org.scalatest.flatspec.AnyFlatSpec
+
+/**
+  * Coverage notes:
+  * `AggregateOpSpec` (in this same package) already exercises the happy paths 
for
+  * `getAggregationAttribute`, the per-kind `init/iterate/merge/finalAgg` 
semantics
+  * (SUM/COUNT/AVERAGE/MIN/MAX/CONCAT, including null-handling and 
AVERAGE-of-empty),
+  * and the `getFinal` rewrite. This spec deliberately does NOT duplicate 
those.
+  *
+  * What this spec adds:
+  * - `getAggFunc` validation errors (non-numeric types, null aggFunction).
+  * - The CONCAT-specific `merge` partial-combination behavior (no per-tuple
+  *   iterate test in `AggregateOpSpec` calls `merge` directly).
+  * - A two-stage worker→final pipeline that runs a real partial aggregation
+  *   on each "worker", emits a partial tuple, then applies `getFinal` and
+  *   re-aggregates the partials end-to-end.
+  * - `AveragePartialObj` value-class exposure.

Review Comment:
   The coverage-notes header says "AveragePartialObj value-class exposure", but 
`AveragePartialObj` is a plain case class (it doesn’t extend `AnyVal`). 
Consider rewording this bullet (e.g., “case-class field exposure / value 
equality”) to avoid misleading readers about the type’s semantics.
   



##########
common/workflow-operator/src/test/scala/org/apache/texera/amber/operator/aggregate/AggregationOperationSpec.scala:
##########
@@ -0,0 +1,182 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.texera.amber.operator.aggregate
+
+import org.apache.texera.amber.core.tuple.{Attribute, AttributeType, Schema, 
Tuple}
+import org.scalatest.flatspec.AnyFlatSpec
+
+/**
+  * Coverage notes:
+  * `AggregateOpSpec` (in this same package) already exercises the happy paths 
for
+  * `getAggregationAttribute`, the per-kind `init/iterate/merge/finalAgg` 
semantics
+  * (SUM/COUNT/AVERAGE/MIN/MAX/CONCAT, including null-handling and 
AVERAGE-of-empty),
+  * and the `getFinal` rewrite. This spec deliberately does NOT duplicate 
those.
+  *
+  * What this spec adds:
+  * - `getAggFunc` validation errors (non-numeric types, null aggFunction).
+  * - The CONCAT-specific `merge` partial-combination behavior (no per-tuple
+  *   iterate test in `AggregateOpSpec` calls `merge` directly).
+  * - A two-stage worker→final pipeline that runs a real partial aggregation
+  *   on each "worker", emits a partial tuple, then applies `getFinal` and
+  *   re-aggregates the partials end-to-end.
+  * - `AveragePartialObj` value-class exposure.
+  */
+class AggregationOperationSpec extends AnyFlatSpec {
+
+  // --- helpers 
---------------------------------------------------------------
+
+  private def schemaWith(name: String, t: AttributeType): Schema =
+    new Schema(new Attribute(name, t))
+
+  private def tupleOf(name: String, t: AttributeType, value: AnyRef): Tuple =
+    Tuple.builder(schemaWith(name, t)).add(new Attribute(name, t), 
value).build()
+
+  private def op(
+      func: AggregationFunction,
+      attribute: String = "v",
+      resultAttribute: String = "r"
+  ): AggregationOperation = {
+    val o = new AggregationOperation()
+    o.aggFunction = func
+    o.attribute = attribute
+    o.resultAttribute = resultAttribute
+    o
+  }
+
+  // --- getAggFunc: type validation (not covered in AggregateOpSpec) 
----------
+
+  "AggregationOperation.getAggFunc" should "throw 
UnsupportedOperationException for non-numeric types on SUM" in {
+    val ex = intercept[UnsupportedOperationException] {
+      op(AggregationFunction.SUM).getAggFunc(AttributeType.STRING)
+    }
+    assert(ex.getMessage.contains("Unsupported attribute type for sum"))
+  }
+
+  it should "throw UnsupportedOperationException for non-numeric types on MIN 
and MAX" in {
+    intercept[UnsupportedOperationException] {
+      op(AggregationFunction.MIN).getAggFunc(AttributeType.STRING)
+    }
+    intercept[UnsupportedOperationException] {
+      op(AggregationFunction.MAX).getAggFunc(AttributeType.BOOLEAN)
+    }

Review Comment:
   The test descriptions refer to “non-numeric types” for SUM/MIN/MAX, but 
`AggregationOperation` also allows `TIMESTAMP` for these aggregations. Consider 
adjusting the wording to “unsupported attribute types” (or explicitly listing 
disallowed examples) so the test names match the actual validation rule.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to