apache/iceberg · error · ValidationException
Cannot validate against a view
Error message
Cannot validate %s against a view
What it means
The interface default validate(ViewMetadata) throws ValidationException when a requirement that only supports tables is validated against view metadata. Each concrete UpdateRequirement implements validate for the metadata type it applies to; passing the wrong type reaches this default and reports the requirement's class name.
Solutions
- Route table-scoped requirements to validate(TableMetadata) only.
- Check the requirement class before choosing which metadata object to validate against.
- Implement the missing validate(ViewMetadata) override if this is a new requirement type.
Example fix
// before
requirement.validate(viewMetadata); // table-only requirement
// after
if (requirement instanceof UpdateRequirement.ViewRequirement) {
requirement.validate(viewMetadata);
} else {
requirement.validate(tableMetadata);
} Defensive patterns
Strategy: type-guard
Validate before calling
boolean isTableScoped = !(requirement instanceof UpdateRequirement.ViewRequirement);
Type guard
if (requirement instanceof UpdateRequirement.ViewRequirement) { requirement.validate(viewMetadata); } else { requirement.validate(tableMetadata); } Try / catch
try { requirement.validate(viewMetadata); } catch (ValidationException e) { /* table-only requirement applied to a view; re-dispatch */ } Prevention
- Never apply table requirements during view commits.
- Separate requirement lists per metadata kind before validation.
- Check requirement class hierarchy before dispatching.
When it happens
Trigger: Calling UpdateRequirement.validate(ViewMetadata) on a table-scoped requirement such as AssertTableUUID or AssertRefSnapshotID.
Common situations: Shared commit client code applying table requirements during view commits, or vice versa, after refactoring to support views.
Understand the failure class
Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.
Related errors
- Cannot validate against a table
- Cannot convert date
- Cannot convert dict encoded field
- Cannot convert time
- Cannot convert timestamp
AI-assisted analysis of apache/iceberg@86d9c8fc54 (2026-09-12).
Data as JSON: /api/errors/28436d51d1774ff6.
Report an issue: GitHub.
Appendix: source
Thrown at core/src/main/java/org/apache/iceberg/UpdateRequirement.java:34
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.iceberg;
import org.apache.iceberg.exceptions.CommitFailedException;
import org.apache.iceberg.exceptions.ValidationException;
import org.apache.iceberg.relocated.com.google.common.base.Preconditions;
import org.apache.iceberg.view.ViewMetadata;
/** Represents a requirement for a {@link MetadataUpdate} */
public interface UpdateRequirement {
default void validate(TableMetadata base) {
throw new ValidationException(
"Cannot validate %s against a table", this.getClass().getSimpleName());
}
default void validate(ViewMetadata base) {
throw new ValidationException(
"Cannot validate %s against a view", this.getClass().getSimpleName());
}
class AssertTableDoesNotExist implements UpdateRequirement {
public AssertTableDoesNotExist() {}
@Override
public void validate(TableMetadata base) {
if (base != null) {
throw new CommitFailedException("Requirement failed: table already exists");
}
}
}
class AssertTableUUID implements UpdateRequirement {
private final String uuid;
public AssertTableUUID(String uuid) {View on GitHub (pinned to 86d9c8fc54)