tanishqgandhi1908 commented on code in PR #5896:
URL: https://github.com/apache/texera/pull/5896#discussion_r3508602145


##########
common/workflow-operator/src/main/scala/org/apache/texera/amber/operator/aggregate/AggregateOpExec.scala:
##########
@@ -47,9 +47,14 @@ class AggregateOpExec(descString: String) extends 
OperatorExecutor {
 
     // Initialize distributedAggregations if it's not yet initialized
     if (distributedAggregations == null) {
-      distributedAggregations = desc.aggregations.map(agg =>
-        agg.getAggFunc(tuple.getSchema.getAttribute(agg.attribute).getType)
-      )
+      distributedAggregations = desc.aggregations.map { agg =>
+        // An empty attribute (COUNT(*)) has no input column to look up; 
COUNT's result
+        // type does not depend on any input attribute, so a null attrType is 
safe here.
+        val attrType =
+          if (agg.attribute == null || agg.attribute.trim.isEmpty) null
+          else tuple.getSchema.getAttribute(agg.attribute).getType
+        agg.getAggFunc(attrType)

Review Comment:
   The guard now only skips the column lookup for count with an empty attribute 
(COUNT(*)); every other function resolves the input attribute and fails fast if 
it's missing, so no null-typed output can slip through from a stale/API config. 
Added a test covering the fail-fast case.



##########
common/workflow-operator/src/main/scala/org/apache/texera/amber/operator/aggregate/AggregateOpDesc.scala:
##########
@@ -78,9 +78,14 @@ class AggregateOpDesc extends LogicalOp {
           val inputSchema = inputSchemas(operatorInfo.inputPorts.head.id)
           val outputSchema = Schema(
             groupByKeys.map(key => inputSchema.getAttribute(key)) ++
-              localAggregations.map(agg =>
-                
agg.getAggregationAttribute(inputSchema.getAttribute(agg.attribute).getType)
-              )
+              localAggregations.map { agg =>
+                // An empty attribute (COUNT(*)) has no input column to look 
up; COUNT's
+                // result type is INTEGER regardless, so a null attrType is 
safe here.
+                val attrType =
+                  if (agg.attribute == null || agg.attribute.trim.isEmpty) null
+                  else inputSchema.getAttribute(agg.attribute).getType
+                agg.getAggregationAttribute(attrType)

Review Comment:
   The guard now only skips the column lookup for count with an empty attribute 
(COUNT(*)); every other function resolves the input attribute and fails fast if 
it's missing, so no null-typed output can slip through from a stale/API config. 
Added a test covering the fail-fast case.



-- 
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