Class EsqlBinaryComparison
- All Implemented Interfaces:
NamedWriteable,Writeable,TranslationAware,TranslationAware.SingleValueTranslationAware,Resolvable,EvaluatorMapper
- Direct Known Subclasses:
Equals,GreaterThan,GreaterThanOrEqual,LessThan,LessThanOrEqual,NotEquals
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumstatic interfaceNested classes/interfaces inherited from class org.elasticsearch.xpack.esql.core.expression.Expression
Expression.TypeResolutionNested classes/interfaces inherited from class org.elasticsearch.xpack.esql.core.tree.Node
Node.NodeStringFormatNested classes/interfaces inherited from interface org.elasticsearch.xpack.esql.evaluator.mapper.EvaluatorMapper
EvaluatorMapper.ToEvaluatorNested classes/interfaces inherited from interface org.elasticsearch.xpack.esql.capabilities.TranslationAware
TranslationAware.FinishedTranslatable, TranslationAware.SingleValueTranslationAware, TranslationAware.TranslatableNested classes/interfaces inherited from interface org.elasticsearch.common.io.stream.Writeable
Writeable.Reader<V>, Writeable.Writer<V> -
Field Summary
Fields inherited from class org.elasticsearch.xpack.esql.core.expression.function.scalar.ScalarFunction
MAX_BYTES_REF_RESULT_SIZEFields inherited from class org.elasticsearch.xpack.esql.core.tree.Node
TO_STRING_MAX_LINES, TO_STRING_MAX_WIDTH -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedEsqlBinaryComparison(Source source, Expression left, Expression right, EsqlBinaryComparison.BinaryComparisonOperation operation, ZoneId zoneId, Map<DataType, EsqlArithmeticOperation.BinaryEvaluator> evaluatorMap, EsqlArithmeticOperation.BinaryEvaluator nanosToMillisEvaluator, EsqlArithmeticOperation.BinaryEvaluator millisToNanosEvaluator) protectedEsqlBinaryComparison(Source source, Expression left, Expression right, EsqlBinaryComparison.BinaryComparisonOperation operation, Map<DataType, EsqlArithmeticOperation.BinaryEvaluator> evaluatorMap, EsqlArithmeticOperation.BinaryEvaluator nanosToMillisEvaluator, EsqlArithmeticOperation.BinaryEvaluator millisToNanosEvaluator) -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanareTypesCompatible(DataType leftType, DataType rightType) Check if the two types are compatible for binary comparison.asQuery(LucenePushdownPredicates pushdownPredicates, TranslatorHandler handler) This method is responsible for pushing the ES|QL Binary Comparison operators into Lucene.protected Expression.TypeResolutionCheck if the two input types are compatible for this operation.fold(FoldContext ctx) Evaluate this expression statically to a constant.static StringformatIncompatibleTypesMessage(DataType leftType, DataType rightType, String sourceText) static EsqlBinaryComparisonreadFrom(StreamInput in) protected Expression.TypeResolutionresolveInputType(Expression e, TypeResolutions.ParamOrdinal paramOrdinal) protected Expression.TypeResolutionThe implementation ofExpression.typeResolved(), which is just a caching wrapper around this method.Returns the field that only supports single-value semantics.toEvaluator(EvaluatorMapper.ToEvaluator toEvaluator) Convert this into anExpressionEvaluator.translatable(LucenePushdownPredicates pushdownPredicates) Can this instance be translated or not? Usually checks whether the expression arguments are actual fields that exist in Lucene.final voidwriteTo(StreamOutput out) Methods inherited from class org.elasticsearch.xpack.esql.core.expression.predicate.operator.comparison.BinaryComparison
compare, dataType, reverse, zoneIdMethods inherited from class org.elasticsearch.xpack.esql.core.expression.predicate.BinaryOperator
canonicalize, collectCommutative, isCommutative, swapLeftAndRightMethods inherited from class org.elasticsearch.xpack.esql.core.expression.predicate.BinaryPredicate
equals, function, hashCode, nodeString, symbolMethods inherited from class org.elasticsearch.xpack.esql.core.expression.function.scalar.BinaryScalarFunction
foldable, left, replaceChildren, replaceChildren, rightMethods inherited from class org.elasticsearch.xpack.esql.core.expression.function.Function
arguments, functionName, nullableMethods inherited from class org.elasticsearch.xpack.esql.core.expression.Expression
canonical, childrenResolved, propertiesToString, references, resolved, semanticEquals, semanticHash, toString, toString, typeResolvedMethods inherited from class org.elasticsearch.xpack.esql.core.tree.Node
allMatch, anyMatch, children, collect, collect, collect, collectFirstChildren, collectLeaves, doCollectFirst, forEachDown, forEachDown, forEachDownMayReturnEarly, forEachProperty, forEachPropertyDown, forEachPropertyOnly, forEachPropertyUp, forEachUp, forEachUp, info, nodeName, nodeProperties, nodeString, replaceChildrenSameSize, source, sourceLocation, sourceText, transformChildren, transformChildren, transformDown, transformDown, transformDown, transformDown, transformDownSkipBranch, transformNodeProps, transformPropertiesDown, transformPropertiesOnly, transformPropertiesUp, transformUp, transformUp, transformUpMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.elasticsearch.xpack.esql.evaluator.mapper.EvaluatorMapper
foldMethods inherited from interface org.elasticsearch.common.io.stream.NamedWriteable
getWriteableNameMethods inherited from interface org.elasticsearch.xpack.esql.capabilities.TranslationAware
asLuceneQuery
-
Constructor Details
-
EsqlBinaryComparison
protected EsqlBinaryComparison(Source source, Expression left, Expression right, EsqlBinaryComparison.BinaryComparisonOperation operation, Map<DataType, EsqlArithmeticOperation.BinaryEvaluator> evaluatorMap, EsqlArithmeticOperation.BinaryEvaluator nanosToMillisEvaluator, EsqlArithmeticOperation.BinaryEvaluator millisToNanosEvaluator) -
EsqlBinaryComparison
protected EsqlBinaryComparison(Source source, Expression left, Expression right, EsqlBinaryComparison.BinaryComparisonOperation operation, ZoneId zoneId, Map<DataType, EsqlArithmeticOperation.BinaryEvaluator> evaluatorMap, EsqlArithmeticOperation.BinaryEvaluator nanosToMillisEvaluator, EsqlArithmeticOperation.BinaryEvaluator millisToNanosEvaluator)
-
-
Method Details
-
readFrom
- Throws:
IOException
-
writeTo
- Specified by:
writeToin interfaceWriteable- Overrides:
writeToin classBinaryScalarFunction- Throws:
IOException
-
getFunctionType
-
toEvaluator
Description copied from interface:EvaluatorMapperConvert this into anExpressionEvaluator.Note for implementors: If you are implementing this function, you should call the passed-in lambda on your children, after doing any other manipulation (casting, etc.) necessary.
Note for Callers: If you are attempting to call this method, and you have an
Expressionand aLayout, you likely want to callEvalMapper.toEvaluator(org.elasticsearch.xpack.esql.core.expression.FoldContext, org.elasticsearch.xpack.esql.core.expression.Expression, org.elasticsearch.xpack.esql.planner.Layout)instead. On the other hand, if you already have something that looks like the parameter for this method, you should call this method with that function.Build an
ExpressionEvaluator.Factoryfor the tree of expressions rooted at this node. This is only guaranteed to return a sensible evaluator if this node has a valid type. If this node is a subclass ofExpressionthen "valid type" means thatExpression.typeResolved()returns a non-error resolution. If Expression.typeResolved() returns an error then this method may throw. Or return an evaluator that produces garbage. Or return an evaluator that throws when run.- Specified by:
toEvaluatorin interfaceEvaluatorMapper
-
fold
Description copied from class:ExpressionEvaluate this expression statically to a constant. It is an error to call this ifExpression.foldable()returns false.- Overrides:
foldin classBinaryPredicate<Object,Object, Boolean, BinaryComparisonOperation>
-
resolveType
Description copied from class:ExpressionThe implementation ofExpression.typeResolved(), which is just a caching wrapper around this method. See it's javadoc for what this method should return.Implementations will rarely interact with the
Expression.TypeResolutionclass directly, instead usually calling the utility methods onTypeResolutions.Implementations should fail if
Expression.childrenResolved()returnsfalse.- Overrides:
resolveTypein classBinaryOperator<Object,Object, Boolean, BinaryComparisonOperation>
-
resolveInputType
protected Expression.TypeResolution resolveInputType(Expression e, TypeResolutions.ParamOrdinal paramOrdinal) - Overrides:
resolveInputTypein classBinaryComparison
-
checkCompatibility
Check if the two input types are compatible for this operation. NOTE: this method should be consistent withVerifier.validateBinaryComparison(BinaryComparison)- Returns:
- TypeResolution.TYPE_RESOLVED if the types are compatible. Otherwise, an appropriate type resolution error.
-
areTypesCompatible
Check if the two types are compatible for binary comparison.For UNSIGNED_LONG types, we ensure they are not implicitly converted when used in binary operations, as this cannot be done since: - unsigned longs are passed through the engine as longs, so/and - negative values cannot be represented (i.e. range [Long.MIN_VALUE, "abs"(Long.MIN_VALUE) + Long.MAX_VALUE] won't fit on 64 bits); - a conversion to double isn't possible, since upper range UL values can no longer be distinguished ex: (double) 18446744073709551615 == (double) 18446744073709551614 - the implicit ESQL's Cast doesn't currently catch Exception and nullify the result. Let the user handle the operation explicitly.
- Parameters:
leftType- the left operand typerightType- the right operand type- Returns:
- true if the types are compatible for comparison
-
formatIncompatibleTypesMessage
-
translatable
Description copied from interface:TranslationAwareCan this instance be translated or not? Usually checks whether the expression arguments are actual fields that exist in Lucene. SeeTranslationAware.Translatablefor precisely what can be signaled from this method.- Specified by:
translatablein interfaceTranslationAware
-
asQuery
This method is responsible for pushing the ES|QL Binary Comparison operators into Lucene. It covers: In general, we are able to push these down when one of the arguments is a constant (i.e. is foldable). This class assumes that an earlier pass through the query has rearranged things so that the foldable value will be the right hand side input to the operation.- Specified by:
asQueryin interfaceTranslationAware
-
singleValueField
Description copied from interface:TranslationAware.SingleValueTranslationAwareReturns the field that only supports single-value semantics.- Specified by:
singleValueFieldin interfaceTranslationAware.SingleValueTranslationAware
-