Skip to content

Commit

Permalink
Revert "[ES|QL] Moving argument compatibility checking for Equals (#1…
Browse files Browse the repository at this point in the history
…05217)" (#107537)

* Revert "[ES|QL] Moving argument compatibility checking for Equals (#105217)"

This reverts commit af8e4bf.

* Update docs/changelog/107537.yaml
  • Loading branch information
not-napoleon authored Apr 16, 2024
1 parent 7e18768 commit 225edaf
Show file tree
Hide file tree
Showing 21 changed files with 245 additions and 825 deletions.
5 changes: 5 additions & 0 deletions docs/changelog/107537.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 107537
summary: "Revert \"[ES|QL] Moving argument compatibility checking for Equals\""
area: ES|QL
type: bug
issues: []
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,6 @@ nullOnMultivaluesComparisonOperation
required_feature: esql.disable_nullable_opts

ROW a = 5, b = [ 1, 2 ]| EVAL same = a == b| LIMIT 1 | WHERE same IS NULL;
warning:Line 1:38: evaluation of [a == b] failed, treating result as null. Only first 20 failures recorded.
warning:Line 1:38: java.lang.IllegalArgumentException: single-value function encountered multi-value


a:integer | b:integer | same:boolean
5 | [1, 2] | null
Expand All @@ -169,8 +166,6 @@ notNullOnMultivaluesComparisonOperation
required_feature: esql.disable_nullable_opts

ROW a = 5, b = [ 1, 2 ]| EVAL same = a == b| LIMIT 1 | WHERE same IS NOT NULL;
warning:Line 1:38: evaluation of [a == b] failed, treating result as null. Only first 20 failures recorded.
warning:Line 1:38: java.lang.IllegalArgumentException: single-value function encountered multi-value

a:integer | b:integer | same:boolean
;
Expand All @@ -180,8 +175,6 @@ notNullOnMultivaluesComparisonOperationWithPartialMatch
required_feature: esql.disable_nullable_opts

ROW a = 5, b = [ 5, 2 ]| EVAL same = a == b| LIMIT 1 | WHERE same IS NOT NULL;
warning:Line 1:38: evaluation of [a == b] failed, treating result as null. Only first 20 failures recorded.
warning:Line 1:38: java.lang.IllegalArgumentException: single-value function encountered multi-value

a:integer | b:integer | same:boolean
;
Original file line number Diff line number Diff line change
Expand Up @@ -8,48 +8,33 @@

import org.apache.lucene.util.BytesRef;
import org.elasticsearch.compute.ann.Evaluator;
import org.elasticsearch.xpack.esql.expression.predicate.operator.arithmetic.EsqlArithmeticOperation;
import org.elasticsearch.xpack.esql.type.EsqlDataTypes;
import org.elasticsearch.xpack.esql.expression.EsqlTypeResolutions;
import org.elasticsearch.xpack.ql.expression.Expression;
import org.elasticsearch.xpack.ql.expression.predicate.Negatable;
import org.elasticsearch.xpack.ql.expression.TypeResolutions;
import org.elasticsearch.xpack.ql.expression.predicate.operator.comparison.BinaryComparison;
import org.elasticsearch.xpack.ql.expression.predicate.operator.comparison.BinaryComparisonProcessor;
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 java.time.ZoneId;
import java.util.Map;

public class Equals extends EsqlBinaryComparison implements Negatable<BinaryComparison> {
private static final Map<DataType, EsqlArithmeticOperation.BinaryEvaluator> evaluatorMap = Map.ofEntries(
Map.entry(DataTypes.BOOLEAN, EqualsBoolsEvaluator.Factory::new),
Map.entry(DataTypes.INTEGER, EqualsIntsEvaluator.Factory::new),
Map.entry(DataTypes.DOUBLE, EqualsDoublesEvaluator.Factory::new),
Map.entry(DataTypes.LONG, EqualsLongsEvaluator.Factory::new),
Map.entry(DataTypes.UNSIGNED_LONG, EqualsLongsEvaluator.Factory::new),
Map.entry(DataTypes.DATETIME, EqualsLongsEvaluator.Factory::new),
Map.entry(EsqlDataTypes.GEO_POINT, EqualsGeometriesEvaluator.Factory::new),
Map.entry(EsqlDataTypes.CARTESIAN_POINT, EqualsGeometriesEvaluator.Factory::new),
Map.entry(EsqlDataTypes.GEO_SHAPE, EqualsGeometriesEvaluator.Factory::new),
Map.entry(EsqlDataTypes.CARTESIAN_SHAPE, EqualsGeometriesEvaluator.Factory::new),
Map.entry(DataTypes.KEYWORD, EqualsKeywordsEvaluator.Factory::new),
Map.entry(DataTypes.TEXT, EqualsKeywordsEvaluator.Factory::new),
Map.entry(DataTypes.VERSION, EqualsKeywordsEvaluator.Factory::new),
Map.entry(DataTypes.IP, EqualsKeywordsEvaluator.Factory::new)
);

import static org.elasticsearch.xpack.ql.expression.TypeResolutions.ParamOrdinal.DEFAULT;

public class Equals extends org.elasticsearch.xpack.ql.expression.predicate.operator.comparison.Equals {
public Equals(Source source, Expression left, Expression right) {
super(source, left, right, BinaryComparisonProcessor.BinaryComparisonOperation.EQ, evaluatorMap);
super(source, left, right);
}

public Equals(Source source, Expression left, Expression right, ZoneId zoneId) {
super(source, left, right, BinaryComparisonProcessor.BinaryComparisonOperation.EQ, zoneId, evaluatorMap);
super(source, left, right, zoneId);
}

@Override
protected TypeResolution resolveInputType(Expression e, TypeResolutions.ParamOrdinal paramOrdinal) {
return EsqlTypeResolutions.isExact(e, sourceText(), DEFAULT);
}

@Override
protected NodeInfo<Equals> info() {
protected NodeInfo<org.elasticsearch.xpack.ql.expression.predicate.operator.comparison.Equals> info() {
return NodeInfo.create(this, Equals::new, left(), right(), zoneId());
}

Expand All @@ -63,11 +48,6 @@ public Equals swapLeftAndRight() {
return new Equals(source(), right(), left(), zoneId());
}

@Override
public BinaryComparison reverse() {
return this;
}

@Override
public BinaryComparison negate() {
return new NotEquals(source(), left(), right(), zoneId());
Expand Down Expand Up @@ -102,5 +82,4 @@ static boolean processBools(boolean lhs, boolean rhs) {
static boolean processGeometries(BytesRef lhs, BytesRef rhs) {
return lhs.equals(rhs);
}

}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,42 +8,29 @@

import org.apache.lucene.util.BytesRef;
import org.elasticsearch.compute.ann.Evaluator;
import org.elasticsearch.xpack.esql.expression.predicate.operator.arithmetic.EsqlArithmeticOperation;
import org.elasticsearch.xpack.esql.expression.EsqlTypeResolutions;
import org.elasticsearch.xpack.ql.expression.Expression;
import org.elasticsearch.xpack.ql.expression.predicate.Negatable;
import org.elasticsearch.xpack.ql.expression.TypeResolutions;
import org.elasticsearch.xpack.ql.expression.predicate.operator.comparison.BinaryComparison;
import org.elasticsearch.xpack.ql.expression.predicate.operator.comparison.BinaryComparisonProcessor;
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 java.time.ZoneId;
import java.util.Map;

public class GreaterThan extends EsqlBinaryComparison implements Negatable<BinaryComparison> {
private static final Map<DataType, EsqlArithmeticOperation.BinaryEvaluator> evaluatorMap = Map.ofEntries(
Map.entry(DataTypes.INTEGER, GreaterThanIntsEvaluator.Factory::new),
Map.entry(DataTypes.DOUBLE, GreaterThanDoublesEvaluator.Factory::new),
Map.entry(DataTypes.LONG, GreaterThanLongsEvaluator.Factory::new),
Map.entry(DataTypes.UNSIGNED_LONG, GreaterThanLongsEvaluator.Factory::new),
Map.entry(DataTypes.DATETIME, GreaterThanLongsEvaluator.Factory::new),
Map.entry(DataTypes.KEYWORD, GreaterThanKeywordsEvaluator.Factory::new),
Map.entry(DataTypes.TEXT, GreaterThanKeywordsEvaluator.Factory::new),
Map.entry(DataTypes.VERSION, GreaterThanKeywordsEvaluator.Factory::new),
Map.entry(DataTypes.IP, GreaterThanKeywordsEvaluator.Factory::new)
);
import static org.elasticsearch.xpack.ql.expression.TypeResolutions.ParamOrdinal.DEFAULT;

public GreaterThan(Source source, Expression left, Expression right) {
super(source, left, right, BinaryComparisonProcessor.BinaryComparisonOperation.GT, evaluatorMap);
public class GreaterThan extends org.elasticsearch.xpack.ql.expression.predicate.operator.comparison.GreaterThan {
public GreaterThan(Source source, Expression left, Expression right, ZoneId zoneId) {
super(source, left, right, zoneId);
}

public GreaterThan(Source source, Expression left, Expression right, ZoneId zoneId) {
super(source, left, right, BinaryComparisonProcessor.BinaryComparisonOperation.GT, zoneId, evaluatorMap);
@Override
protected TypeResolution resolveInputType(Expression e, TypeResolutions.ParamOrdinal paramOrdinal) {
return EsqlTypeResolutions.isExact(e, sourceText(), DEFAULT);
}

@Override
protected NodeInfo<GreaterThan> info() {
protected NodeInfo<org.elasticsearch.xpack.ql.expression.predicate.operator.comparison.GreaterThan> info() {
return NodeInfo.create(this, GreaterThan::new, left(), right(), zoneId());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,42 +8,30 @@

import org.apache.lucene.util.BytesRef;
import org.elasticsearch.compute.ann.Evaluator;
import org.elasticsearch.xpack.esql.expression.predicate.operator.arithmetic.EsqlArithmeticOperation;
import org.elasticsearch.xpack.esql.expression.EsqlTypeResolutions;
import org.elasticsearch.xpack.ql.expression.Expression;
import org.elasticsearch.xpack.ql.expression.predicate.Negatable;
import org.elasticsearch.xpack.ql.expression.TypeResolutions;
import org.elasticsearch.xpack.ql.expression.predicate.operator.comparison.BinaryComparison;
import org.elasticsearch.xpack.ql.expression.predicate.operator.comparison.BinaryComparisonProcessor;
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 java.time.ZoneId;
import java.util.Map;

public class GreaterThanOrEqual extends EsqlBinaryComparison implements Negatable<BinaryComparison> {
private static final Map<DataType, EsqlArithmeticOperation.BinaryEvaluator> evaluatorMap = Map.ofEntries(
Map.entry(DataTypes.INTEGER, GreaterThanOrEqualIntsEvaluator.Factory::new),
Map.entry(DataTypes.DOUBLE, GreaterThanOrEqualDoublesEvaluator.Factory::new),
Map.entry(DataTypes.LONG, GreaterThanOrEqualLongsEvaluator.Factory::new),
Map.entry(DataTypes.UNSIGNED_LONG, GreaterThanOrEqualLongsEvaluator.Factory::new),
Map.entry(DataTypes.DATETIME, GreaterThanOrEqualLongsEvaluator.Factory::new),
Map.entry(DataTypes.KEYWORD, GreaterThanOrEqualKeywordsEvaluator.Factory::new),
Map.entry(DataTypes.TEXT, GreaterThanOrEqualKeywordsEvaluator.Factory::new),
Map.entry(DataTypes.VERSION, GreaterThanOrEqualKeywordsEvaluator.Factory::new),
Map.entry(DataTypes.IP, GreaterThanOrEqualKeywordsEvaluator.Factory::new)
);
import static org.elasticsearch.xpack.ql.expression.TypeResolutions.ParamOrdinal.DEFAULT;

public GreaterThanOrEqual(Source source, Expression left, Expression right) {
super(source, left, right, BinaryComparisonProcessor.BinaryComparisonOperation.GTE, evaluatorMap);
}
public class GreaterThanOrEqual extends org.elasticsearch.xpack.ql.expression.predicate.operator.comparison.GreaterThanOrEqual {

public GreaterThanOrEqual(Source source, Expression left, Expression right, ZoneId zoneId) {
super(source, left, right, BinaryComparisonProcessor.BinaryComparisonOperation.GTE, zoneId, evaluatorMap);
super(source, left, right, zoneId);
}

@Override
protected TypeResolution resolveInputType(Expression e, TypeResolutions.ParamOrdinal paramOrdinal) {
return EsqlTypeResolutions.isExact(e, sourceText(), DEFAULT);
}

@Override
protected NodeInfo<GreaterThanOrEqual> info() {
protected NodeInfo<org.elasticsearch.xpack.ql.expression.predicate.operator.comparison.GreaterThanOrEqual> info() {
return NodeInfo.create(this, GreaterThanOrEqual::new, left(), right(), zoneId());
}

Expand Down
Loading

0 comments on commit 225edaf

Please sign in to comment.