org.elasticsearch.xpack.esql.optimizer.PhysicalVerifier Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of x-pack-esql Show documentation
Show all versions of x-pack-esql Show documentation
The plugin that powers ESQL for Elasticsearch
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
package org.elasticsearch.xpack.esql.optimizer;
import org.elasticsearch.xpack.esql.core.common.Failure;
import org.elasticsearch.xpack.esql.core.expression.Attribute;
import org.elasticsearch.xpack.esql.core.expression.Expressions;
import org.elasticsearch.xpack.esql.optimizer.OptimizerRules.PhysicalPlanDependencyCheck;
import org.elasticsearch.xpack.esql.plan.physical.FieldExtractExec;
import org.elasticsearch.xpack.esql.plan.physical.PhysicalPlan;
import java.util.Collection;
import java.util.LinkedHashSet;
import java.util.Set;
import static org.elasticsearch.xpack.esql.core.common.Failure.fail;
/** Physical plan verifier. */
public final class PhysicalVerifier {
public static final PhysicalVerifier INSTANCE = new PhysicalVerifier();
private static final PhysicalPlanDependencyCheck DEPENDENCY_CHECK = new PhysicalPlanDependencyCheck();
private PhysicalVerifier() {}
/** Verifies the physical plan. */
public Collection verify(PhysicalPlan plan) {
Set failures = new LinkedHashSet<>();
plan.forEachDown(p -> {
// FIXME: re-enable
// DEPENDENCY_CHECK.checkPlan(p, failures);
if (p instanceof FieldExtractExec fieldExtractExec) {
Attribute sourceAttribute = fieldExtractExec.sourceAttribute();
if (sourceAttribute == null) {
failures.add(
fail(
fieldExtractExec,
"Need to add field extractor for [{}] but cannot detect source attributes from node [{}]",
Expressions.names(fieldExtractExec.attributesToExtract()),
fieldExtractExec.child()
)
);
}
}
});
return failures;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy