{"record":{"id":"090ff61ab086d255","repo":"apache/druid","slug":"order-required-for-column-s","errorCode":null,"errorMessage":"Order required for column [%s]","messagePattern":"Order required for column \\[(.+?)\\]","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":400,"severity":"error","filePath":"processing/src/main/java/org/apache/druid/query/OrderBy.java","lineNumber":56,"sourceCode":"  public static OrderBy descending(String columnName)\n  {\n    return new OrderBy(columnName, Order.DESCENDING);\n  }\n\n  private final String columnName;\n  private final Order order;\n\n  @JsonCreator\n  public OrderBy(\n      @JsonProperty(\"columnName\") final String columnName,\n      @JsonProperty(\"order\") final Order order\n  )\n  {\n    this.columnName = Preconditions.checkNotNull(columnName, \"columnName\");\n    this.order = Preconditions.checkNotNull(order, \"order\");\n\n    if (order == Order.NONE) {\n      throw new IAE(\"Order required for column [%s]\", columnName);\n    }\n  }\n\n  @JsonProperty\n  public String getColumnName()\n  {\n    return columnName;\n  }\n\n  @JsonProperty\n  public Order getOrder()\n  {\n    return order;\n  }\n\n  /**\n   * Returns true if the given {@link OrderBy} is the exact reverse, meaning they have the same column name\n   * in revrersed order.","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/processing/src/main/java/org/apache/druid/query/OrderBy.java#L38-L74","documentation":"OrderBy specifies a sort column and direction for a Sort/OrderBy component of a query. The constructor validates that the order is non-null and not Order.NONE — a column with 'no ordering' is meaningless in an explicit sort spec, so this IllegalArgumentException is thrown.","triggerScenarios":"Constructing new OrderBy(column, Order.NONE) programmatically, or deserializing JSON with \"order\":\"none\" (or an order field resolving to NONE) in a query's sort spec.","commonSituations":"Code building OrderBy from user input where the direction defaults to NONE; JSON payloads that omit or misuse the order enum; developers thinking NONE means 'default order' rather than an invalid sort direction.","solutions":["Use Order.ASCENDING or Order.DESCENDING instead of Order.NONE.","If the column shouldn't be sorted, remove it from the sort spec entirely rather than using NONE.","Fix client serialization that maps missing order fields to NONE."],"exampleFix":"// before\nnew OrderBy(\"col\", Order.NONE);\n// after\nnew OrderBy(\"col\", Order.ASCENDING);","handlingStrategy":"validation","validationCode":"if (order == null || order == Order.NONE) {\n  throw new IllegalArgumentException(\"Order required for column \" + columnName);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never map missing direction input to Order.NONE; default to ASCENDING instead.","Validate sort specs at API boundaries before building OrderBy objects.","Remove unsorted columns from sort specs rather than using NONE."],"tags":["validation","sorting","invalid-argument-value","query-json"],"backgroundTag":"invalid-argument-value","analyzedSha":"9b90983fd291f26935af934383ce360473179e4d","analyzedAt":"2026-09-07T13:32:30.957Z","contentChangedAt":"2026-09-07T13:32:30.957Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}