/** * Convert a map of columns to values into the TupleDomain which requires * those columns to be fixed to those values. Null is allowed as a fixed value. */ public static <T> TupleDomain<T> fromFixedValues(Map<T, NullableValue> fixedValues) { return TupleDomain.withColumnDomains(fixedValues.entrySet().stream() .collect(toMap( Map.Entry::getKey, entry -> { Type type = entry.getValue().getType(); Object value = entry.getValue().getValue(); return value == null ? Domain.onlyNull(type) : Domain.singleValue(type, value); }))); }
private Optional<Expression> coerceComparisonWithRounding( Type symbolExpressionType, Expression symbolExpression, NullableValue nullableValue, ComparisonExpression.Operator comparisonOperator) { requireNonNull(nullableValue, "nullableValue is null"); if (nullableValue.isNull()) { return Optional.empty(); } Type valueType = nullableValue.getType(); Object value = nullableValue.getValue(); return floorValue(valueType, symbolExpressionType, value) .map((floorValue) -> rewriteComparisonExpression(symbolExpressionType, symbolExpression, valueType, value, floorValue, comparisonOperator)); }
private Optional<Expression> coerceComparisonWithRounding( Type symbolExpressionType, Expression symbolExpression, NullableValue nullableValue, ComparisonExpression.Operator comparisonOperator) { requireNonNull(nullableValue, "nullableValue is null"); if (nullableValue.isNull()) { return Optional.empty(); } Type valueType = nullableValue.getType(); Object value = nullableValue.getValue(); return floorValue(valueType, symbolExpressionType, value) .map((floorValue) -> rewriteComparisonExpression(symbolExpressionType, symbolExpression, valueType, value, floorValue, comparisonOperator)); }
private static Domain buildColumnDomain(ColumnHandle column, List<HivePartition> partitions) { checkArgument(!partitions.isEmpty(), "partitions cannot be empty"); boolean hasNull = false; List<Object> nonNullValues = new ArrayList<>(); Type type = null; for (HivePartition partition : partitions) { NullableValue value = partition.getKeys().get(column); if (value == null) { throw new PrestoException(HIVE_UNKNOWN_ERROR, format("Partition %s does not have a value for partition column %s", partition, column)); } if (value.isNull()) { hasNull = true; } else { nonNullValues.add(value.getValue()); } if (type == null) { type = value.getType(); } } if (!nonNullValues.isEmpty()) { Domain domain = Domain.multipleValues(type, nonNullValues); if (hasNull) { return domain.union(Domain.onlyNull(type)); } return domain; } return Domain.onlyNull(type); }
Symbol symbol = Symbol.from(symbolExpression); NullableValue value = normalized.getValue(); Type type = value.getType(); // common type for symbol and value return createComparisonExtractionResult(normalized.getComparisonOperator(), symbol, type, value.getValue(), complement);
Symbol symbol = Symbol.from(symbolExpression); NullableValue value = normalized.getValue(); Type type = value.getType(); // common type for symbol and value return createComparisonExtractionResult(normalized.getComparisonOperator(), symbol, type, value.getValue(), complement);
.map(argument -> { if (argument.isConstant()) { return argument.getConstant().getType();
.map(argument -> { if (argument.isConstant()) { return argument.getConstant().getType();