Search in sources :

Example 1 with IN

use of com.facebook.presto.spi.relation.SpecialFormExpression.Form.IN in project presto by prestodb.

the class RowExpressionDomainTranslator method extractDisjuncts.

private List<RowExpression> extractDisjuncts(Type type, DiscreteValues discreteValues, RowExpression reference) {
    List<RowExpression> values = discreteValues.getValues().stream().map(object -> toRowExpression(reference.getSourceLocation(), object, type)).collect(toList());
    // If values is empty, then the equatableValues was either ALL or NONE, both of which should already have been checked for
    checkState(!values.isEmpty());
    RowExpression predicate;
    if (values.size() == 1) {
        predicate = equal(reference, getOnlyElement(values));
    } else {
        predicate = in(reference, values);
    }
    if (!discreteValues.isWhiteList()) {
        predicate = not(functionResolution, predicate);
    }
    return ImmutableList.of(predicate);
}
Also used : FunctionAndTypeManager(com.facebook.presto.metadata.FunctionAndTypeManager) SATURATED_FLOOR_CAST(com.facebook.presto.metadata.CastType.SATURATED_FLOOR_CAST) IS_NULL(com.facebook.presto.spi.relation.SpecialFormExpression.Form.IS_NULL) DiscreteValues(com.facebook.presto.common.predicate.DiscreteValues) RowExpressionVisitor(com.facebook.presto.spi.relation.RowExpressionVisitor) VariableReferenceExpression(com.facebook.presto.spi.relation.VariableReferenceExpression) IS_DISTINCT_FROM(com.facebook.presto.common.function.OperatorType.IS_DISTINCT_FROM) SortedRangeSet(com.facebook.presto.common.predicate.SortedRangeSet) StandardFunctionResolution(com.facebook.presto.spi.function.StandardFunctionResolution) PeekingIterator(com.google.common.collect.PeekingIterator) Preconditions.checkArgument(com.google.common.base.Preconditions.checkArgument) Map(java.util.Map) EQUAL(com.facebook.presto.common.function.OperatorType.EQUAL) FALSE_CONSTANT(com.facebook.presto.expressions.LogicalRowExpressions.FALSE_CONSTANT) AND(com.facebook.presto.spi.relation.SpecialFormExpression.Form.AND) LESS_THAN(com.facebook.presto.common.function.OperatorType.LESS_THAN) CallExpression(com.facebook.presto.spi.relation.CallExpression) Marker(com.facebook.presto.common.predicate.Marker) SpecialFormExpression(com.facebook.presto.spi.relation.SpecialFormExpression) IN(com.facebook.presto.spi.relation.SpecialFormExpression.Form.IN) RowExpressionInterpreter(com.facebook.presto.sql.planner.RowExpressionInterpreter) NullableValue(com.facebook.presto.common.predicate.NullableValue) InterpretedFunctionInvoker(com.facebook.presto.sql.InterpretedFunctionInvoker) ImmutableMap(com.google.common.collect.ImmutableMap) ImmutableList.toImmutableList(com.google.common.collect.ImmutableList.toImmutableList) DomainTranslator(com.facebook.presto.spi.relation.DomainTranslator) LambdaDefinitionExpression(com.facebook.presto.spi.relation.LambdaDefinitionExpression) LiteralEncoder.toRowExpression(com.facebook.presto.sql.planner.LiteralEncoder.toRowExpression) TRUE_CONSTANT(com.facebook.presto.expressions.LogicalRowExpressions.TRUE_CONSTANT) Range(com.facebook.presto.common.predicate.Range) Preconditions.checkState(com.google.common.base.Preconditions.checkState) ConnectorSession(com.facebook.presto.spi.ConnectorSession) FunctionMetadata(com.facebook.presto.spi.function.FunctionMetadata) List(java.util.List) OperatorNotFoundException(com.facebook.presto.metadata.OperatorNotFoundException) Optional(java.util.Optional) InputReferenceExpression(com.facebook.presto.spi.relation.InputReferenceExpression) CAST(com.facebook.presto.metadata.CastType.CAST) Ranges(com.facebook.presto.common.predicate.Ranges) DeterminismEvaluator(com.facebook.presto.spi.relation.DeterminismEvaluator) NOT_EQUAL(com.facebook.presto.common.function.OperatorType.NOT_EQUAL) Utils(com.facebook.presto.common.Utils) Collectors.collectingAndThen(java.util.stream.Collectors.collectingAndThen) ConstantExpression(com.facebook.presto.spi.relation.ConstantExpression) TypeSignatureProvider.fromTypes(com.facebook.presto.sql.analyzer.TypeSignatureProvider.fromTypes) Expressions.call(com.facebook.presto.sql.relational.Expressions.call) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) LESS_THAN_OR_EQUAL(com.facebook.presto.common.function.OperatorType.LESS_THAN_OR_EQUAL) ImmutableList(com.google.common.collect.ImmutableList) LogicalRowExpressions(com.facebook.presto.expressions.LogicalRowExpressions) Objects.requireNonNull(java.util.Objects.requireNonNull) BOOLEAN(com.facebook.presto.common.type.BooleanType.BOOLEAN) Form(com.facebook.presto.spi.relation.SpecialFormExpression.Form) OR(com.facebook.presto.spi.relation.SpecialFormExpression.Form.OR) Iterators.peekingIterator(com.google.common.collect.Iterators.peekingIterator) Type(com.facebook.presto.common.type.Type) Nullable(javax.annotation.Nullable) RowExpression(com.facebook.presto.spi.relation.RowExpression) LogicalRowExpressions.and(com.facebook.presto.expressions.LogicalRowExpressions.and) Iterables.getOnlyElement(com.google.common.collect.Iterables.getOnlyElement) OperatorType(com.facebook.presto.common.function.OperatorType) Domain(com.facebook.presto.common.predicate.Domain) TupleDomain(com.facebook.presto.common.predicate.TupleDomain) GREATER_THAN_OR_EQUAL(com.facebook.presto.common.function.OperatorType.GREATER_THAN_OR_EQUAL) GREATER_THAN(com.facebook.presto.common.function.OperatorType.GREATER_THAN) OPTIMIZED(com.facebook.presto.spi.relation.ExpressionOptimizer.Level.OPTIMIZED) Collectors.toList(java.util.stream.Collectors.toList) BETWEEN(com.facebook.presto.common.function.OperatorType.BETWEEN) LogicalRowExpressions.or(com.facebook.presto.expressions.LogicalRowExpressions.or) FunctionHandle(com.facebook.presto.spi.function.FunctionHandle) Block(com.facebook.presto.common.block.Block) ValueSet(com.facebook.presto.common.predicate.ValueSet) Metadata(com.facebook.presto.metadata.Metadata) LiteralEncoder.toRowExpression(com.facebook.presto.sql.planner.LiteralEncoder.toRowExpression) RowExpression(com.facebook.presto.spi.relation.RowExpression)

Aggregations

Utils (com.facebook.presto.common.Utils)1 Block (com.facebook.presto.common.block.Block)1 OperatorType (com.facebook.presto.common.function.OperatorType)1 BETWEEN (com.facebook.presto.common.function.OperatorType.BETWEEN)1 EQUAL (com.facebook.presto.common.function.OperatorType.EQUAL)1 GREATER_THAN (com.facebook.presto.common.function.OperatorType.GREATER_THAN)1 GREATER_THAN_OR_EQUAL (com.facebook.presto.common.function.OperatorType.GREATER_THAN_OR_EQUAL)1 IS_DISTINCT_FROM (com.facebook.presto.common.function.OperatorType.IS_DISTINCT_FROM)1 LESS_THAN (com.facebook.presto.common.function.OperatorType.LESS_THAN)1 LESS_THAN_OR_EQUAL (com.facebook.presto.common.function.OperatorType.LESS_THAN_OR_EQUAL)1 NOT_EQUAL (com.facebook.presto.common.function.OperatorType.NOT_EQUAL)1 DiscreteValues (com.facebook.presto.common.predicate.DiscreteValues)1 Domain (com.facebook.presto.common.predicate.Domain)1 Marker (com.facebook.presto.common.predicate.Marker)1 NullableValue (com.facebook.presto.common.predicate.NullableValue)1 Range (com.facebook.presto.common.predicate.Range)1 Ranges (com.facebook.presto.common.predicate.Ranges)1 SortedRangeSet (com.facebook.presto.common.predicate.SortedRangeSet)1 TupleDomain (com.facebook.presto.common.predicate.TupleDomain)1 ValueSet (com.facebook.presto.common.predicate.ValueSet)1