From c3a167830fd7c3b60a6abf8513ba261d161c6854 Mon Sep 17 00:00:00 2001 From: Andrei Stefan Date: Fri, 28 Feb 2020 14:04:10 +0200 Subject: [PATCH] SQL: refactor In predicate moving it to QL project (#52870) (#52938) * Move In, InPipe and InProcessor out of SQL to the common QL project. * Move tests classes to the QL project. * Create SQL dedicated In class to handle SQL specific data types. * Update SQL classes to use the InPipe and InProcessor QL classes. * Extract common Foldables methods in QL project. * Be more explicit when folding and converting a foldable value, by removing most of the code inside Foldables class. (cherry picked from commit 7425042f86f66df8c207c5e96f9b9848bda2b4c3) --- .../xpack/ql/expression/Foldables.java | 18 ++ .../predicate/operator/comparison/In.java | 172 ++++++++++++++++++ .../predicate/operator/comparison/InPipe.java | 2 +- .../operator/comparison/InProcessor.java | 3 +- .../operator/comparison/InProcessorTests.java | 6 +- .../operator/comparison/InTests.java | 4 +- .../xpack/sql/analysis/analyzer/Analyzer.java | 2 +- .../xpack/sql/expression/Foldables.java | 63 ------- .../function/aggregate/Percentile.java | 6 +- .../function/aggregate/PercentileRank.java | 6 +- .../function/scalar/Processors.java | 2 +- .../whitelist/InternalSqlScriptUtils.java | 2 +- .../literal/interval/Intervals.java | 2 +- .../predicate/conditional/Greatest.java | 10 +- .../predicate/conditional/Least.java | 10 +- .../predicate/operator/comparison/In.java | 136 ++------------ .../xpack/sql/planner/QueryFolder.java | 20 +- .../xpack/sql/planner/QueryTranslator.java | 17 +- .../xpack/sql/util/DateUtils.java | 6 +- .../xpack/sql/optimizer/OptimizerTests.java | 3 +- .../xpack/sql/tree/SqlNodeSubclassTests.java | 2 +- 21 files changed, 270 insertions(+), 222 deletions(-) create mode 100644 x-pack/plugin/ql/src/main/java/org/elasticsearch/xpack/ql/expression/Foldables.java create mode 100644 x-pack/plugin/ql/src/main/java/org/elasticsearch/xpack/ql/expression/predicate/operator/comparison/In.java rename x-pack/plugin/{sql/src/main/java/org/elasticsearch/xpack/sql => ql/src/main/java/org/elasticsearch/xpack/ql}/expression/predicate/operator/comparison/InPipe.java (95%) rename x-pack/plugin/{sql/src/main/java/org/elasticsearch/xpack/sql => ql/src/main/java/org/elasticsearch/xpack/ql}/expression/predicate/operator/comparison/InProcessor.java (93%) rename x-pack/plugin/{sql/src/test/java/org/elasticsearch/xpack/sql => ql/src/test/java/org/elasticsearch/xpack/ql}/expression/predicate/operator/comparison/InProcessorTests.java (91%) rename x-pack/plugin/{sql/src/test/java/org/elasticsearch/xpack/sql => ql/src/test/java/org/elasticsearch/xpack/ql}/expression/predicate/operator/comparison/InTests.java (91%) delete mode 100644 x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/expression/Foldables.java diff --git a/x-pack/plugin/ql/src/main/java/org/elasticsearch/xpack/ql/expression/Foldables.java b/x-pack/plugin/ql/src/main/java/org/elasticsearch/xpack/ql/expression/Foldables.java new file mode 100644 index 00000000000..53cb62acae3 --- /dev/null +++ b/x-pack/plugin/ql/src/main/java/org/elasticsearch/xpack/ql/expression/Foldables.java @@ -0,0 +1,18 @@ +/* + * 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.ql.expression; + +import org.elasticsearch.xpack.ql.QlIllegalArgumentException; + +public abstract class Foldables { + + public static Object valueOf(Expression e) { + if (e.foldable()) { + return e.fold(); + } + throw new QlIllegalArgumentException("Cannot determine value for {}", e); + } +} diff --git a/x-pack/plugin/ql/src/main/java/org/elasticsearch/xpack/ql/expression/predicate/operator/comparison/In.java b/x-pack/plugin/ql/src/main/java/org/elasticsearch/xpack/ql/expression/predicate/operator/comparison/In.java new file mode 100644 index 00000000000..8f084167f15 --- /dev/null +++ b/x-pack/plugin/ql/src/main/java/org/elasticsearch/xpack/ql/expression/predicate/operator/comparison/In.java @@ -0,0 +1,172 @@ +/* + * 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.ql.expression.predicate.operator.comparison; + +import org.elasticsearch.xpack.ql.expression.Expression; +import org.elasticsearch.xpack.ql.expression.Expressions; +import org.elasticsearch.xpack.ql.expression.Foldables; +import org.elasticsearch.xpack.ql.expression.Nullability; +import org.elasticsearch.xpack.ql.expression.TypeResolutions; +import org.elasticsearch.xpack.ql.expression.function.scalar.ScalarFunction; +import org.elasticsearch.xpack.ql.expression.gen.pipeline.Pipe; +import org.elasticsearch.xpack.ql.expression.gen.script.ScriptTemplate; +import org.elasticsearch.xpack.ql.tree.NodeInfo; +import org.elasticsearch.xpack.ql.tree.Source; +import org.elasticsearch.xpack.ql.type.DataType; +import org.elasticsearch.xpack.ql.type.DataTypeConverter; +import org.elasticsearch.xpack.ql.type.DataTypes; +import org.elasticsearch.xpack.ql.util.CollectionUtils; + +import java.util.ArrayList; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Objects; +import java.util.stream.Collectors; + +import static org.elasticsearch.common.logging.LoggerMessageFormat.format; +import static org.elasticsearch.xpack.ql.expression.gen.script.ParamsBuilder.paramsBuilder; +import static org.elasticsearch.xpack.ql.util.StringUtils.ordinal; + +public class In extends ScalarFunction { + + private final Expression value; + private final List list; + + public In(Source source, Expression value, List list) { + super(source, CollectionUtils.combine(list, value)); + this.value = value; + this.list = new ArrayList<>(new LinkedHashSet<>(list)); + } + + @Override + protected NodeInfo info() { + return NodeInfo.create(this, In::new, value(), list()); + } + + @Override + public Expression replaceChildren(List newChildren) { + if (newChildren.size() < 2) { + throw new IllegalArgumentException("expected at least [2] children but received [" + newChildren.size() + "]"); + } + return new In(source(), newChildren.get(newChildren.size() - 1), newChildren.subList(0, newChildren.size() - 1)); + } + + public Expression value() { + return value; + } + + public List list() { + return list; + } + + @Override + public DataType dataType() { + return DataTypes.BOOLEAN; + } + + @Override + public Nullability nullable() { + return Nullability.UNKNOWN; + } + + @Override + public boolean foldable() { + return Expressions.foldable(children()) || + (Expressions.foldable(list) && list().stream().allMatch(Expressions::isNull)); + } + + @Override + public Boolean fold() { + // Optimization for early return and Query folding to LocalExec + if (Expressions.isNull(value) || list.size() == 1 && Expressions.isNull(list.get(0))) { + return null; + } + return InProcessor.apply(value.fold(), foldAndConvertListOfValues(list, value.dataType())); + } + + @Override + public ScriptTemplate asScript() { + ScriptTemplate leftScript = asScript(value); + + // fold & remove duplicates + List values = new ArrayList<>(new LinkedHashSet<>(foldAndConvertListOfValues(list, value.dataType()))); + + return new ScriptTemplate( + formatTemplate(format("{sql}.","in({}, {})", leftScript.template())), + paramsBuilder() + .script(leftScript.params()) + .variable(values) + .build(), + dataType()); + } + + protected List foldAndConvertListOfValues(List list, DataType dataType) { + List values = new ArrayList<>(list.size()); + for (Expression e : list) { + values.add(DataTypeConverter.convert(Foldables.valueOf(e), dataType)); + } + return values; + } + + protected boolean areCompatible(DataType left, DataType right) { + return DataTypes.areCompatible(left, right); + } + + @Override + protected Pipe makePipe() { + return new InPipe(source(), this, children().stream().map(Expressions::pipe).collect(Collectors.toList())); + } + + @Override + protected TypeResolution resolveType() { + TypeResolution resolution = TypeResolutions.isExact(value, functionName(), Expressions.ParamOrdinal.DEFAULT); + if (resolution.unresolved()) { + return resolution; + } + + for (Expression ex : list) { + if (ex.foldable() == false) { + return new TypeResolution(format(null, "Comparisons against variables are not (currently) supported; offender [{}] in [{}]", + Expressions.name(ex), + sourceText())); + } + } + + DataType dt = value.dataType(); + for (int i = 0; i < list.size(); i++) { + Expression listValue = list.get(i); + if (areCompatible(dt, listValue.dataType()) == false) { + return new TypeResolution(format(null, "{} argument of [{}] must be [{}], found value [{}] type [{}]", + ordinal(i + 1), + sourceText(), + dt.typeName(), + Expressions.name(listValue), + listValue.dataType().typeName())); + } + } + + return super.resolveType(); + } + + @Override + public int hashCode() { + return Objects.hash(value, list); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null || getClass() != obj.getClass()) { + return false; + } + + In other = (In) obj; + return Objects.equals(value, other.value) + && Objects.equals(list, other.list); + } +} diff --git a/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/expression/predicate/operator/comparison/InPipe.java b/x-pack/plugin/ql/src/main/java/org/elasticsearch/xpack/ql/expression/predicate/operator/comparison/InPipe.java similarity index 95% rename from x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/expression/predicate/operator/comparison/InPipe.java rename to x-pack/plugin/ql/src/main/java/org/elasticsearch/xpack/ql/expression/predicate/operator/comparison/InPipe.java index a586e5801cf..993bd1d8001 100644 --- a/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/expression/predicate/operator/comparison/InPipe.java +++ b/x-pack/plugin/ql/src/main/java/org/elasticsearch/xpack/ql/expression/predicate/operator/comparison/InPipe.java @@ -3,7 +3,7 @@ * 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.predicate.operator.comparison; +package org.elasticsearch.xpack.ql.expression.predicate.operator.comparison; import org.elasticsearch.xpack.ql.expression.Expression; import org.elasticsearch.xpack.ql.expression.gen.pipeline.MultiPipe; diff --git a/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/expression/predicate/operator/comparison/InProcessor.java b/x-pack/plugin/ql/src/main/java/org/elasticsearch/xpack/ql/expression/predicate/operator/comparison/InProcessor.java similarity index 93% rename from x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/expression/predicate/operator/comparison/InProcessor.java rename to x-pack/plugin/ql/src/main/java/org/elasticsearch/xpack/ql/expression/predicate/operator/comparison/InProcessor.java index a81634cddb9..2ceb90a39de 100644 --- a/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/expression/predicate/operator/comparison/InProcessor.java +++ b/x-pack/plugin/ql/src/main/java/org/elasticsearch/xpack/ql/expression/predicate/operator/comparison/InProcessor.java @@ -3,12 +3,11 @@ * 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.predicate.operator.comparison; +package org.elasticsearch.xpack.ql.expression.predicate.operator.comparison; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.xpack.ql.expression.gen.processor.Processor; -import org.elasticsearch.xpack.ql.expression.predicate.operator.comparison.Comparisons; import java.io.IOException; import java.util.ArrayList; diff --git a/x-pack/plugin/sql/src/test/java/org/elasticsearch/xpack/sql/expression/predicate/operator/comparison/InProcessorTests.java b/x-pack/plugin/ql/src/test/java/org/elasticsearch/xpack/ql/expression/predicate/operator/comparison/InProcessorTests.java similarity index 91% rename from x-pack/plugin/sql/src/test/java/org/elasticsearch/xpack/sql/expression/predicate/operator/comparison/InProcessorTests.java rename to x-pack/plugin/ql/src/test/java/org/elasticsearch/xpack/ql/expression/predicate/operator/comparison/InProcessorTests.java index 02233cc1f4c..38f18feefb7 100644 --- a/x-pack/plugin/sql/src/test/java/org/elasticsearch/xpack/sql/expression/predicate/operator/comparison/InProcessorTests.java +++ b/x-pack/plugin/ql/src/test/java/org/elasticsearch/xpack/ql/expression/predicate/operator/comparison/InProcessorTests.java @@ -3,7 +3,7 @@ * 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.predicate.operator.comparison; +package org.elasticsearch.xpack.ql.expression.predicate.operator.comparison; import org.elasticsearch.common.io.stream.NamedWriteableRegistry; import org.elasticsearch.common.io.stream.Writeable.Reader; @@ -11,9 +11,9 @@ import org.elasticsearch.test.AbstractWireSerializingTestCase; import org.elasticsearch.xpack.ql.TestUtils; import org.elasticsearch.xpack.ql.expression.Literal; import org.elasticsearch.xpack.ql.expression.gen.processor.ConstantProcessor; +import org.elasticsearch.xpack.ql.expression.predicate.operator.comparison.In; +import org.elasticsearch.xpack.ql.expression.predicate.operator.comparison.InProcessor; import org.elasticsearch.xpack.ql.expression.processor.Processors; -import org.elasticsearch.xpack.sql.expression.predicate.operator.comparison.In; -import org.elasticsearch.xpack.sql.expression.predicate.operator.comparison.InProcessor; import java.util.Arrays; diff --git a/x-pack/plugin/sql/src/test/java/org/elasticsearch/xpack/sql/expression/predicate/operator/comparison/InTests.java b/x-pack/plugin/ql/src/test/java/org/elasticsearch/xpack/ql/expression/predicate/operator/comparison/InTests.java similarity index 91% rename from x-pack/plugin/sql/src/test/java/org/elasticsearch/xpack/sql/expression/predicate/operator/comparison/InTests.java rename to x-pack/plugin/ql/src/test/java/org/elasticsearch/xpack/ql/expression/predicate/operator/comparison/InTests.java index 4d437edd00b..6672e516363 100644 --- a/x-pack/plugin/sql/src/test/java/org/elasticsearch/xpack/sql/expression/predicate/operator/comparison/InTests.java +++ b/x-pack/plugin/ql/src/test/java/org/elasticsearch/xpack/ql/expression/predicate/operator/comparison/InTests.java @@ -3,12 +3,12 @@ * 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.predicate.operator.comparison; +package org.elasticsearch.xpack.ql.expression.predicate.operator.comparison; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.xpack.ql.TestUtils; import org.elasticsearch.xpack.ql.expression.Literal; -import org.elasticsearch.xpack.sql.expression.predicate.operator.comparison.In; +import org.elasticsearch.xpack.ql.expression.predicate.operator.comparison.In; import java.util.Arrays; diff --git a/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/analysis/analyzer/Analyzer.java b/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/analysis/analyzer/Analyzer.java index c838327f00e..2e719dd0fbc 100644 --- a/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/analysis/analyzer/Analyzer.java +++ b/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/analysis/analyzer/Analyzer.java @@ -15,6 +15,7 @@ import org.elasticsearch.xpack.ql.expression.AttributeSet; import org.elasticsearch.xpack.ql.expression.Expression; import org.elasticsearch.xpack.ql.expression.Expressions; import org.elasticsearch.xpack.ql.expression.FieldAttribute; +import org.elasticsearch.xpack.ql.expression.Foldables; import org.elasticsearch.xpack.ql.expression.NamedExpression; import org.elasticsearch.xpack.ql.expression.Order; import org.elasticsearch.xpack.ql.expression.ReferenceAttribute; @@ -46,7 +47,6 @@ import org.elasticsearch.xpack.ql.type.InvalidMappedField; import org.elasticsearch.xpack.ql.type.UnsupportedEsField; import org.elasticsearch.xpack.ql.util.CollectionUtils; import org.elasticsearch.xpack.ql.util.Holder; -import org.elasticsearch.xpack.sql.expression.Foldables; import org.elasticsearch.xpack.sql.expression.SubQueryExpression; import org.elasticsearch.xpack.sql.expression.function.scalar.Cast; import org.elasticsearch.xpack.sql.plan.logical.Join; diff --git a/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/expression/Foldables.java b/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/expression/Foldables.java deleted file mode 100644 index 067b85ae30d..00000000000 --- a/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/expression/Foldables.java +++ /dev/null @@ -1,63 +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; - * you may not use this file except in compliance with the Elastic License. - */ -package org.elasticsearch.xpack.sql.expression; - -import org.elasticsearch.xpack.ql.QlIllegalArgumentException; -import org.elasticsearch.xpack.ql.expression.Expression; -import org.elasticsearch.xpack.ql.type.DataType; -import org.elasticsearch.xpack.ql.type.DataTypes; -import org.elasticsearch.xpack.sql.type.SqlDataTypeConverter; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Set; - -public abstract class Foldables { - - @SuppressWarnings("unchecked") - private static T valueOf(Expression e, DataType to) { - if (e.foldable()) { - return (T) SqlDataTypeConverter.convert(e.fold(), to); - } - throw new QlIllegalArgumentException("Cannot determine value for {}", e); - } - - public static Object valueOf(Expression e) { - if (e.foldable()) { - return e.fold(); - } - throw new QlIllegalArgumentException("Cannot determine value for {}", e); - } - - public static Integer intValueOf(Expression e) { - return valueOf(e, DataTypes.INTEGER); - } - - public static double doubleValueOf(Expression e) { - return valueOf(e, DataTypes.DOUBLE); - } - - public static List valuesOf(List list, DataType to) { - return foldTo(list, to, new ArrayList<>(list.size())); - } - - public static Set valuesUnique(List list, DataType to) { - return foldTo(list, to, new LinkedHashSet<>(list.size())); - } - - private static > C foldTo(Collection expressions, DataType to, C values) { - for (Expression e : expressions) { - values.add(valueOf(e, to)); - } - return values; - } - - public static List doubleValuesOf(List list) { - return valuesOf(list, DataTypes.DOUBLE); - } -} diff --git a/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/expression/function/aggregate/Percentile.java b/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/expression/function/aggregate/Percentile.java index 785cbb1a7a6..4b54d9c8cb1 100644 --- a/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/expression/function/aggregate/Percentile.java +++ b/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/expression/function/aggregate/Percentile.java @@ -7,12 +7,13 @@ package org.elasticsearch.xpack.sql.expression.function.aggregate; import org.elasticsearch.xpack.ql.expression.Expression; import org.elasticsearch.xpack.ql.expression.Expressions.ParamOrdinal; +import org.elasticsearch.xpack.ql.expression.Foldables; import org.elasticsearch.xpack.ql.expression.function.aggregate.EnclosedAgg; import org.elasticsearch.xpack.ql.tree.NodeInfo; import org.elasticsearch.xpack.ql.tree.Source; import org.elasticsearch.xpack.ql.type.DataType; import org.elasticsearch.xpack.ql.type.DataTypes; -import org.elasticsearch.xpack.sql.expression.Foldables; +import org.elasticsearch.xpack.sql.type.SqlDataTypeConverter; import java.util.List; @@ -68,6 +69,7 @@ public class Percentile extends NumericAggregate implements EnclosedAgg { @Override public String innerName() { - return Double.toString(Foldables.doubleValueOf(percent)); + Double value = (Double) SqlDataTypeConverter.convert(Foldables.valueOf(percent), DataTypes.DOUBLE); + return Double.toString(value); } } diff --git a/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/expression/function/aggregate/PercentileRank.java b/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/expression/function/aggregate/PercentileRank.java index be253aa4619..6f1f4e688cb 100644 --- a/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/expression/function/aggregate/PercentileRank.java +++ b/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/expression/function/aggregate/PercentileRank.java @@ -7,13 +7,14 @@ package org.elasticsearch.xpack.sql.expression.function.aggregate; import org.elasticsearch.xpack.ql.expression.Expression; import org.elasticsearch.xpack.ql.expression.Expressions.ParamOrdinal; +import org.elasticsearch.xpack.ql.expression.Foldables; import org.elasticsearch.xpack.ql.expression.function.aggregate.AggregateFunction; import org.elasticsearch.xpack.ql.expression.function.aggregate.EnclosedAgg; import org.elasticsearch.xpack.ql.tree.NodeInfo; import org.elasticsearch.xpack.ql.tree.Source; import org.elasticsearch.xpack.ql.type.DataType; import org.elasticsearch.xpack.ql.type.DataTypes; -import org.elasticsearch.xpack.sql.expression.Foldables; +import org.elasticsearch.xpack.sql.type.SqlDataTypeConverter; import java.util.List; @@ -69,6 +70,7 @@ public class PercentileRank extends AggregateFunction implements EnclosedAgg { @Override public String innerName() { - return Double.toString(Foldables.doubleValueOf(value)); + Double doubleValue = (Double) SqlDataTypeConverter.convert(Foldables.valueOf(value), DataTypes.DOUBLE); + return Double.toString(doubleValue); } } diff --git a/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/expression/function/scalar/Processors.java b/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/expression/function/scalar/Processors.java index 10b7012791c..647a668d40c 100644 --- a/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/expression/function/scalar/Processors.java +++ b/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/expression/function/scalar/Processors.java @@ -10,6 +10,7 @@ import org.elasticsearch.common.io.stream.NamedWriteableRegistry.Entry; import org.elasticsearch.xpack.ql.expression.gen.processor.Processor; import org.elasticsearch.xpack.ql.expression.predicate.nulls.CheckNullProcessor; import org.elasticsearch.xpack.ql.expression.predicate.operator.arithmetic.BinaryArithmeticOperation; +import org.elasticsearch.xpack.ql.expression.predicate.operator.comparison.InProcessor; import org.elasticsearch.xpack.ql.type.Converter; import org.elasticsearch.xpack.sql.expression.function.scalar.datetime.DateAddProcessor; import org.elasticsearch.xpack.sql.expression.function.scalar.datetime.DateDiffProcessor; @@ -38,7 +39,6 @@ import org.elasticsearch.xpack.sql.expression.predicate.conditional.CaseProcesso import org.elasticsearch.xpack.sql.expression.predicate.conditional.ConditionalProcessor; import org.elasticsearch.xpack.sql.expression.predicate.conditional.NullIfProcessor; import org.elasticsearch.xpack.sql.expression.predicate.operator.arithmetic.SqlBinaryArithmeticOperation; -import org.elasticsearch.xpack.sql.expression.predicate.operator.comparison.InProcessor; import org.elasticsearch.xpack.sql.type.SqlDataTypeConverter.SqlConverter; import java.util.ArrayList; diff --git a/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/expression/function/scalar/whitelist/InternalSqlScriptUtils.java b/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/expression/function/scalar/whitelist/InternalSqlScriptUtils.java index 2089e779c0c..82a41fb2024 100644 --- a/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/expression/function/scalar/whitelist/InternalSqlScriptUtils.java +++ b/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/expression/function/scalar/whitelist/InternalSqlScriptUtils.java @@ -11,6 +11,7 @@ import org.elasticsearch.script.JodaCompatibleZonedDateTime; import org.elasticsearch.xpack.ql.expression.function.scalar.whitelist.InternalQlScriptUtils; import org.elasticsearch.xpack.ql.expression.predicate.nulls.CheckNullProcessor.CheckNullOperation; import org.elasticsearch.xpack.ql.expression.predicate.operator.arithmetic.UnaryArithmeticProcessor.UnaryArithmeticOperation; +import org.elasticsearch.xpack.ql.expression.predicate.operator.comparison.InProcessor; import org.elasticsearch.xpack.ql.expression.predicate.regex.RegexProcessor.RegexOperation; import org.elasticsearch.xpack.sql.SqlIllegalArgumentException; import org.elasticsearch.xpack.sql.expression.function.scalar.datetime.DateAddProcessor; @@ -43,7 +44,6 @@ import org.elasticsearch.xpack.sql.expression.predicate.conditional.CaseProcesso import org.elasticsearch.xpack.sql.expression.predicate.conditional.ConditionalProcessor.ConditionalOperation; import org.elasticsearch.xpack.sql.expression.predicate.conditional.NullIfProcessor; import org.elasticsearch.xpack.sql.expression.predicate.operator.arithmetic.SqlBinaryArithmeticOperation; -import org.elasticsearch.xpack.sql.expression.predicate.operator.comparison.InProcessor; import org.elasticsearch.xpack.sql.type.SqlDataTypeConverter; import org.elasticsearch.xpack.sql.type.SqlDataTypes; import org.elasticsearch.xpack.sql.util.DateUtils; diff --git a/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/expression/literal/interval/Intervals.java b/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/expression/literal/interval/Intervals.java index 9d96fb9606a..c3489f03ef5 100644 --- a/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/expression/literal/interval/Intervals.java +++ b/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/expression/literal/interval/Intervals.java @@ -9,12 +9,12 @@ package org.elasticsearch.xpack.sql.expression.literal.interval; import org.elasticsearch.common.Strings; import org.elasticsearch.xpack.ql.ParsingException; import org.elasticsearch.xpack.ql.QlIllegalArgumentException; +import org.elasticsearch.xpack.ql.expression.Foldables; import org.elasticsearch.xpack.ql.expression.Literal; import org.elasticsearch.xpack.ql.tree.Source; import org.elasticsearch.xpack.ql.type.DataType; import org.elasticsearch.xpack.ql.util.Check; import org.elasticsearch.xpack.ql.util.StringUtils; -import org.elasticsearch.xpack.sql.expression.Foldables; import java.time.Duration; import java.time.Period; diff --git a/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/expression/predicate/conditional/Greatest.java b/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/expression/predicate/conditional/Greatest.java index 13b740261ca..dc0b8d8e385 100644 --- a/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/expression/predicate/conditional/Greatest.java +++ b/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/expression/predicate/conditional/Greatest.java @@ -7,13 +7,15 @@ package org.elasticsearch.xpack.sql.expression.predicate.conditional; import org.elasticsearch.xpack.ql.expression.Expression; +import org.elasticsearch.xpack.ql.expression.Foldables; import org.elasticsearch.xpack.ql.tree.NodeInfo; import org.elasticsearch.xpack.ql.tree.Source; -import org.elasticsearch.xpack.sql.expression.Foldables; +import org.elasticsearch.xpack.sql.type.SqlDataTypeConverter; import java.util.ArrayList; import java.util.LinkedHashSet; import java.util.List; +import java.util.Set; import static org.elasticsearch.xpack.sql.expression.predicate.conditional.ConditionalProcessor.ConditionalOperation.GREATEST; @@ -35,6 +37,10 @@ public class Greatest extends ArbitraryConditionalFunction { @Override public Object fold() { - return GREATEST.apply(Foldables.valuesUnique(children(), dataType)); + Set values = new LinkedHashSet<>(children().size()); + for (Expression e : children()) { + values.add(SqlDataTypeConverter.convert(Foldables.valueOf(e), dataType)); + } + return GREATEST.apply(values); } } diff --git a/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/expression/predicate/conditional/Least.java b/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/expression/predicate/conditional/Least.java index b9d2470d5a1..0d48a9e2415 100644 --- a/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/expression/predicate/conditional/Least.java +++ b/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/expression/predicate/conditional/Least.java @@ -7,13 +7,15 @@ package org.elasticsearch.xpack.sql.expression.predicate.conditional; import org.elasticsearch.xpack.ql.expression.Expression; +import org.elasticsearch.xpack.ql.expression.Foldables; import org.elasticsearch.xpack.ql.tree.NodeInfo; import org.elasticsearch.xpack.ql.tree.Source; -import org.elasticsearch.xpack.sql.expression.Foldables; +import org.elasticsearch.xpack.sql.type.SqlDataTypeConverter; import java.util.ArrayList; import java.util.LinkedHashSet; import java.util.List; +import java.util.Set; import static org.elasticsearch.xpack.sql.expression.predicate.conditional.ConditionalProcessor.ConditionalOperation.LEAST; @@ -35,6 +37,10 @@ public class Least extends ArbitraryConditionalFunction { @Override public Object fold() { - return LEAST.apply(Foldables.valuesUnique(children(), dataType)); + Set values = new LinkedHashSet<>(children().size()); + for (Expression e : children()) { + values.add(SqlDataTypeConverter.convert(Foldables.valueOf(e), dataType)); + } + return LEAST.apply(values); } } diff --git a/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/expression/predicate/operator/comparison/In.java b/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/expression/predicate/operator/comparison/In.java index 5f075a8064c..51466ab9f30 100644 --- a/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/expression/predicate/operator/comparison/In.java +++ b/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/expression/predicate/operator/comparison/In.java @@ -3,47 +3,29 @@ * 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.predicate.operator.comparison; import org.elasticsearch.xpack.ql.expression.Expression; -import org.elasticsearch.xpack.ql.expression.Expressions; -import org.elasticsearch.xpack.ql.expression.Nullability; -import org.elasticsearch.xpack.ql.expression.TypeResolutions; -import org.elasticsearch.xpack.ql.expression.function.scalar.ScalarFunction; -import org.elasticsearch.xpack.ql.expression.gen.pipeline.Pipe; -import org.elasticsearch.xpack.ql.expression.gen.script.ScriptTemplate; +import org.elasticsearch.xpack.ql.expression.Foldables; import org.elasticsearch.xpack.ql.tree.NodeInfo; import org.elasticsearch.xpack.ql.tree.Source; import org.elasticsearch.xpack.ql.type.DataType; -import org.elasticsearch.xpack.ql.type.DataTypes; -import org.elasticsearch.xpack.ql.util.CollectionUtils; -import org.elasticsearch.xpack.sql.expression.Foldables; +import org.elasticsearch.xpack.sql.type.SqlDataTypeConverter; import org.elasticsearch.xpack.sql.type.SqlDataTypes; import java.util.ArrayList; -import java.util.LinkedHashSet; import java.util.List; -import java.util.Objects; -import java.util.stream.Collectors; -import static org.elasticsearch.common.logging.LoggerMessageFormat.format; -import static org.elasticsearch.xpack.ql.expression.gen.script.ParamsBuilder.paramsBuilder; -import static org.elasticsearch.xpack.ql.util.StringUtils.ordinal; - -public class In extends ScalarFunction { - - private final Expression value; - private final List list; +public class In extends org.elasticsearch.xpack.ql.expression.predicate.operator.comparison.In { public In(Source source, Expression value, List list) { - super(source, CollectionUtils.combine(list, value)); - this.value = value; - this.list = new ArrayList<>(new LinkedHashSet<>(list)); + super(source, value, list); } @Override - protected NodeInfo info() { - return NodeInfo.create(this, In::new, value, list); + protected NodeInfo info() { + return NodeInfo.create(this, In::new, value(), list()); } @Override @@ -54,107 +36,17 @@ public class In extends ScalarFunction { return new In(source(), newChildren.get(newChildren.size() - 1), newChildren.subList(0, newChildren.size() - 1)); } - public Expression value() { - return value; - } - - public List list() { - return list; - } - @Override - public DataType dataType() { - return DataTypes.BOOLEAN; - } - - @Override - public Nullability nullable() { - return Nullability.UNKNOWN; - } - - @Override - public boolean foldable() { - return Expressions.foldable(children()) || - (Expressions.foldable(list) && list().stream().allMatch(Expressions::isNull)); - } - - @Override - public Boolean fold() { - // Optimization for early return and Query folding to LocalExec - if (Expressions.isNull(value) || list.size() == 1 && Expressions.isNull(list.get(0))) { - return null; + protected List foldAndConvertListOfValues(List list, DataType dataType) { + List values = new ArrayList<>(list.size()); + for (Expression e : list) { + values.add(SqlDataTypeConverter.convert(Foldables.valueOf(e), dataType)); } - return InProcessor.apply(value.fold(), Foldables.valuesOf(list, value.dataType())); + return values; } @Override - public ScriptTemplate asScript() { - ScriptTemplate leftScript = asScript(value); - - // fold & remove duplicates - List values = new ArrayList<>(new LinkedHashSet<>(Foldables.valuesOf(list, value.dataType()))); - - return new ScriptTemplate( - formatTemplate(format("{sql}.","in({}, {})", leftScript.template())), - paramsBuilder() - .script(leftScript.params()) - .variable(values) - .build(), - dataType()); - } - - @Override - protected Pipe makePipe() { - return new InPipe(source(), this, children().stream().map(Expressions::pipe).collect(Collectors.toList())); - } - - @Override - protected TypeResolution resolveType() { - TypeResolution resolution = TypeResolutions.isExact(value, functionName(), Expressions.ParamOrdinal.DEFAULT); - if (resolution.unresolved()) { - return resolution; - } - - for (Expression ex : list) { - if (ex.foldable() == false) { - return new TypeResolution(format(null, "Comparisons against variables are not (currently) supported; offender [{}] in [{}]", - Expressions.name(ex), - sourceText())); - } - } - - DataType dt = value.dataType(); - for (int i = 0; i < list.size(); i++) { - Expression listValue = list.get(i); - if (SqlDataTypes.areCompatible(dt, listValue.dataType()) == false) { - return new TypeResolution(format(null, "{} argument of [{}] must be [{}], found value [{}] type [{}]", - ordinal(i + 1), - sourceText(), - dt.typeName(), - Expressions.name(listValue), - listValue.dataType().typeName())); - } - } - - return super.resolveType(); - } - - @Override - public int hashCode() { - return Objects.hash(value, list); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null || getClass() != obj.getClass()) { - return false; - } - - In other = (In) obj; - return Objects.equals(value, other.value) - && Objects.equals(list, other.list); + protected boolean areCompatible(DataType left, DataType right) { + return SqlDataTypes.areCompatible(left, right); } } diff --git a/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/planner/QueryFolder.java b/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/planner/QueryFolder.java index 83b5ae9d626..e4edf467409 100644 --- a/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/planner/QueryFolder.java +++ b/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/planner/QueryFolder.java @@ -14,6 +14,7 @@ import org.elasticsearch.xpack.ql.expression.AttributeMap; import org.elasticsearch.xpack.ql.expression.Expression; import org.elasticsearch.xpack.ql.expression.Expressions; import org.elasticsearch.xpack.ql.expression.FieldAttribute; +import org.elasticsearch.xpack.ql.expression.Foldables; import org.elasticsearch.xpack.ql.expression.Literal; import org.elasticsearch.xpack.ql.expression.NamedExpression; import org.elasticsearch.xpack.ql.expression.Order; @@ -34,8 +35,8 @@ import org.elasticsearch.xpack.ql.planner.ExpressionTranslators; import org.elasticsearch.xpack.ql.querydsl.query.Query; import org.elasticsearch.xpack.ql.rule.Rule; import org.elasticsearch.xpack.ql.rule.RuleExecutor; +import org.elasticsearch.xpack.ql.type.DataTypes; import org.elasticsearch.xpack.sql.SqlIllegalArgumentException; -import org.elasticsearch.xpack.sql.expression.Foldables; import org.elasticsearch.xpack.sql.expression.function.Score; import org.elasticsearch.xpack.sql.expression.function.aggregate.CompoundNumericAggregate; import org.elasticsearch.xpack.sql.expression.function.aggregate.TopHits; @@ -78,6 +79,7 @@ import org.elasticsearch.xpack.sql.querydsl.container.Sort.Direction; import org.elasticsearch.xpack.sql.querydsl.container.Sort.Missing; import org.elasticsearch.xpack.sql.querydsl.container.TopHitsAggRef; import org.elasticsearch.xpack.sql.session.EmptyExecutable; +import org.elasticsearch.xpack.sql.type.SqlDataTypeConverter; import org.elasticsearch.xpack.sql.util.Check; import org.elasticsearch.xpack.sql.util.DateUtils; @@ -372,12 +374,14 @@ class QueryFolder extends RuleExecutor { } // numeric histogram else { - if (field instanceof FieldAttribute) { - key = new GroupByNumericHistogram(aggId, QueryTranslator.nameOf(field), - Foldables.doubleValueOf(h.interval())); - } else if (field instanceof Function) { - key = new GroupByNumericHistogram(aggId, ((Function) field).asScript(), - Foldables.doubleValueOf(h.interval())); + if (field instanceof FieldAttribute || field instanceof Function) { + Double interval = (Double) SqlDataTypeConverter.convert(Foldables.valueOf(h.interval()), + DataTypes.DOUBLE); + if (field instanceof FieldAttribute) { + key = new GroupByNumericHistogram(aggId, QueryTranslator.nameOf(field), interval); + } else { + key = new GroupByNumericHistogram(aggId, ((Function) field).asScript(), interval); + } } } if (key == null) { @@ -754,7 +758,7 @@ class QueryFolder extends RuleExecutor { protected PhysicalPlan rule(LimitExec plan) { if (plan.child() instanceof EsQueryExec) { EsQueryExec exec = (EsQueryExec) plan.child(); - int limit = Foldables.intValueOf(plan.limit()); + int limit = (Integer) SqlDataTypeConverter.convert(Foldables.valueOf(plan.limit()), DataTypes.INTEGER); int currentSize = exec.queryContainer().limit(); int newSize = currentSize < 0 ? limit : Math.min(currentSize, limit); return exec.with(exec.queryContainer().withLimit(newSize)); diff --git a/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/planner/QueryTranslator.java b/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/planner/QueryTranslator.java index b7c7712c6e1..3c8357262cf 100644 --- a/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/planner/QueryTranslator.java +++ b/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/planner/QueryTranslator.java @@ -10,6 +10,7 @@ import org.elasticsearch.geometry.Point; import org.elasticsearch.search.sort.SortOrder; import org.elasticsearch.xpack.ql.expression.Expression; import org.elasticsearch.xpack.ql.expression.FieldAttribute; +import org.elasticsearch.xpack.ql.expression.Foldables; import org.elasticsearch.xpack.ql.expression.Literal; import org.elasticsearch.xpack.ql.expression.NamedExpression; import org.elasticsearch.xpack.ql.expression.function.Function; @@ -81,6 +82,7 @@ import org.elasticsearch.xpack.sql.querydsl.agg.TopHitsAgg; import org.elasticsearch.xpack.sql.type.SqlDataTypeConverter; import org.elasticsearch.xpack.sql.util.Check; +import java.util.ArrayList; import java.util.Arrays; import java.util.LinkedHashSet; import java.util.List; @@ -88,8 +90,7 @@ import java.util.Set; import static java.util.Collections.singletonList; import static org.elasticsearch.xpack.ql.expression.Expressions.id; -import static org.elasticsearch.xpack.sql.expression.Foldables.doubleValuesOf; -import static org.elasticsearch.xpack.sql.expression.Foldables.valueOf; +import static org.elasticsearch.xpack.ql.expression.Foldables.valueOf; final class QueryTranslator { @@ -636,7 +637,7 @@ final class QueryTranslator { @Override protected LeafAgg toAgg(String id, Percentiles p) { - return new PercentilesAgg(id, field(p), doubleValuesOf(p.percents())); + return new PercentilesAgg(id, field(p), foldAndConvertToDoubles(p.percents())); } } @@ -644,7 +645,7 @@ final class QueryTranslator { @Override protected LeafAgg toAgg(String id, PercentileRanks p) { - return new PercentileRanksAgg(id, field(p), doubleValuesOf(p.values())); + return new PercentileRanksAgg(id, field(p), foldAndConvertToDoubles(p.values())); } } @@ -697,4 +698,12 @@ final class QueryTranslator { protected abstract LeafAgg toAgg(String id, C f); } + + private static List foldAndConvertToDoubles(List list) { + List values = new ArrayList<>(list.size()); + for (Expression e : list) { + values.add((Double) SqlDataTypeConverter.convert(Foldables.valueOf(e), DataTypes.DOUBLE)); + } + return values; + } } \ No newline at end of file diff --git a/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/util/DateUtils.java b/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/util/DateUtils.java index 7ea20224a86..84dbc7c43b7 100644 --- a/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/util/DateUtils.java +++ b/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/util/DateUtils.java @@ -9,9 +9,11 @@ package org.elasticsearch.xpack.sql.util; import org.elasticsearch.common.time.DateFormatter; import org.elasticsearch.common.time.DateFormatters; import org.elasticsearch.xpack.ql.expression.Expression; -import org.elasticsearch.xpack.sql.expression.Foldables; +import org.elasticsearch.xpack.ql.expression.Foldables; +import org.elasticsearch.xpack.ql.type.DataTypes; import org.elasticsearch.xpack.sql.parser.ParsingException; import org.elasticsearch.xpack.sql.proto.StringUtils; +import org.elasticsearch.xpack.sql.type.SqlDataTypeConverter; import java.time.Instant; import java.time.LocalDate; @@ -187,7 +189,7 @@ public final class DateUtils { if (precisionExpression != null) { try { - precision = Foldables.intValueOf(precisionExpression); + precision = (Integer) SqlDataTypeConverter.convert(Foldables.valueOf(precisionExpression), DataTypes.INTEGER); } catch (Exception e) { throw new ParsingException(precisionExpression.source(), "invalid precision; " + e.getMessage()); } diff --git a/x-pack/plugin/sql/src/test/java/org/elasticsearch/xpack/sql/optimizer/OptimizerTests.java b/x-pack/plugin/sql/src/test/java/org/elasticsearch/xpack/sql/optimizer/OptimizerTests.java index f924f87317e..d4ef29f667e 100644 --- a/x-pack/plugin/sql/src/test/java/org/elasticsearch/xpack/sql/optimizer/OptimizerTests.java +++ b/x-pack/plugin/sql/src/test/java/org/elasticsearch/xpack/sql/optimizer/OptimizerTests.java @@ -56,7 +56,6 @@ import org.elasticsearch.xpack.ql.type.EsField; import org.elasticsearch.xpack.ql.util.CollectionUtils; import org.elasticsearch.xpack.ql.util.StringUtils; import org.elasticsearch.xpack.sql.analysis.analyzer.Analyzer.PruneSubqueryAliases; -import org.elasticsearch.xpack.sql.expression.Foldables; import org.elasticsearch.xpack.sql.expression.function.aggregate.Avg; import org.elasticsearch.xpack.sql.expression.function.aggregate.ExtendedStats; import org.elasticsearch.xpack.sql.expression.function.aggregate.First; @@ -278,7 +277,7 @@ public class OptimizerTests extends ESTestCase { assertEquals(1, p.projections().size()); Alias a = (Alias) p.projections().get(0); In i = (In) a.child(); - assertThat(Foldables.valuesOf(i.list(), INTEGER), contains(1, 2, 3, 4)); + assertThat(i.list(), contains(ONE, TWO, THREE, FOUR)); } public void testConstantFoldingIn_RightValueIsNull() { diff --git a/x-pack/plugin/sql/src/test/java/org/elasticsearch/xpack/sql/tree/SqlNodeSubclassTests.java b/x-pack/plugin/sql/src/test/java/org/elasticsearch/xpack/sql/tree/SqlNodeSubclassTests.java index abbfc984186..55c00286eba 100644 --- a/x-pack/plugin/sql/src/test/java/org/elasticsearch/xpack/sql/tree/SqlNodeSubclassTests.java +++ b/x-pack/plugin/sql/src/test/java/org/elasticsearch/xpack/sql/tree/SqlNodeSubclassTests.java @@ -8,6 +8,7 @@ package org.elasticsearch.xpack.sql.tree; import org.elasticsearch.xpack.ql.expression.Expression; import org.elasticsearch.xpack.ql.expression.Literal; import org.elasticsearch.xpack.ql.expression.LiteralTests; +import org.elasticsearch.xpack.ql.expression.predicate.operator.comparison.InPipe; import org.elasticsearch.xpack.ql.tree.Node; import org.elasticsearch.xpack.ql.tree.NodeSubclassTests; import org.elasticsearch.xpack.ql.tree.SourceTests; @@ -22,7 +23,6 @@ import org.elasticsearch.xpack.sql.expression.predicate.conditional.IfConditiona import org.elasticsearch.xpack.sql.expression.predicate.conditional.IfNull; import org.elasticsearch.xpack.sql.expression.predicate.conditional.Iif; import org.elasticsearch.xpack.sql.expression.predicate.operator.comparison.In; -import org.elasticsearch.xpack.sql.expression.predicate.operator.comparison.InPipe; import java.util.List;