Search in sources :

Example 1 with CompareToTerm

use of io.confluent.ksql.execution.interpreter.terms.ComparisonTerm.CompareToTerm in project ksql by confluentinc.

the class ComparisonInterpreter method doComparison.

/**
 * Does a comparison between the two terms
 * @param type The type of the comparison
 * @param left Left term
 * @param right Right term
 * @return The term representing the result of the comparison
 */
public static Term doComparison(final ComparisonExpression.Type type, final Term left, final Term right) {
    final ComparisonNullCheckFunction nullCheckFunction = getNullCheckFunction(type);
    final Optional<ComparisonFunction> compareTo = doCompareTo(left, right);
    if (compareTo.isPresent()) {
        return new CompareToTerm(left, right, nullCheckFunction, compareTo.get(), getComparisonCheckFunction(type, left, right));
    }
    final Optional<EqualsFunction> equals = doEquals(left, right);
    if (equals.isPresent()) {
        return new EqualsTerm(left, right, nullCheckFunction, equals.get(), getEqualsCheckFunction(type, left, right));
    }
    throw new KsqlException("Unsupported comparison between " + left.getSqlType() + " and " + right.getSqlType());
}
Also used : ComparisonNullCheckFunction(io.confluent.ksql.execution.interpreter.terms.ComparisonTerm.ComparisonNullCheckFunction) ComparisonFunction(io.confluent.ksql.execution.interpreter.terms.ComparisonTerm.ComparisonFunction) EqualsTerm(io.confluent.ksql.execution.interpreter.terms.ComparisonTerm.EqualsTerm) CompareToTerm(io.confluent.ksql.execution.interpreter.terms.ComparisonTerm.CompareToTerm) KsqlException(io.confluent.ksql.util.KsqlException) EqualsFunction(io.confluent.ksql.execution.interpreter.terms.ComparisonTerm.EqualsFunction)

Aggregations

CompareToTerm (io.confluent.ksql.execution.interpreter.terms.ComparisonTerm.CompareToTerm)1 ComparisonFunction (io.confluent.ksql.execution.interpreter.terms.ComparisonTerm.ComparisonFunction)1 ComparisonNullCheckFunction (io.confluent.ksql.execution.interpreter.terms.ComparisonTerm.ComparisonNullCheckFunction)1 EqualsFunction (io.confluent.ksql.execution.interpreter.terms.ComparisonTerm.EqualsFunction)1 EqualsTerm (io.confluent.ksql.execution.interpreter.terms.ComparisonTerm.EqualsTerm)1 KsqlException (io.confluent.ksql.util.KsqlException)1