Ma77Ball commented on code in PR #5416:
URL: https://github.com/apache/texera/pull/5416#discussion_r3368392999
##########
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:
Added `SortOpDescSpec` to cover this. It just feeds different JSON into the
Sort operator and checks it reads back correctly: when no sort columns are
given it now comes through as an empty list instead of null (which was the
crash), and when a column is set it works and gives a clear message if
something's missing. Run with `sbt "WorkflowOperator/testOnly *SortOpDescSpec"`.
--
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]