{"record":{"id":"e9cb16f20888476a","repo":"apache/druid","slug":"cannot-specify-desc-clustering-key-s-only-asc","errorCode":null,"errorMessage":"Cannot specify DESC clustering key [%s]. Only ASC is supported.","messagePattern":"Cannot specify DESC clustering key \\[(.+?)\\]\\. Only ASC is supported\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"server/src/main/java/org/apache/druid/catalog/model/table/DatasourceDefn.java","lineNumber":180,"sourceCode":"    public ClusterKeysDefn()\n    {\n      super(\n          CLUSTER_KEYS_PROPERTY,\n          \"ClusterKeySpec list\",\n          new TypeReference<>() {}\n      );\n    }\n\n    @Override\n    public void validate(Object value, ObjectMapper jsonMapper)\n    {\n      if (value == null) {\n        return;\n      }\n      List<ClusterKeySpec> clusterKeys = decode(value, jsonMapper);\n      for (ClusterKeySpec clusterKey : clusterKeys) {\n        if (clusterKey.desc()) {\n          throw new IAE(\n              StringUtils.format(\"Cannot specify DESC clustering key [%s]. Only ASC is supported.\", clusterKey)\n          );\n        }\n      }\n    }\n  }\n\n  public static class ProjectionsDefn extends ModelProperties.TypeRefPropertyDefn<List<DatasourceProjectionMetadata>>\n  {\n    public static final TypeReference<List<DatasourceProjectionMetadata>> TYPE_REF = new TypeReference<>() {};\n\n    public ProjectionsDefn()\n    {\n      super(PROJECTIONS_KEYS_PROPERTY, \"DatasourceProjectionMetadata list\", TYPE_REF);\n    }\n  }\n\n  public static class BaseTableDefn extends ModelProperties.TypeRefPropertyDefn<DatasourceBaseTableMetadata>","sourceCodeStart":162,"sourceCodeEnd":198,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/server/src/main/java/org/apache/druid/catalog/model/table/DatasourceDefn.java#L162-L198","documentation":"Validation guard in the ClusterKeysDefn property definition for datasource table specs: clustering currently only supports ascending sort, and a ClusterKeySpec with desc=true would produce a clustering layout Druid cannot maintain. It fires when a datasource definition (or its JSON spec) declares a clustering column with descending order; flip the key to ascending (or drop it) when configuring clusterBy in the table spec.","triggerScenarios":"Creating or updating a datasource whose clusteringColumns property contains a key with desc=true; validate() decodes the ClusterKeySpec list and throws on the first descending key.","commonSituations":"Users copying ORDER BY-style specs with DESC; generating clustering keys from a UI that allows direction selection; migrating specs written for other systems that permit descending clustering.","solutions":["Remove the DESC direction so each clustering key defaults to ascending.","Explicitly set desc:false in each ClusterKeySpec entry.","Reorder columns rather than reversing directions if ordering semantics matter.","Update tooling/templates that emit DESC clustering keys."],"exampleFix":"// before\n\"clusteringColumns\": [{\"column\":\"region\",\"desc\":true}]\n// after\n\"clusteringColumns\": [{\"column\":\"region\",\"desc\":false}]","handlingStrategy":"validation","validationCode":"for (ClusterKeySpec key : spec.getClusteringColumns()) {\n  if (key.desc()) throw new IllegalArgumentException(\"DESC clustering not supported: \" + key);\n}","typeGuard":null,"tryCatchPattern":"try { saveSpec(spec); } catch (IAE e) { if (e.getMessage().contains(\"Only ASC is supported\")) { spec.getClusteringColumns().forEach(k -> k.setDesc(false)); saveSpec(spec); } }","preventionTips":["Always use ascending order for clustering keys","Scrub direction flags when migrating specs from other systems","Disable direction selection for clustering in custom tooling","Prefer reordering columns over reversing sort direction"],"tags":["druid","catalog","datasource","clustering"],"backgroundTag":"invalid-config-value","analyzedSha":"9b90983fd291f26935af934383ce360473179e4d","analyzedAt":"2026-09-07T13:32:30.957Z","contentChangedAt":"2026-09-07T13:32:30.957Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}