{"record":{"id":"a88ddb721448b296","repo":"apache/iceberg","slug":"ignoring-as-such-values-are-constant-within-a","errorCode":null,"errorMessage":"Ignoring '{}' as such values are constant within a partition","messagePattern":"Ignoring '(.+?)' as such values are constant within a partition","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"spark/v3.5/spark/src/main/java/org/apache/iceberg/spark/actions/SparkZOrderFileRewriteRunner.java","lineNumber":199,"sourceCode":"            ? schema.findField(Z_COLUMN) == null\n            : schema.caseInsensitiveFindField(Z_COLUMN) == null,\n        \"Cannot zorder because the table has a column named '%s', which conflicts with Iceberg's internal Z-order column name\",\n        Z_COLUMN);\n\n    List<String> validZOrderColNames = Lists.newArrayList();\n\n    for (String colName : inputZOrderColNames) {\n      Types.NestedField field =\n          caseSensitive ? schema.findField(colName) : schema.caseInsensitiveFindField(colName);\n      Preconditions.checkArgument(\n          field != null,\n          \"Cannot find column '%s' in table schema (case sensitive = %s): %s\",\n          colName,\n          caseSensitive,\n          schema.asStruct());\n\n      if (identityPartitionFieldIds.contains(field.fieldId())) {\n        LOG.warn(\"Ignoring '{}' as such values are constant within a partition\", colName);\n      } else {\n        validZOrderColNames.add(colName);\n      }\n    }\n\n    Preconditions.checkArgument(\n        !validZOrderColNames.isEmpty(),\n        \"Cannot ZOrder, all columns provided were identity partition columns and cannot be used\");\n\n    return validZOrderColNames;\n  }\n}\n","sourceCodeStart":181,"sourceCodeEnd":212,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/spark/v3.5/spark/src/main/java/org/apache/iceberg/spark/actions/SparkZOrderFileRewriteRunner.java#L181-L212","documentation":"Spark Z-Order rewrite runner skips columns whose values are constant within each partition, because sorting by such columns gives no benefit inside a partition's files. This is a LOG.warn (not an exception) emitted while building the valid Z-Order column list; the rewrite continues with the remaining columns.","triggerScenarios":"Calling rewrite_data_files with a Z_ORDER BY option containing a column that is an identity partition field.","commonSituations":"Users z-order by a partition key column (e.g. date or region) assuming it will cluster data, when it is already fully clustered per partition.","solutions":["Remove identity partition columns from the Z_ORDER BY option","Keep only non-partition columns in z_order_by to get actual intra-partition clustering","If ordering across the whole table is desired, change partitioning so the column is not an identity partition field"],"exampleFix":"-- before\nCALL iceberg.system.rewrite_data_files(table => 'db.t', options => map('strategy','sort'), where => 'true', strategy => 'zorder', z_order_by => 'date, id')\n-- after\nCALL iceberg.system.rewrite_data_files(table => 'db.t', strategy => 'zorder', z_order_by => 'id')","handlingStrategy":"validation","validationCode":"Set<PartitionField> identity = table.spec().identitySourceIds().isEmpty() ? Set.of() : table.spec().fields().stream().filter(f -> f.transform().isIdentity()).collect(Collectors.toSet()); List<String> valid = zOrderCols.stream().filter(c -> !identity.contains(table.schema().findField(c))).collect(Collectors.toList());","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Exclude identity partition columns from z_order_by","Check table.spec() partition transforms before choosing sort columns"],"tags":["spark","zorder","partitioning","compaction"],"backgroundTag":"invalid-argument-value","analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}