public static NullableValue asNull(Type type) { return new NullableValue(type, null); }
public static NullableValue of(Type type, Object value) { requireNonNull(value, "value is null"); return new NullableValue(type, value); }
/** * Extract all column constraints that require exactly one value or only null in their respective Domains. * Returns an empty Optional if the Domain is none. */ public static <T> Optional<Map<T, NullableValue>> extractFixedValues(TupleDomain<T> tupleDomain) { if (!tupleDomain.getDomains().isPresent()) { return Optional.empty(); } return Optional.of(tupleDomain.getDomains().get() .entrySet().stream() .filter(entry -> entry.getValue().isNullableSingleValue()) .collect(toMap(Map.Entry::getKey, entry -> new NullableValue(entry.getValue().getType(), entry.getValue().getNullableSingleValue())))); }
private Map<ColumnHandle, NullableValue> schemaAsFixedValues(String schema) { return ImmutableMap.of(SCHEMA_COLUMN_HANDLE, new NullableValue(createUnboundedVarcharType(), utf8Slice(schema))); }
@JsonCreator public static NullableValue fromSerializable(@JsonProperty("serializable") Serializable serializable) { Type type = serializable.getType(); Block block = serializable.getBlock(); return new NullableValue(type, block == null ? null : Utils.blockToNativeValue(type, block)); }
private Map<ColumnHandle, NullableValue> asFixedValues(QualifiedObjectName objectName) { return ImmutableMap.of( CATALOG_COLUMN_HANDLE, new NullableValue(createUnboundedVarcharType(), utf8Slice(objectName.getCatalogName())), SCHEMA_COLUMN_HANDLE, new NullableValue(createUnboundedVarcharType(), utf8Slice(objectName.getSchemaName())), TABLE_NAME_COLUMN_HANDLE, new NullableValue(createUnboundedVarcharType(), utf8Slice(objectName.getObjectName()))); }
private static TupleDomain<ColumnHandle> fixedValueTupleDomain(TpchMetadata tpchMetadata, TpchColumn<?> column, Object value) { requireNonNull(column, "column is null"); requireNonNull(value, "value is null"); return TupleDomain.fromFixedValues( ImmutableMap.of(tpchMetadata.toColumnHandle(column), new NullableValue(getPrestoType(column), value))); }
NullableValue existingConstantValue = constants.get(symbol); if (existingConstantValue != null) { constants.put(assignment.getKey(), new NullableValue(type, value)); constants.put(assignment.getKey(), new NullableValue(type, value));
private static TupleDomain<ColumnHandle> fixedValueTupleDomain(TpchMetadata tpchMetadata, TpchColumn<?> column1, Object value1, TpchColumn<?> column2, Object value2) { return TupleDomain.fromFixedValues( ImmutableMap.of( tpchMetadata.toColumnHandle(column1), new NullableValue(getPrestoType(column1), value1), tpchMetadata.toColumnHandle(column2), new NullableValue(getPrestoType(column2), value2))); }
symbolExpression = comparison.getLeft(); comparisonOperator = comparison.getOperator(); value = new NullableValue(rightType, right); value = new NullableValue(leftType, left);
public static NullableValue asNull(Type type) { return new NullableValue(type, null); }
public static NullableValue of(Type type, Object value) { requireNonNull(value, "value is null"); return new NullableValue(type, value); }
/** * Extract all column constraints that require exactly one value or only null in their respective Domains. * Returns an empty Optional if the Domain is none. */ public static <T> Optional<Map<T, NullableValue>> extractFixedValues(TupleDomain<T> tupleDomain) { if (!tupleDomain.getDomains().isPresent()) { return Optional.empty(); } return Optional.of(tupleDomain.getDomains().get() .entrySet().stream() .filter(entry -> entry.getValue().isNullableSingleValue()) .collect(toMap(Map.Entry::getKey, entry -> new NullableValue(entry.getValue().getType(), entry.getValue().getNullableSingleValue())))); }
@JsonCreator public static NullableValue fromSerializable(@JsonProperty("serializable") Serializable serializable) { Type type = serializable.getType(); Block block = serializable.getBlock(); return new NullableValue(type, block == null ? null : Utils.blockToNativeValue(type, block)); }
/** * Extract a normalized simple comparison between a QualifiedNameReference and a native value if possible. */ private static Optional<NormalizedSimpleComparison> toNormalizedSimpleComparison(Session session, Metadata metadata, Map<Symbol, Type> types, ComparisonExpression comparison) { IdentityHashMap<Expression, Type> expressionTypes = ExpressionAnalyzer.getExpressionTypes(session, metadata, new SqlParser(), types, comparison); Object left = ExpressionInterpreter.expressionOptimizer(comparison.getLeft(), metadata, session, expressionTypes).optimize(NoOpSymbolResolver.INSTANCE); Object right = ExpressionInterpreter.expressionOptimizer(comparison.getRight(), metadata, session, expressionTypes).optimize(NoOpSymbolResolver.INSTANCE); if (left instanceof QualifiedNameReference && !(right instanceof Expression)) { return Optional.of(new NormalizedSimpleComparison((QualifiedNameReference) left, comparison.getType(), new NullableValue(expressionTypes.get(comparison.getRight()), right))); } if (right instanceof QualifiedNameReference && !(left instanceof Expression)) { return Optional.of(new NormalizedSimpleComparison((QualifiedNameReference) right, comparison.getType().flip(), new NullableValue(expressionTypes.get(comparison.getLeft()), left))); } return Optional.empty(); }
NullableValue existingConstantValue = constants.get(symbol); if (existingConstantValue != null) { constants.put(assignment.getKey(), new NullableValue(type, value)); constants.put(assignment.getKey(), new NullableValue(type, value));
private static TupleDomain<ColumnHandle> fixedValueTupleDomain(TpchMetadata tpchMetadata, TpchColumn<?> column, Object value) { requireNonNull(column, "column is null"); requireNonNull(value, "value is null"); return TupleDomain.fromFixedValues( ImmutableMap.of(tpchMetadata.toColumnHandle(column), new NullableValue(getPrestoType(column), value))); }
private static TupleDomain<ColumnHandle> fixedValueTupleDomain(TpchMetadata tpchMetadata, TpchColumn<?> column1, Object value1, TpchColumn<?> column2, Object value2) { return TupleDomain.fromFixedValues( ImmutableMap.of( tpchMetadata.toColumnHandle(column1), new NullableValue(getPrestoType(column1), value1), tpchMetadata.toColumnHandle(column2), new NullableValue(getPrestoType(column2), value2))); }