Yicong-Huang commented on code in PR #5416:
URL: https://github.com/apache/texera/pull/5416#discussion_r3368378872


##########
common/workflow-operator/src/main/scala/org/apache/texera/amber/operator/sort/SortOpDesc.scala:
##########
@@ -28,9 +28,14 @@ import 
org.apache.texera.amber.operator.metadata.{OperatorGroupConstants, Operat
 class SortOpDesc extends PythonOperatorDescriptor {
   @JsonProperty(required = true)
   @JsonPropertyDescription("column to perform sorting on")
-  var attributes: List[SortCriteriaUnit] = _
+  var attributes: List[SortCriteriaUnit] = List.empty
 
   override def generatePythonCode(): String = {
+    require(attributes.nonEmpty, "Sort operator requires at least one sort 
key.")
+    require(
+      attributes.forall(c => c.attributeName != null && 
c.attributeName.trim.nonEmpty),
+      "Each sort key must have an attribute selected."
+    )

Review Comment:
   as we just json to generate SortOpDesc, please test the json patterns can 
correctly being deserialized



##########
common/workflow-operator/src/main/scala/org/apache/texera/amber/operator/sort/SortOpDesc.scala:
##########
@@ -28,9 +28,14 @@ import 
org.apache.texera.amber.operator.metadata.{OperatorGroupConstants, Operat
 class SortOpDesc extends PythonOperatorDescriptor {
   @JsonProperty(required = true)
   @JsonPropertyDescription("column to perform sorting on")
-  var attributes: List[SortCriteriaUnit] = _
+  var attributes: List[SortCriteriaUnit] = List.empty
 
   override def generatePythonCode(): String = {
+    require(attributes.nonEmpty, "Sort operator requires at least one sort 
key.")
+    require(
+      attributes.forall(c => c.attributeName != null && 
c.attributeName.trim.nonEmpty),
+      "Each sort key must have an attribute selected."
+    )

Review Comment:
   as we use json to generate SortOpDesc, please test the json patterns can 
correctly being deserialized



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