apache/iceberg · error · ValidationException
Cannot validate against a table
Error message
Cannot validate %s against a table
What it means
UpdateRequirement is the interface for commit requirements (assertions on base metadata). Its default validate(TableMetadata) throws ValidationException because each concrete requirement either validates against a table or a view, not both. Calling validate(base) with a TableMetadata on a requirement that only supports views (or calling the interface default directly on an unsupported subtype) hits this throw.
Solutions
- Dispatch view-scoped requirements to validate(ViewMetadata) instead of validate(TableMetadata).
- Use the requirement's concrete type (e.g., AssertViewUUID) to decide which metadata type to pass.
- Upgrade Iceberg if a requirement subclass is missing its table-side validate override.
Example fix
// before
requirement.validate(tableMetadata); // view-only requirement
// after
if (requirement instanceof UpdateRequirement.ViewRequirement) {
requirement.validate(viewMetadata);
} else {
requirement.validate(tableMetadata);
} Defensive patterns
Strategy: type-guard
Validate before calling
boolean isViewScoped = requirement instanceof UpdateRequirement.ViewRequirement;
Type guard
if (requirement instanceof UpdateRequirement.ViewRequirement vr) { vr.validate(viewMetadata); } else { requirement.validate(tableMetadata); } Try / catch
try { requirement.validate(base); } catch (ValidationException e) { /* wrong metadata type for this requirement; re-dispatch */ } Prevention
- Dispatch requirements by their target metadata type, not a single validate call.
- Group view requirements separately from table requirements during commit apply.
- Ensure every concrete requirement overrides the applicable validate().
When it happens
Trigger: Invoking UpdateRequirement.validate(TableMetadata) on a requirement subclass that only overrides validate(ViewMetadata), or on a stub/default implementation.
Common situations: Generic commit-apply code that dispatches all requirements against table metadata without checking whether the requirement is view-scoped.
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 view
- 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/0c288526751b5548.
Report an issue: GitHub.
Appendix: source
Thrown at core/src/main/java/org/apache/iceberg/UpdateRequirement.java:29
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* 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");
}
}
}View on GitHub (pinned to 86d9c8fc54)