Переглянути джерело

ESQL: Drop unused parts of esql-core package (#110174)

This drops a bunch of unused code in the esql-core package that was used
to power SQL and EQL. We copied it when we forked the shared ql code
into esql-core. But we don't need it.
Nik Everett 1 рік тому
батько
коміт
573e44ab2a
25 змінених файлів з 0 додано та 1607 видалено
  1. 0 23
      x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/execution/search/AggRef.java
  2. 0 28
      x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/execution/search/FieldExtraction.java
  3. 0 62
      x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/execution/search/QlSourceBuilder.java
  4. 0 269
      x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/execution/search/extractor/AbstractFieldHitExtractor.java
  5. 0 18
      x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/execution/search/extractor/BucketExtractor.java
  6. 0 29
      x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/execution/search/extractor/BucketExtractors.java
  7. 0 106
      x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/execution/search/extractor/ComputingExtractor.java
  8. 0 79
      x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/execution/search/extractor/ConstantExtractor.java
  9. 0 27
      x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/execution/search/extractor/HitExtractor.java
  10. 0 29
      x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/execution/search/extractor/HitExtractors.java
  11. 0 54
      x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/execution/search/extractor/TotalHitsExtractor.java
  12. 0 13
      x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/function/FunctionTypeRegistry.java
  13. 0 47
      x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/function/scalar/BaseSurrogateFunction.java
  14. 0 28
      x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/function/scalar/ConfigurationFunction.java
  15. 0 19
      x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/function/scalar/IntervalScripting.java
  16. 0 83
      x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/function/scalar/string/BinaryComparisonCaseInsensitiveFunction.java
  17. 0 39
      x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/function/scalar/string/CaseInsensitiveScalarFunction.java
  18. 0 108
      x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/function/scalar/string/StartsWithFunctionProcessor.java
  19. 0 170
      x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/function/scalar/whitelist/InternalQlScriptUtils.java
  20. 0 77
      x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/gen/processor/BucketExtractorProcessor.java
  21. 0 77
      x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/gen/processor/HitExtractorProcessor.java
  22. 0 4
      x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/processor/Processors.java
  23. 0 129
      x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/type/Schema.java
  24. 0 53
      x-pack/plugin/esql-core/src/test/java/org/elasticsearch/xpack/esql/core/execution/search/extractor/ConstantExtractorTests.java
  25. 0 36
      x-pack/plugin/esql-core/src/test/java/org/elasticsearch/xpack/esql/core/expression/function/FunctionRegistryTests.java

+ 0 - 23
x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/execution/search/AggRef.java

@@ -1,23 +0,0 @@
-/*
- * 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.core.execution.search;
-
-/**
- * Reference to a ES aggregation (which can be either a GROUP BY or Metric agg).
- */
-public abstract class AggRef implements FieldExtraction {
-
-    @Override
-    public void collectFields(QlSourceBuilder sourceBuilder) {
-        // Aggregations do not need any special fields
-    }
-
-    @Override
-    public boolean supportedByAggsOnlyQuery() {
-        return true;
-    }
-}

+ 0 - 28
x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/execution/search/FieldExtraction.java

@@ -1,28 +0,0 @@
-/*
- * 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.core.execution.search;
-
-import org.elasticsearch.search.builder.SearchSourceBuilder;
-
-/**
- * An interface for something that needs to extract field(s) from a result.
- */
-public interface FieldExtraction {
-
-    /**
-     * Add whatever is necessary to the {@link SearchSourceBuilder}
-     * in order to fetch the field. This can include tracking the score,
-     * {@code _source} fields, doc values fields, and script fields.
-     */
-    void collectFields(QlSourceBuilder sourceBuilder);
-
-    /**
-     * Is this aggregation supported in an "aggregation only" query
-     * ({@code true}) or should it force a scroll query ({@code false})?
-     */
-    boolean supportedByAggsOnlyQuery();
-}

+ 0 - 62
x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/execution/search/QlSourceBuilder.java

@@ -1,62 +0,0 @@
-/*
- * 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.core.execution.search;
-
-import org.elasticsearch.script.Script;
-import org.elasticsearch.search.builder.SearchSourceBuilder;
-import org.elasticsearch.search.fetch.subphase.FieldAndFormat;
-
-import java.util.LinkedHashMap;
-import java.util.LinkedHashSet;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * A {@code SqlSourceBuilder} is a builder object passed to objects implementing
- * {@link FieldExtraction} that can "build" whatever needs to be extracted from
- * the resulting ES document as a field.
- */
-public class QlSourceBuilder {
-    // The LinkedHashMaps preserve the order of the fields in the response
-    private final Set<FieldAndFormat> fetchFields = new LinkedHashSet<>();
-    private final Map<String, Script> scriptFields = new LinkedHashMap<>();
-
-    boolean trackScores = false;
-
-    public QlSourceBuilder() {}
-
-    /**
-     * Turns on returning the {@code _score} for documents.
-     */
-    public void trackScores() {
-        this.trackScores = true;
-    }
-
-    /**
-     * Retrieve the requested field using the "fields" API
-     */
-    public void addFetchField(String field, String format) {
-        fetchFields.add(new FieldAndFormat(field, format));
-    }
-
-    /**
-     * Return the given field as a script field with the supplied script
-     */
-    public void addScriptField(String name, Script script) {
-        scriptFields.put(name, script);
-    }
-
-    /**
-     * Collect the necessary fields, modifying the {@code SearchSourceBuilder}
-     * to retrieve them from the document.
-     */
-    public void build(SearchSourceBuilder sourceBuilder) {
-        sourceBuilder.trackScores(this.trackScores);
-        fetchFields.forEach(field -> sourceBuilder.fetchField(new FieldAndFormat(field.field, field.format, null)));
-        scriptFields.forEach(sourceBuilder::scriptField);
-    }
-}

+ 0 - 269
x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/execution/search/extractor/AbstractFieldHitExtractor.java

@@ -1,269 +0,0 @@
-/*
- * 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.core.execution.search.extractor;
-
-import org.elasticsearch.TransportVersions;
-import org.elasticsearch.common.document.DocumentField;
-import org.elasticsearch.common.io.stream.StreamInput;
-import org.elasticsearch.common.io.stream.StreamOutput;
-import org.elasticsearch.search.SearchHit;
-import org.elasticsearch.xpack.esql.core.InvalidArgumentException;
-import org.elasticsearch.xpack.esql.core.QlIllegalArgumentException;
-import org.elasticsearch.xpack.esql.core.type.DataType;
-
-import java.io.IOException;
-import java.time.ZoneId;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-
-/**
- * Extractor for ES fields. Works for both 'normal' fields but also nested ones (which require hitName to be set).
- * The latter is used as metadata in assembling the results in the tabular response.
- */
-public abstract class AbstractFieldHitExtractor implements HitExtractor {
-
-    private final String fieldName, hitName;
-    private final DataType dataType;
-    private final ZoneId zoneId;
-
-    protected MultiValueSupport multiValueSupport;
-
-    public enum MultiValueSupport {
-        NONE,
-        LENIENT,
-        FULL
-    }
-
-    protected AbstractFieldHitExtractor(String name, DataType dataType, ZoneId zoneId) {
-        this(name, dataType, zoneId, null, MultiValueSupport.NONE);
-    }
-
-    protected AbstractFieldHitExtractor(String name, DataType dataType, ZoneId zoneId, MultiValueSupport multiValueSupport) {
-        this(name, dataType, zoneId, null, multiValueSupport);
-    }
-
-    protected AbstractFieldHitExtractor(
-        String name,
-        DataType dataType,
-        ZoneId zoneId,
-        String hitName,
-        MultiValueSupport multiValueSupport
-    ) {
-        this.fieldName = name;
-        this.dataType = dataType;
-        this.zoneId = zoneId;
-        this.multiValueSupport = multiValueSupport;
-        this.hitName = hitName;
-
-        if (hitName != null) {
-            if (name.contains(hitName) == false) {
-                throw new QlIllegalArgumentException("Hitname [{}] specified but not part of the name [{}]", hitName, name);
-            }
-        }
-    }
-
-    @SuppressWarnings("this-escape")
-    protected AbstractFieldHitExtractor(StreamInput in) throws IOException {
-        fieldName = in.readString();
-        String typeName = in.readOptionalString();
-        dataType = typeName != null ? loadTypeFromName(typeName) : null;
-        hitName = in.readOptionalString();
-        if (in.getTransportVersion().before(TransportVersions.V_8_6_0)) {
-            this.multiValueSupport = in.readBoolean() ? MultiValueSupport.LENIENT : MultiValueSupport.NONE;
-        } else {
-            this.multiValueSupport = in.readEnum(MultiValueSupport.class);
-        }
-        zoneId = readZoneId(in);
-    }
-
-    protected DataType loadTypeFromName(String typeName) {
-        return DataType.fromTypeName(typeName);
-    }
-
-    protected abstract ZoneId readZoneId(StreamInput in) throws IOException;
-
-    @Override
-    public void writeTo(StreamOutput out) throws IOException {
-        out.writeString(fieldName);
-        out.writeOptionalString(dataType == null ? null : dataType.typeName());
-        out.writeOptionalString(hitName);
-        if (out.getTransportVersion().before(TransportVersions.V_8_6_0)) {
-            out.writeBoolean(multiValueSupport != MultiValueSupport.NONE);
-        } else {
-            out.writeEnum(multiValueSupport);
-        }
-
-    }
-
-    @Override
-    public Object extract(SearchHit hit) {
-        Object value = null;
-        DocumentField field = null;
-        if (hitName != null) {
-            value = unwrapFieldsMultiValue(extractNestedField(hit));
-        } else {
-            field = hit.field(fieldName);
-            if (field != null) {
-                value = unwrapFieldsMultiValue(field.getValues());
-            }
-        }
-        return value;
-    }
-
-    /*
-     * For a path of fields like root.nested1.nested2.leaf where nested1 and nested2 are nested field types,
-     * fieldName is root.nested1.nested2.leaf, while hitName is root.nested1.nested2
-     * We first look for root.nested1.nested2 or root.nested1 or root in the SearchHit until we find something.
-     * If the DocumentField lives under "root.nested1" the remaining path to search for (in the DocumentField itself) is nested2.
-     * After this step is done, what remains to be done is just getting the leaf values.
-     */
-    @SuppressWarnings("unchecked")
-    private Object extractNestedField(SearchHit hit) {
-        Object value;
-        DocumentField field;
-        String tempHitname = hitName;
-        List<String> remainingPath = new ArrayList<>();
-        // first, search for the "root" DocumentField under which the remaining path of nested document values is
-        while ((field = hit.field(tempHitname)) == null) {
-            int indexOfDot = tempHitname.lastIndexOf('.');
-            if (indexOfDot < 0) {// there is no such field in the hit
-                return null;
-            }
-            remainingPath.add(0, tempHitname.substring(indexOfDot + 1));
-            tempHitname = tempHitname.substring(0, indexOfDot);
-        }
-        // then dig into DocumentField's structure until we reach the field we are interested into
-        if (remainingPath.size() > 0) {
-            List<Object> values = field.getValues();
-            Iterator<String> pathIterator = remainingPath.iterator();
-            while (pathIterator.hasNext()) {
-                String pathElement = pathIterator.next();
-                Map<String, List<Object>> elements = (Map<String, List<Object>>) values.get(0);
-                values = elements.get(pathElement);
-                /*
-                 * if this path is not found it means we hit another nested document (inner_root_1.inner_root_2.nested_field_2)
-                 * something like this
-                 * "root_field_1.root_field_2.nested_field_1" : [
-                 *     {
-                 *       "inner_root_1.inner_root_2.nested_field_2" : [
-                 *         {
-                 *           "leaf_field" : [
-                 *             "abc2"
-                 *           ]
-                 * So, start re-building the path until the right one is found, ie inner_root_1.inner_root_2......
-                 */
-                while (values == null) {
-                    pathElement += "." + pathIterator.next();
-                    values = elements.get(pathElement);
-                }
-            }
-            value = ((Map<String, Object>) values.get(0)).get(fieldName.substring(hitName.length() + 1));
-        } else {
-            value = field.getValues();
-        }
-        return value;
-    }
-
-    protected Object unwrapFieldsMultiValue(Object values) {
-        if (values == null) {
-            return null;
-        }
-        if (values instanceof Map && hitName != null) {
-            // extract the sub-field from a nested field (dep.dep_name -> dep_name)
-            return unwrapFieldsMultiValue(((Map<?, ?>) values).get(fieldName.substring(hitName.length() + 1)));
-        }
-        if (values instanceof List<?> list) {
-            if (list.isEmpty()) {
-                return null;
-            } else {
-                if (isPrimitive(list) == false) {
-                    if (list.size() == 1 || multiValueSupport == MultiValueSupport.LENIENT) {
-                        return unwrapFieldsMultiValue(list.get(0));
-                    } else if (multiValueSupport == MultiValueSupport.FULL) {
-                        List<Object> unwrappedValues = new ArrayList<>();
-                        for (Object value : list) {
-                            unwrappedValues.add(unwrapFieldsMultiValue(value));
-                        }
-                        values = unwrappedValues;
-                    } else {
-                        // missing `field_multi_value_leniency` setting
-                        throw new InvalidArgumentException("Arrays (returned by [{}]) are not supported", fieldName);
-                    }
-                }
-            }
-        }
-
-        Object unwrapped = unwrapCustomValue(values);
-        if (unwrapped != null && isListOfNulls(unwrapped) == false) {
-            return unwrapped;
-        }
-
-        return values;
-    }
-
-    private static boolean isListOfNulls(Object unwrapped) {
-        if (unwrapped instanceof List<?> list) {
-            if (list.size() == 0) {
-                return false;
-            }
-            for (Object o : list) {
-                if (o != null) {
-                    return false;
-                }
-            }
-            return true;
-        }
-        return false;
-    }
-
-    protected abstract Object unwrapCustomValue(Object values);
-
-    protected abstract boolean isPrimitive(List<?> list);
-
-    @Override
-    public String hitName() {
-        return hitName;
-    }
-
-    public String fieldName() {
-        return fieldName;
-    }
-
-    public ZoneId zoneId() {
-        return zoneId;
-    }
-
-    public DataType dataType() {
-        return dataType;
-    }
-
-    public MultiValueSupport multiValueSupport() {
-        return multiValueSupport;
-    }
-
-    @Override
-    public String toString() {
-        return fieldName + "@" + hitName + "@" + zoneId;
-    }
-
-    @Override
-    public boolean equals(Object obj) {
-        if (obj == null || obj.getClass() != getClass()) {
-            return false;
-        }
-        AbstractFieldHitExtractor other = (AbstractFieldHitExtractor) obj;
-        return fieldName.equals(other.fieldName) && hitName.equals(other.hitName) && multiValueSupport == other.multiValueSupport;
-    }
-
-    @Override
-    public int hashCode() {
-        return Objects.hash(fieldName, hitName, multiValueSupport);
-    }
-}

+ 0 - 18
x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/execution/search/extractor/BucketExtractor.java

@@ -1,18 +0,0 @@
-/*
- * 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.core.execution.search.extractor;
-
-import org.elasticsearch.common.io.stream.NamedWriteable;
-import org.elasticsearch.search.aggregations.bucket.MultiBucketsAggregation.Bucket;
-
-/**
- * Extracts an aggregation value from a {@link Bucket}.
- */
-public interface BucketExtractor extends NamedWriteable {
-
-    Object extract(Bucket bucket);
-}

+ 0 - 29
x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/execution/search/extractor/BucketExtractors.java

@@ -1,29 +0,0 @@
-/*
- * 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.core.execution.search.extractor;
-
-import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
-import org.elasticsearch.common.io.stream.NamedWriteableRegistry.Entry;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public final class BucketExtractors {
-
-    private BucketExtractors() {}
-
-    /**
-     * All of the named writeables needed to deserialize the instances of
-     * {@linkplain BucketExtractor}s.
-     */
-    public static List<NamedWriteableRegistry.Entry> getNamedWriteables() {
-        List<NamedWriteableRegistry.Entry> entries = new ArrayList<>();
-        entries.add(new Entry(BucketExtractor.class, ComputingExtractor.NAME, ComputingExtractor::new));
-        entries.add(new Entry(BucketExtractor.class, ConstantExtractor.NAME, ConstantExtractor::new));
-        return entries;
-    }
-}

+ 0 - 106
x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/execution/search/extractor/ComputingExtractor.java

@@ -1,106 +0,0 @@
-/*
- * 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.core.execution.search.extractor;
-
-import org.elasticsearch.common.io.stream.StreamInput;
-import org.elasticsearch.common.io.stream.StreamOutput;
-import org.elasticsearch.search.SearchHit;
-import org.elasticsearch.search.aggregations.bucket.MultiBucketsAggregation.Bucket;
-import org.elasticsearch.xpack.esql.core.expression.gen.processor.HitExtractorProcessor;
-import org.elasticsearch.xpack.esql.core.expression.gen.processor.Processor;
-
-import java.io.IOException;
-import java.util.Objects;
-
-/**
- * Hit/BucketExtractor that delegates to a processor. The difference between this class
- * and {@link HitExtractorProcessor} is that the latter is used inside a
- * {@link Processor} tree as a leaf (and thus can effectively parse the
- * {@link SearchHit} while this class is used when scrolling and passing down
- * the results.
- *
- * In the future, the processor might be used across the board for all columns
- * to reduce API complexity (and keep the {@link HitExtractor} only as an
- * internal implementation detail).
- */
-public class ComputingExtractor implements HitExtractor, BucketExtractor {
-    /**
-     * Stands for {@code comPuting}. We try to use short names for {@link HitExtractor}s
-     * to save a few bytes when when we send them back to the user.
-     */
-    static final String NAME = "p";
-    private final Processor processor;
-    private final String hitName;
-
-    public ComputingExtractor(Processor processor) {
-        this(processor, null);
-    }
-
-    public ComputingExtractor(Processor processor, String hitName) {
-        this.processor = processor;
-        this.hitName = hitName;
-    }
-
-    // Visibility required for tests
-    public ComputingExtractor(StreamInput in) throws IOException {
-        processor = in.readNamedWriteable(Processor.class);
-        hitName = in.readOptionalString();
-    }
-
-    @Override
-    public void writeTo(StreamOutput out) throws IOException {
-        out.writeNamedWriteable(processor);
-        out.writeOptionalString(hitName);
-    }
-
-    @Override
-    public String getWriteableName() {
-        return NAME;
-    }
-
-    public Processor processor() {
-        return processor;
-    }
-
-    public Object extract(Object input) {
-        return processor.process(input);
-    }
-
-    @Override
-    public Object extract(Bucket bucket) {
-        return processor.process(bucket);
-    }
-
-    @Override
-    public Object extract(SearchHit hit) {
-        return processor.process(hit);
-    }
-
-    @Override
-    public String hitName() {
-        return hitName;
-    }
-
-    @Override
-    public boolean equals(Object obj) {
-        if (obj == null || obj.getClass() != getClass()) {
-            return false;
-        }
-        ComputingExtractor other = (ComputingExtractor) obj;
-        return Objects.equals(processor, other.processor) && Objects.equals(hitName, other.hitName);
-    }
-
-    @Override
-    public int hashCode() {
-        return Objects.hash(processor, hitName);
-    }
-
-    @Override
-    public String toString() {
-        return processor.toString();
-    }
-}

+ 0 - 79
x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/execution/search/extractor/ConstantExtractor.java

@@ -1,79 +0,0 @@
-/*
- * 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.core.execution.search.extractor;
-
-import org.elasticsearch.common.io.stream.StreamInput;
-import org.elasticsearch.common.io.stream.StreamOutput;
-import org.elasticsearch.search.SearchHit;
-import org.elasticsearch.search.aggregations.bucket.MultiBucketsAggregation.Bucket;
-
-import java.io.IOException;
-import java.util.Objects;
-
-/**
- * Returns the a constant for every search hit against which it is run.
- */
-public class ConstantExtractor implements HitExtractor, BucketExtractor {
-    /**
-     * Stands for {@code constant}. We try to use short names for {@link HitExtractor}s
-     * to save a few bytes when when we send them back to the user.
-     */
-    static final String NAME = "c";
-    private final Object constant;
-
-    public ConstantExtractor(Object constant) {
-        this.constant = constant;
-    }
-
-    ConstantExtractor(StreamInput in) throws IOException {
-        constant = in.readGenericValue();
-    }
-
-    @Override
-    public void writeTo(StreamOutput out) throws IOException {
-        out.writeGenericValue(constant);
-    }
-
-    @Override
-    public String getWriteableName() {
-        return NAME;
-    }
-
-    @Override
-    public Object extract(SearchHit hit) {
-        return constant;
-    }
-
-    @Override
-    public Object extract(Bucket bucket) {
-        return constant;
-    }
-
-    @Override
-    public String hitName() {
-        return null;
-    }
-
-    @Override
-    public boolean equals(Object obj) {
-        if (obj == null || obj.getClass() != getClass()) {
-            return false;
-        }
-        ConstantExtractor other = (ConstantExtractor) obj;
-        return Objects.equals(constant, other.constant);
-    }
-
-    @Override
-    public int hashCode() {
-        return Objects.hashCode(constant);
-    }
-
-    @Override
-    public String toString() {
-        return "^" + constant;
-    }
-}

+ 0 - 27
x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/execution/search/extractor/HitExtractor.java

@@ -1,27 +0,0 @@
-/*
- * 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.core.execution.search.extractor;
-
-import org.elasticsearch.common.io.stream.NamedWriteable;
-import org.elasticsearch.core.Nullable;
-import org.elasticsearch.search.SearchHit;
-
-/**
- * Extracts a column value from a {@link SearchHit}.
- */
-public interface HitExtractor extends NamedWriteable {
-    /**
-     * Extract the value from a hit.
-     */
-    Object extract(SearchHit hit);
-
-    /**
-     * Name of the inner hit needed by this extractor if it needs one, {@code null} otherwise.
-     */
-    @Nullable
-    String hitName();
-}

+ 0 - 29
x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/execution/search/extractor/HitExtractors.java

@@ -1,29 +0,0 @@
-/*
- * 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.core.execution.search.extractor;
-
-import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
-import org.elasticsearch.common.io.stream.NamedWriteableRegistry.Entry;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public final class HitExtractors {
-
-    private HitExtractors() {}
-
-    /**
-     * All of the named writeables needed to deserialize the instances of
-     * {@linkplain HitExtractor}.
-     */
-    public static List<NamedWriteableRegistry.Entry> getNamedWriteables() {
-        List<NamedWriteableRegistry.Entry> entries = new ArrayList<>();
-        entries.add(new Entry(HitExtractor.class, ConstantExtractor.NAME, ConstantExtractor::new));
-        entries.add(new Entry(HitExtractor.class, ComputingExtractor.NAME, ComputingExtractor::new));
-        return entries;
-    }
-}

+ 0 - 54
x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/execution/search/extractor/TotalHitsExtractor.java

@@ -1,54 +0,0 @@
-/*
- * 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.core.execution.search.extractor;
-
-import org.elasticsearch.common.io.stream.StreamInput;
-import org.elasticsearch.search.SearchHit;
-import org.elasticsearch.search.aggregations.bucket.MultiBucketsAggregation;
-import org.elasticsearch.xpack.esql.core.QlIllegalArgumentException;
-
-import java.io.IOException;
-
-public class TotalHitsExtractor extends ConstantExtractor {
-
-    public TotalHitsExtractor(Long constant) {
-        super(constant);
-    }
-
-    TotalHitsExtractor(StreamInput in) throws IOException {
-        super(in);
-    }
-
-    @Override
-    public Object extract(MultiBucketsAggregation.Bucket bucket) {
-        return validate(super.extract(bucket));
-    }
-
-    @Override
-    public Object extract(SearchHit hit) {
-        return validate(super.extract(hit));
-    }
-
-    private static Object validate(Object value) {
-        if (Number.class.isInstance(value) == false) {
-            throw new QlIllegalArgumentException(
-                "Inconsistent total hits count handling, expected a numeric value but found a {}: {}",
-                value == null ? null : value.getClass().getSimpleName(),
-                value
-            );
-        }
-        if (((Number) value).longValue() < 0) {
-            throw new QlIllegalArgumentException(
-                "Inconsistent total hits count handling, expected a non-negative value but found {}",
-                value
-            );
-        }
-        return value;
-    }
-
-}

+ 0 - 13
x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/function/FunctionTypeRegistry.java

@@ -1,13 +0,0 @@
-/*
- * 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.core.expression.function;
-
-public interface FunctionTypeRegistry {
-
-    String type(Class<? extends Function> clazz);
-}

+ 0 - 47
x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/function/scalar/BaseSurrogateFunction.java

@@ -1,47 +0,0 @@
-/*
- * 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.core.expression.function.scalar;
-
-import org.elasticsearch.xpack.esql.core.expression.Expression;
-import org.elasticsearch.xpack.esql.core.tree.Source;
-
-import java.util.List;
-
-public abstract class BaseSurrogateFunction extends ScalarFunction implements SurrogateFunction {
-
-    private ScalarFunction lazySubstitute;
-
-    public BaseSurrogateFunction(Source source) {
-        super(source);
-    }
-
-    public BaseSurrogateFunction(Source source, List<Expression> fields) {
-        super(source, fields);
-    }
-
-    @Override
-    public ScalarFunction substitute() {
-        if (lazySubstitute == null) {
-            lazySubstitute = makeSubstitute();
-        }
-        return lazySubstitute;
-    }
-
-    protected abstract ScalarFunction makeSubstitute();
-
-    @Override
-    public boolean foldable() {
-        return substitute().foldable();
-    }
-
-    @Override
-    public Object fold() {
-        return substitute().fold();
-    }
-
-}

+ 0 - 28
x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/function/scalar/ConfigurationFunction.java

@@ -1,28 +0,0 @@
-/*
- * 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.core.expression.function.scalar;
-
-import org.elasticsearch.xpack.esql.core.expression.Expression;
-import org.elasticsearch.xpack.esql.core.session.Configuration;
-import org.elasticsearch.xpack.esql.core.tree.Source;
-
-import java.util.List;
-
-public abstract class ConfigurationFunction extends ScalarFunction {
-
-    private final Configuration configuration;
-
-    protected ConfigurationFunction(Source source, List<Expression> fields, Configuration configuration) {
-        super(source, fields);
-        this.configuration = configuration;
-    }
-
-    public Configuration configuration() {
-        return configuration;
-    }
-}

+ 0 - 19
x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/function/scalar/IntervalScripting.java

@@ -1,19 +0,0 @@
-/*
- * 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.core.expression.function.scalar;
-
-// FIXME: accessor interface until making script generation pluggable
-public interface IntervalScripting {
-
-    String script();
-
-    String value();
-
-    String typeName();
-
-}

+ 0 - 83
x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/function/scalar/string/BinaryComparisonCaseInsensitiveFunction.java

@@ -1,83 +0,0 @@
-/*
- * 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.core.expression.function.scalar.string;
-
-import org.elasticsearch.xpack.esql.core.expression.Expression;
-import org.elasticsearch.xpack.esql.core.tree.Source;
-import org.elasticsearch.xpack.esql.core.type.DataType;
-
-import java.util.Objects;
-
-import static java.util.Arrays.asList;
-import static org.elasticsearch.xpack.esql.core.expression.TypeResolutions.ParamOrdinal.FIRST;
-import static org.elasticsearch.xpack.esql.core.expression.TypeResolutions.ParamOrdinal.SECOND;
-import static org.elasticsearch.xpack.esql.core.expression.TypeResolutions.isStringAndExact;
-
-public abstract class BinaryComparisonCaseInsensitiveFunction extends CaseInsensitiveScalarFunction {
-
-    private final Expression left, right;
-
-    protected BinaryComparisonCaseInsensitiveFunction(Source source, Expression left, Expression right, boolean caseInsensitive) {
-        super(source, asList(left, right), caseInsensitive);
-        this.left = left;
-        this.right = right;
-    }
-
-    @Override
-    protected TypeResolution resolveType() {
-        if (childrenResolved() == false) {
-            return new TypeResolution("Unresolved children");
-        }
-
-        TypeResolution sourceResolution = isStringAndExact(left, sourceText(), FIRST);
-        if (sourceResolution.unresolved()) {
-            return sourceResolution;
-        }
-
-        return isStringAndExact(right, sourceText(), SECOND);
-    }
-
-    public Expression left() {
-        return left;
-    }
-
-    public Expression right() {
-        return right;
-    }
-
-    @Override
-    public DataType dataType() {
-        return DataType.BOOLEAN;
-    }
-
-    @Override
-    public boolean foldable() {
-        return left.foldable() && right.foldable();
-    }
-
-    @Override
-    public int hashCode() {
-        return Objects.hash(left, right, isCaseInsensitive());
-    }
-
-    @Override
-    public boolean equals(Object obj) {
-        if (this == obj) {
-            return true;
-        }
-
-        if (obj == null || getClass() != obj.getClass()) {
-            return false;
-        }
-
-        BinaryComparisonCaseInsensitiveFunction other = (BinaryComparisonCaseInsensitiveFunction) obj;
-        return Objects.equals(left, other.left)
-            && Objects.equals(right, other.right)
-            && Objects.equals(isCaseInsensitive(), other.isCaseInsensitive());
-    }
-}

+ 0 - 39
x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/function/scalar/string/CaseInsensitiveScalarFunction.java

@@ -1,39 +0,0 @@
-/*
- * 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.core.expression.function.scalar.string;
-
-import org.elasticsearch.xpack.esql.core.expression.Expression;
-import org.elasticsearch.xpack.esql.core.expression.function.scalar.ScalarFunction;
-import org.elasticsearch.xpack.esql.core.tree.Source;
-
-import java.util.List;
-import java.util.Objects;
-
-public abstract class CaseInsensitiveScalarFunction extends ScalarFunction {
-
-    private final boolean caseInsensitive;
-
-    protected CaseInsensitiveScalarFunction(Source source, List<Expression> fields, boolean caseInsensitive) {
-        super(source, fields);
-        this.caseInsensitive = caseInsensitive;
-    }
-
-    public boolean isCaseInsensitive() {
-        return caseInsensitive;
-    }
-
-    @Override
-    public int hashCode() {
-        return Objects.hash(super.hashCode(), isCaseInsensitive());
-    }
-
-    @Override
-    public boolean equals(Object other) {
-        return super.equals(other) && Objects.equals(((CaseInsensitiveScalarFunction) other).caseInsensitive, caseInsensitive);
-    }
-}

+ 0 - 108
x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/function/scalar/string/StartsWithFunctionProcessor.java

@@ -1,108 +0,0 @@
-/*
- * 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.core.expression.function.scalar.string;
-
-import org.elasticsearch.common.io.stream.StreamInput;
-import org.elasticsearch.common.io.stream.StreamOutput;
-import org.elasticsearch.xpack.esql.core.QlIllegalArgumentException;
-import org.elasticsearch.xpack.esql.core.expression.gen.processor.Processor;
-
-import java.io.IOException;
-import java.util.Locale;
-import java.util.Objects;
-
-public class StartsWithFunctionProcessor implements Processor {
-
-    public static final String NAME = "sstw";
-
-    private final Processor source;
-    private final Processor pattern;
-    private final boolean caseInsensitive;
-
-    public StartsWithFunctionProcessor(Processor source, Processor pattern, boolean caseInsensitive) {
-        this.source = source;
-        this.pattern = pattern;
-        this.caseInsensitive = caseInsensitive;
-    }
-
-    public StartsWithFunctionProcessor(StreamInput in) throws IOException {
-        source = in.readNamedWriteable(Processor.class);
-        pattern = in.readNamedWriteable(Processor.class);
-        caseInsensitive = in.readBoolean();
-    }
-
-    @Override
-    public final void writeTo(StreamOutput out) throws IOException {
-        out.writeNamedWriteable(source);
-        out.writeNamedWriteable(pattern);
-        out.writeBoolean(caseInsensitive);
-    }
-
-    @Override
-    public Object process(Object input) {
-        return doProcess(source.process(input), pattern.process(input), isCaseInsensitive());
-    }
-
-    public static Object doProcess(Object source, Object pattern, boolean caseInsensitive) {
-        if (source == null) {
-            return null;
-        }
-        if (source instanceof String == false && source instanceof Character == false) {
-            throw new QlIllegalArgumentException("A string/char is required; received [{}]", source);
-        }
-        if (pattern == null) {
-            return null;
-        }
-        if (pattern instanceof String == false && pattern instanceof Character == false) {
-            throw new QlIllegalArgumentException("A string/char is required; received [{}]", pattern);
-        }
-
-        if (caseInsensitive == false) {
-            return source.toString().startsWith(pattern.toString());
-        } else {
-            return source.toString().toLowerCase(Locale.ROOT).startsWith(pattern.toString().toLowerCase(Locale.ROOT));
-        }
-    }
-
-    protected Processor source() {
-        return source;
-    }
-
-    protected Processor pattern() {
-        return pattern;
-    }
-
-    protected boolean isCaseInsensitive() {
-        return caseInsensitive;
-    }
-
-    @Override
-    public boolean equals(Object obj) {
-        if (this == obj) {
-            return true;
-        }
-
-        if (obj == null || getClass() != obj.getClass()) {
-            return false;
-        }
-
-        StartsWithFunctionProcessor other = (StartsWithFunctionProcessor) obj;
-        return Objects.equals(source(), other.source())
-            && Objects.equals(pattern(), other.pattern())
-            && Objects.equals(isCaseInsensitive(), other.isCaseInsensitive());
-    }
-
-    @Override
-    public int hashCode() {
-        return Objects.hash(source(), pattern(), isCaseInsensitive());
-    }
-
-    @Override
-    public String getWriteableName() {
-        return NAME;
-    }
-}

+ 0 - 170
x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/function/scalar/whitelist/InternalQlScriptUtils.java

@@ -1,170 +0,0 @@
-/*
- * 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.core.expression.function.scalar.whitelist;
-
-import org.elasticsearch.index.fielddata.ScriptDocValues;
-import org.elasticsearch.xpack.esql.core.expression.function.scalar.string.StartsWithFunctionProcessor;
-import org.elasticsearch.xpack.esql.core.expression.predicate.logical.BinaryLogicProcessor.BinaryLogicOperation;
-import org.elasticsearch.xpack.esql.core.expression.predicate.logical.NotProcessor;
-import org.elasticsearch.xpack.esql.core.expression.predicate.nulls.CheckNullProcessor.CheckNullOperation;
-import org.elasticsearch.xpack.esql.core.expression.predicate.operator.arithmetic.DefaultBinaryArithmeticOperation;
-import org.elasticsearch.xpack.esql.core.expression.predicate.operator.arithmetic.UnaryArithmeticProcessor.UnaryArithmeticOperation;
-import org.elasticsearch.xpack.esql.core.expression.predicate.operator.comparison.BinaryComparisonProcessor.BinaryComparisonOperation;
-import org.elasticsearch.xpack.esql.core.expression.predicate.operator.comparison.InProcessor;
-import org.elasticsearch.xpack.esql.core.expression.predicate.regex.RegexProcessor.RegexOperation;
-import org.elasticsearch.xpack.esql.core.util.StringUtils;
-
-import java.util.List;
-import java.util.Map;
-
-import static org.elasticsearch.xpack.esql.core.type.DataType.fromTypeName;
-import static org.elasticsearch.xpack.esql.core.type.DataTypeConverter.convert;
-import static org.elasticsearch.xpack.esql.core.type.DataTypeConverter.toUnsignedLong;
-
-public class InternalQlScriptUtils {
-
-    //
-    // Utilities
-    //
-
-    // safe missing mapping/value extractor
-    public static <T> Object docValue(Map<String, ScriptDocValues<T>> doc, String fieldName) {
-        if (doc.containsKey(fieldName)) {
-            ScriptDocValues<T> docValues = doc.get(fieldName);
-            if (docValues.isEmpty() == false) {
-                return docValues.get(0);
-            }
-        }
-        return null;
-    }
-
-    public static boolean nullSafeFilter(Boolean filter) {
-        return filter == null ? false : filter.booleanValue();
-    }
-
-    public static double nullSafeSortNumeric(Number sort) {
-        return sort == null ? 0.0d : sort.doubleValue();
-    }
-
-    public static String nullSafeSortString(Object sort) {
-        return sort == null ? StringUtils.EMPTY : sort.toString();
-    }
-
-    public static Number nullSafeCastNumeric(Number number, String typeName) {
-        return number == null || Double.isNaN(number.doubleValue()) ? null : (Number) convert(number, fromTypeName(typeName));
-    }
-
-    public static Number nullSafeCastToUnsignedLong(Number number) {
-        return number == null || Double.isNaN(number.doubleValue()) ? null : toUnsignedLong(number);
-    }
-
-    //
-    // Operators
-    //
-
-    //
-    // Logical
-    //
-    public static Boolean eq(Object left, Object right) {
-        return BinaryComparisonOperation.EQ.apply(left, right);
-    }
-
-    public static Boolean nulleq(Object left, Object right) {
-        return BinaryComparisonOperation.NULLEQ.apply(left, right);
-    }
-
-    public static Boolean neq(Object left, Object right) {
-        return BinaryComparisonOperation.NEQ.apply(left, right);
-    }
-
-    public static Boolean lt(Object left, Object right) {
-        return BinaryComparisonOperation.LT.apply(left, right);
-    }
-
-    public static Boolean lte(Object left, Object right) {
-        return BinaryComparisonOperation.LTE.apply(left, right);
-    }
-
-    public static Boolean gt(Object left, Object right) {
-        return BinaryComparisonOperation.GT.apply(left, right);
-    }
-
-    public static Boolean gte(Object left, Object right) {
-        return BinaryComparisonOperation.GTE.apply(left, right);
-    }
-
-    public static Boolean in(Object value, List<Object> values) {
-        return InProcessor.apply(value, values);
-    }
-
-    public static Boolean and(Boolean left, Boolean right) {
-        return BinaryLogicOperation.AND.apply(left, right);
-    }
-
-    public static Boolean or(Boolean left, Boolean right) {
-        return BinaryLogicOperation.OR.apply(left, right);
-    }
-
-    public static Boolean not(Boolean expression) {
-        return NotProcessor.apply(expression);
-    }
-
-    public static Boolean isNull(Object expression) {
-        return CheckNullOperation.IS_NULL.test(expression);
-    }
-
-    public static Boolean isNotNull(Object expression) {
-        return CheckNullOperation.IS_NOT_NULL.test(expression);
-    }
-
-    //
-    // Regex
-    //
-    public static Boolean regex(String value, String pattern) {
-        return regex(value, pattern, Boolean.FALSE);
-    }
-
-    public static Boolean regex(String value, String pattern, Boolean caseInsensitive) {
-        // TODO: this needs to be improved to avoid creating the pattern on every call
-        return RegexOperation.match(value, pattern, caseInsensitive);
-    }
-
-    //
-    // Math
-    //
-    public static Number add(Number left, Number right) {
-        return (Number) DefaultBinaryArithmeticOperation.ADD.apply(left, right);
-    }
-
-    public static Number div(Number left, Number right) {
-        return (Number) DefaultBinaryArithmeticOperation.DIV.apply(left, right);
-    }
-
-    public static Number mod(Number left, Number right) {
-        return (Number) DefaultBinaryArithmeticOperation.MOD.apply(left, right);
-    }
-
-    public static Number mul(Number left, Number right) {
-        return (Number) DefaultBinaryArithmeticOperation.MUL.apply(left, right);
-    }
-
-    public static Number neg(Number value) {
-        return UnaryArithmeticOperation.NEGATE.apply(value);
-    }
-
-    public static Number sub(Number left, Number right) {
-        return (Number) DefaultBinaryArithmeticOperation.SUB.apply(left, right);
-    }
-
-    //
-    // String
-    //
-    public static Boolean startsWith(String s, String pattern, Boolean caseInsensitive) {
-        return (Boolean) StartsWithFunctionProcessor.doProcess(s, pattern, caseInsensitive);
-    }
-}

+ 0 - 77
x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/gen/processor/BucketExtractorProcessor.java

@@ -1,77 +0,0 @@
-/*
- * 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.core.expression.gen.processor;
-
-import org.elasticsearch.common.io.stream.StreamInput;
-import org.elasticsearch.common.io.stream.StreamOutput;
-import org.elasticsearch.search.aggregations.bucket.MultiBucketsAggregation.Bucket;
-import org.elasticsearch.xpack.esql.core.QlIllegalArgumentException;
-import org.elasticsearch.xpack.esql.core.execution.search.extractor.BucketExtractor;
-
-import java.io.IOException;
-import java.util.Objects;
-
-/**
- * Processor wrapping an {@link BucketExtractor}, essentially being a source/leaf of a
- * Processor tree.
- */
-public class BucketExtractorProcessor implements Processor {
-
-    public static final String NAME = "a";
-
-    private final BucketExtractor extractor;
-
-    public BucketExtractorProcessor(BucketExtractor extractor) {
-        this.extractor = extractor;
-    }
-
-    public BucketExtractorProcessor(StreamInput in) throws IOException {
-        extractor = in.readNamedWriteable(BucketExtractor.class);
-    }
-
-    @Override
-    public void writeTo(StreamOutput out) throws IOException {
-        out.writeNamedWriteable(extractor);
-    }
-
-    @Override
-    public String getWriteableName() {
-        return NAME;
-    }
-
-    @Override
-    public Object process(Object input) {
-        if ((input instanceof Bucket) == false) {
-            throw new QlIllegalArgumentException("Expected an agg bucket but received {}", input);
-        }
-        return extractor.extract((Bucket) input);
-    }
-
-    @Override
-    public int hashCode() {
-        return Objects.hash(extractor);
-    }
-
-    @Override
-    public boolean equals(Object obj) {
-        if (this == obj) {
-            return true;
-        }
-
-        if (obj == null || getClass() != obj.getClass()) {
-            return false;
-        }
-
-        BucketExtractorProcessor other = (BucketExtractorProcessor) obj;
-        return Objects.equals(extractor, other.extractor);
-    }
-
-    @Override
-    public String toString() {
-        return extractor.toString();
-    }
-}

+ 0 - 77
x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/gen/processor/HitExtractorProcessor.java

@@ -1,77 +0,0 @@
-/*
- * 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.core.expression.gen.processor;
-
-import org.elasticsearch.common.io.stream.StreamInput;
-import org.elasticsearch.common.io.stream.StreamOutput;
-import org.elasticsearch.search.SearchHit;
-import org.elasticsearch.xpack.esql.core.QlIllegalArgumentException;
-import org.elasticsearch.xpack.esql.core.execution.search.extractor.HitExtractor;
-
-import java.io.IOException;
-import java.util.Objects;
-
-/**
- * Processor wrapping a {@link HitExtractor}, essentially being a source/leaf of a
- * Processor tree.
- */
-public class HitExtractorProcessor implements Processor {
-
-    public static final String NAME = "h";
-
-    private final HitExtractor extractor;
-
-    public HitExtractorProcessor(HitExtractor extractor) {
-        this.extractor = extractor;
-    }
-
-    public HitExtractorProcessor(StreamInput in) throws IOException {
-        extractor = in.readNamedWriteable(HitExtractor.class);
-    }
-
-    @Override
-    public void writeTo(StreamOutput out) throws IOException {
-        out.writeNamedWriteable(extractor);
-    }
-
-    @Override
-    public String getWriteableName() {
-        return NAME;
-    }
-
-    @Override
-    public Object process(Object input) {
-        if ((input instanceof SearchHit) == false) {
-            throw new QlIllegalArgumentException("Expected a SearchHit but received {}", input);
-        }
-        return extractor.extract((SearchHit) input);
-    }
-
-    @Override
-    public int hashCode() {
-        return Objects.hash(extractor);
-    }
-
-    @Override
-    public boolean equals(Object obj) {
-        if (this == obj) {
-            return true;
-        }
-
-        if (obj == null || getClass() != obj.getClass()) {
-            return false;
-        }
-
-        HitExtractorProcessor other = (HitExtractorProcessor) obj;
-        return Objects.equals(extractor, other.extractor);
-    }
-
-    @Override
-    public String toString() {
-        return extractor.toString();
-    }
-}

+ 0 - 4
x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/processor/Processors.java

@@ -8,10 +8,8 @@ package org.elasticsearch.xpack.esql.core.expression.processor;
 
 import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
 import org.elasticsearch.common.io.stream.NamedWriteableRegistry.Entry;
-import org.elasticsearch.xpack.esql.core.expression.gen.processor.BucketExtractorProcessor;
 import org.elasticsearch.xpack.esql.core.expression.gen.processor.ChainingProcessor;
 import org.elasticsearch.xpack.esql.core.expression.gen.processor.ConstantProcessor;
-import org.elasticsearch.xpack.esql.core.expression.gen.processor.HitExtractorProcessor;
 import org.elasticsearch.xpack.esql.core.expression.gen.processor.Processor;
 import org.elasticsearch.xpack.esql.core.expression.predicate.logical.BinaryLogicProcessor;
 import org.elasticsearch.xpack.esql.core.expression.predicate.logical.NotProcessor;
@@ -42,8 +40,6 @@ public final class Processors {
         entries.add(new Entry(Converter.class, DefaultConverter.NAME, DefaultConverter::read));
 
         entries.add(new Entry(Processor.class, ConstantProcessor.NAME, ConstantProcessor::new));
-        entries.add(new Entry(Processor.class, HitExtractorProcessor.NAME, HitExtractorProcessor::new));
-        entries.add(new Entry(Processor.class, BucketExtractorProcessor.NAME, BucketExtractorProcessor::new));
         entries.add(new Entry(Processor.class, ChainingProcessor.NAME, ChainingProcessor::new));
 
         // logical

+ 0 - 129
x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/type/Schema.java

@@ -1,129 +0,0 @@
-/*
- * 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.core.type;
-
-import org.elasticsearch.xpack.esql.core.util.Check;
-
-import java.util.Iterator;
-import java.util.List;
-import java.util.NoSuchElementException;
-import java.util.Spliterator;
-import java.util.Spliterators;
-import java.util.stream.Stream;
-import java.util.stream.StreamSupport;
-
-import static java.util.Collections.emptyList;
-
-public class Schema implements Iterable<Schema.Entry> {
-
-    public interface Entry {
-        String name();
-
-        DataType type();
-    }
-
-    static class DefaultEntry implements Entry {
-        private final String name;
-        private final DataType type;
-
-        DefaultEntry(String name, DataType type) {
-            this.name = name;
-            this.type = type;
-        }
-
-        @Override
-        public String name() {
-            return name;
-        }
-
-        @Override
-        public DataType type() {
-            return type;
-        }
-    }
-
-    public static final Schema EMPTY = new Schema(emptyList(), emptyList());
-
-    private final List<String> names;
-    private final List<DataType> types;
-
-    public Schema(List<String> names, List<DataType> types) {
-        Check.isTrue(names.size() == types.size(), "Different # of names {} vs types {}", names, types);
-        this.types = types;
-        this.names = names;
-    }
-
-    public List<String> names() {
-        return names;
-    }
-
-    public List<DataType> types() {
-        return types;
-    }
-
-    public int size() {
-        return names.size();
-    }
-
-    public Entry get(int i) {
-        return new DefaultEntry(names.get(i), types.get(i));
-    }
-
-    public DataType type(String name) {
-        int indexOf = names.indexOf(name);
-        if (indexOf < 0) {
-            return null;
-        }
-        return types.get(indexOf);
-    }
-
-    @Override
-    public Iterator<Entry> iterator() {
-        return new Iterator<>() {
-            private final int size = size();
-            private int pos = -1;
-
-            @Override
-            public boolean hasNext() {
-                return pos < size - 1;
-            }
-
-            @Override
-            public Entry next() {
-                if (pos++ >= size) {
-                    throw new NoSuchElementException();
-                }
-                return get(pos);
-            }
-        };
-    }
-
-    public Stream<Entry> stream() {
-        return StreamSupport.stream(spliterator(), false);
-    }
-
-    @Override
-    public Spliterator<Entry> spliterator() {
-        return Spliterators.spliterator(iterator(), size(), 0);
-    }
-
-    @Override
-    public String toString() {
-        StringBuilder sb = new StringBuilder();
-        sb.append("[");
-        for (int i = 0; i < names.size(); i++) {
-            if (i > 0) {
-                sb.append(",");
-            }
-            sb.append(names.get(i));
-            sb.append(":");
-            sb.append(types.get(i).typeName());
-        }
-        sb.append("]");
-        return sb.toString();
-    }
-}

+ 0 - 53
x-pack/plugin/esql-core/src/test/java/org/elasticsearch/xpack/esql/core/execution/search/extractor/ConstantExtractorTests.java

@@ -1,53 +0,0 @@
-/*
- * 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.core.execution.search.extractor;
-
-import org.elasticsearch.common.io.stream.Writeable.Reader;
-import org.elasticsearch.search.SearchHit;
-import org.elasticsearch.test.AbstractWireSerializingTestCase;
-
-import java.util.function.Supplier;
-
-public class ConstantExtractorTests extends AbstractWireSerializingTestCase<ConstantExtractor> {
-    public static ConstantExtractor randomConstantExtractor() {
-        return new ConstantExtractor(randomValidConstant());
-    }
-
-    private static Object randomValidConstant() {
-        @SuppressWarnings("unchecked")
-        Supplier<Object> valueSupplier = randomFrom(() -> randomInt(), () -> randomDouble(), () -> randomAlphaOfLengthBetween(1, 140));
-        return valueSupplier.get();
-    }
-
-    @Override
-    protected ConstantExtractor createTestInstance() {
-        return randomConstantExtractor();
-    }
-
-    @Override
-    protected Reader<ConstantExtractor> instanceReader() {
-        return ConstantExtractor::new;
-    }
-
-    @Override
-    protected ConstantExtractor mutateInstance(ConstantExtractor instance) {
-        return new ConstantExtractor(instance.extract((SearchHit) null) + "mutated");
-    }
-
-    public void testGet() {
-        Object expected = randomValidConstant();
-        int times = between(1, 1000);
-        for (int i = 0; i < times; i++) {
-            assertSame(expected, new ConstantExtractor(expected).extract((SearchHit) null));
-        }
-    }
-
-    public void testToString() {
-        assertEquals("^foo", new ConstantExtractor("foo").toString());
-        assertEquals("^42", new ConstantExtractor("42").toString());
-    }
-}

+ 0 - 36
x-pack/plugin/esql-core/src/test/java/org/elasticsearch/xpack/esql/core/expression/function/FunctionRegistryTests.java

@@ -10,9 +10,7 @@ import org.elasticsearch.test.ESTestCase;
 import org.elasticsearch.xpack.esql.core.ParsingException;
 import org.elasticsearch.xpack.esql.core.QlIllegalArgumentException;
 import org.elasticsearch.xpack.esql.core.expression.Expression;
-import org.elasticsearch.xpack.esql.core.expression.function.scalar.ConfigurationFunction;
 import org.elasticsearch.xpack.esql.core.expression.function.scalar.ScalarFunction;
-import org.elasticsearch.xpack.esql.core.session.Configuration;
 import org.elasticsearch.xpack.esql.core.tree.NodeInfo;
 import org.elasticsearch.xpack.esql.core.tree.Source;
 import org.elasticsearch.xpack.esql.core.tree.SourceTests;
@@ -166,18 +164,6 @@ public class FunctionRegistryTests extends ESTestCase {
         assertThat(e.getMessage(), is("Cannot find function dummyfunction; this should have been caught during analysis"));
     }
 
-    public void testConfigurationOptionalFunction() {
-        UnresolvedFunction ur = uf(DEFAULT, mock(Expression.class));
-        FunctionRegistry r = new FunctionRegistry(
-            def(DummyConfigurationOptionalArgumentFunction.class, (Source l, Expression e, Configuration c) -> {
-                assertSame(e, ur.children().get(0));
-                return new DummyConfigurationOptionalArgumentFunction(l, List.of(ur), c);
-            }, "dummy")
-        );
-        FunctionDefinition def = r.resolveFunction(r.resolveAlias("DUMMY"));
-        assertEquals(ur.source(), ur.buildResolved(randomConfiguration(), def).source());
-    }
-
     public static UnresolvedFunction uf(FunctionResolutionStrategy resolutionStrategy, Expression... children) {
         return new UnresolvedFunction(SourceTests.randomSource(), "dummy_function", resolutionStrategy, Arrays.asList(children));
     }
@@ -208,26 +194,4 @@ public class FunctionRegistryTests extends ESTestCase {
             super(source);
         }
     }
-
-    public static class DummyConfigurationOptionalArgumentFunction extends ConfigurationFunction implements OptionalArgument {
-
-        public DummyConfigurationOptionalArgumentFunction(Source source, List<Expression> fields, Configuration configuration) {
-            super(source, fields, configuration);
-        }
-
-        @Override
-        public DataType dataType() {
-            return null;
-        }
-
-        @Override
-        public Expression replaceChildren(List<Expression> newChildren) {
-            return new DummyConfigurationOptionalArgumentFunction(source(), newChildren, configuration());
-        }
-
-        @Override
-        protected NodeInfo<? extends Expression> info() {
-            return NodeInfo.create(this, DummyConfigurationOptionalArgumentFunction::new, children(), configuration());
-        }
-    }
 }