/*
 * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
 * or more contributor license agreements. Licensed under the Elastic License;
 * you may not use this file except in compliance with the Elastic License.
 */
package org.elasticsearch.xpack.sql.expression.function.scalar.processor.definition;

import org.elasticsearch.xpack.sql.execution.search.FieldExtraction;
import org.elasticsearch.xpack.sql.execution.search.SqlSourceBuilder;
import org.elasticsearch.xpack.sql.expression.Attribute;
import org.elasticsearch.xpack.sql.expression.Expression;
import org.elasticsearch.xpack.sql.expression.function.scalar.processor.runtime.Processor;
import org.elasticsearch.xpack.sql.querydsl.container.ColumnReference;
import org.elasticsearch.xpack.sql.tree.Node;

import java.util.List;

public abstract class ProcessorDefinition extends Node<ProcessorDefinition> implements FieldExtraction {

    private final Expression expression;

    public ProcessorDefinition(Expression expression, List<ProcessorDefinition> children) {
        super(children);
        this.expression = expression;
    }

    public Expression expression() {
        return expression;
    }

    public abstract boolean resolved();

    public abstract Processor asProcessor();

    @Override
    public void collectFields(SqlSourceBuilder sourceBuilder) {
        // No fields needed
    }

    public abstract ProcessorDefinition resolveAttributes(AttributeResolver resolver);
    public interface AttributeResolver {
        ColumnReference resolve(Attribute attribute);
    }
}

@@ -1381,32 +1381,306 @@
 s needed%0A    %7D%0A%0A
+    /**%0A     * Resolve %7B@link Attribute%7Ds which are unprocessable into%0A     * %7B@link ColumnReference%7Ds which are processable.%0A     *%0A     * @return %7B@code this%7D if the resolution doesn't change the%0A     *      definition, a new %7B@link ProcessorDefinition%7D otherwise%0A     */%0A
     public abstr

Document reference equality requirement