private List<Object> getSymbolValues(ValuesNode valuesNode, int symbolId, Session session, Type symbolType) { if (UNKNOWN.equals(symbolType)) { // special casing for UNKNOWN as evaluateConstantExpression does not handle that return IntStream.range(0, valuesNode.getRows().size()) .mapToObj(rowId -> null) .collect(toList()); } return valuesNode.getRows().stream() .map(row -> row.get(symbolId)) .map(expression -> evaluateConstantExpression(expression, symbolType, metadata, session, ImmutableList.of())) .collect(toList()); }
private void verifyTypeSignature(Symbol symbol, TypeSignature expected, TypeSignature actual) { // UNKNOWN should be considered as a wildcard type, which matches all the other types TypeManager typeManager = metadata.getTypeManager(); if (!actual.equals(UNKNOWN.getTypeSignature()) && !typeManager.isTypeOnlyCoercion(typeManager.getType(actual), typeManager.getType(expected))) { checkArgument(expected.equals(actual), "type of symbol '%s' is expected to be %s, but the actual type is %s", symbol, expected, actual); } } }
@Override public Block[] getSequenceBlocks(int start, int length) { BlockBuilder blockBuilder = UNKNOWN.createBlockBuilder(null, length); for (int i = 0; i < length; i++) { blockBuilder.appendNull(); } return new Block[] {blockBuilder.build()}; }
if (UNKNOWN.equals(actualType)) { actualTypeParametersTypeSignatureProvider = Collections.nCopies(formalTypeSignature.getParameters().size(), new TypeSignatureProvider(UNKNOWN.getTypeSignature()));
public ChannelSetBuilder(Type type, Optional<Integer> hashChannel, int expectedPositions, OperatorContext operatorContext, JoinCompiler joinCompiler) { List<Type> types = ImmutableList.of(type); this.hash = createGroupByHash( types, HASH_CHANNELS, hashChannel, expectedPositions, isDictionaryAggregationEnabled(operatorContext.getSession()), joinCompiler, this::updateMemoryReservation); this.nullBlockPage = new Page(type.createBlockBuilder(null, 1, UNKNOWN.getFixedSize()).appendNull().build()); this.operatorContext = requireNonNull(operatorContext, "operatorContext is null"); this.localMemoryContext = operatorContext.localUserMemoryContext(); }
public ChannelSetBuilder(Type type, Optional<Integer> hashChannel, int expectedPositions, OperatorContext operatorContext) { List<Type> types = ImmutableList.of(type); this.hash = createGroupByHash(operatorContext.getSession(), types, HASH_CHANNELS, Optional.empty(), hashChannel, expectedPositions); this.operatorContext = operatorContext; this.nullBlockPage = new Page(type.createBlockBuilder(new BlockBuilderStatus(), 1, UNKNOWN.getFixedSize()).appendNull().build()); }
this.types.put(UNKNOWN.getTypeSignature(), UNKNOWN);
private boolean satisfiesConstraints(Type type) { if (comparableRequired && !type.isComparable()) { return false; } if (orderableRequired && !type.isOrderable()) { return false; } if (requiredBaseName.isPresent() && !UNKNOWN.equals(type) && !requiredBaseName.get().equals(type.getTypeSignature().getBase())) { // TODO: the case below should be properly handled: // * `type` does not have the `requiredBaseName` but can be coerced to some type that has the `requiredBaseName`. return false; } return true; } }
@Override public Block[] getSequenceBlocks(int start, int length) { BlockBuilder blockBuilder = UNKNOWN.createBlockBuilder(null, length); for (int i = 0; i < length; i++) { blockBuilder.appendNull(); } return new Block[] {blockBuilder.build()}; }
public static Optional<TypeSignature> getCommonSuperTypeSignature(List<? extends TypeSignature> typeSignatures) { checkArgument(!typeSignatures.isEmpty(), "typeSignatures is empty"); TypeSignature superTypeSignature = UNKNOWN.getTypeSignature(); for (TypeSignature typeSignature : typeSignatures) { Optional<TypeSignature> commonSuperTypeSignature = getCommonSuperTypeSignature(superTypeSignature, typeSignature); if (!commonSuperTypeSignature.isPresent()) { return Optional.empty(); } superTypeSignature = commonSuperTypeSignature.get(); } return Optional.of(superTypeSignature); }
else if (UNKNOWN.equals(type)) { Object objectValue = resultSet.getObject(i); checkState(resultSet.wasNull(), "Expected a null value, but got %s", objectValue);
public TestUnknownType() { super(UNKNOWN, boolean.class, UNKNOWN.createBlockBuilder(null, 3) .appendNull() .appendNull() .appendNull() .build()); }
@Test public void testResolveCalculatedTypes() { // given function(varchar(x), varchar(y)):boolean Signature function = new Signature( "function", SCALAR, ImmutableList.of(), BooleanType.BOOLEAN.getTypeSignature(), ImmutableList.of(varcharX, varcharY), false); TypeSignature varchar42 = createVarcharType(42).getTypeSignature(); TypeSignature varchar44 = createVarcharType(44).getTypeSignature(); TypeSignature varchar = new TypeSignature(StandardTypes.VARCHAR, ImmutableList.of()); assertEquals( function.resolveCalculatedTypes(ImmutableList.of(varchar42, varchar44)).getArgumentTypes(), ImmutableList.of(varchar42, varchar44)); assertEquals( function.resolveCalculatedTypes(ImmutableList.of(UNKNOWN.getTypeSignature(), varchar44)).getArgumentTypes(), ImmutableList.of(varchar, varchar44)); }
else if (UNKNOWN.equals(type)) { Object objectValue = resultSet.getObject(i); checkState(resultSet.wasNull(), "Expected a null value, but got %s", objectValue);
public TestUnknownType() { super(UNKNOWN, void.class, UNKNOWN.createBlockBuilder(new BlockBuilderStatus(), 3) .appendNull() .appendNull() .appendNull() .build()); }
@Test public void testCanCoerce() { assertTrue(TypeRegistry.canCoerce(BIGINT, BIGINT)); assertTrue(TypeRegistry.canCoerce(UNKNOWN, BIGINT)); assertFalse(TypeRegistry.canCoerce(BIGINT, UNKNOWN)); assertTrue(TypeRegistry.canCoerce(BIGINT, DOUBLE)); assertTrue(TypeRegistry.canCoerce(DATE, TIMESTAMP)); assertTrue(TypeRegistry.canCoerce(DATE, TIMESTAMP_WITH_TIME_ZONE)); assertTrue(TypeRegistry.canCoerce(TIME, TIME_WITH_TIME_ZONE)); assertTrue(TypeRegistry.canCoerce(TIMESTAMP, TIMESTAMP_WITH_TIME_ZONE)); assertTrue(TypeRegistry.canCoerce(VARCHAR, REGEXP)); assertTrue(TypeRegistry.canCoerce(VARCHAR, LIKE_PATTERN)); assertTrue(TypeRegistry.canCoerce(VARCHAR, JSON_PATH)); assertFalse(TypeRegistry.canCoerce(DOUBLE, BIGINT)); assertFalse(TypeRegistry.canCoerce(TIMESTAMP, TIME_WITH_TIME_ZONE)); assertFalse(TypeRegistry.canCoerce(TIMESTAMP_WITH_TIME_ZONE, TIMESTAMP)); assertFalse(TypeRegistry.canCoerce(VARBINARY, VARCHAR)); assertTrue(TypeRegistry.canCoerce(UNKNOWN.getTypeSignature(), parseTypeSignature("array(bigint)"))); assertFalse(TypeRegistry.canCoerce(parseTypeSignature("array(bigint)"), UNKNOWN.getTypeSignature())); assertTrue(TypeRegistry.canCoerce(parseTypeSignature("array(bigint)"), parseTypeSignature("array(double)"))); assertFalse(TypeRegistry.canCoerce(parseTypeSignature("array(double)"), parseTypeSignature("array(bigint)"))); assertTrue(TypeRegistry.canCoerce(parseTypeSignature("map(bigint,double)"), parseTypeSignature("map(bigint,double)"))); assertTrue(TypeRegistry.canCoerce(parseTypeSignature("map(bigint,double)"), parseTypeSignature("map(double,double)"))); assertTrue(TypeRegistry.canCoerce(parseTypeSignature("row<bigint,double,varchar>('a','b','c')"), parseTypeSignature("row<bigint,double,varchar>('a','b','c')"))); assertTrue(TypeRegistry.canCoerce(parseTypeSignature("varchar(42)"), parseTypeSignature("varchar(42)"))); assertTrue(TypeRegistry.canCoerce(parseTypeSignature("varchar(42)"), parseTypeSignature("varchar(44)"))); assertFalse(TypeRegistry.canCoerce(parseTypeSignature("varchar(44)"), parseTypeSignature("varchar(42)"))); }
|| StringType.STRING.equals(prestoType) || prestoType instanceof com.facebook.presto.type.VarcharType) { return new LogicalSchema.LogicalFieldSchema(alias, null, DataType.CHARARRAY); } else if (UnknownType.UNKNOWN.equals(prestoType)) { return new LogicalSchema.LogicalFieldSchema(alias, null, DataType.UNKNOWN); } else if (prestoType instanceof MapType) { if (mapType.getValueType() != null && !UnknownType.UNKNOWN.equals(mapType.getValueType())) { schema = new LogicalSchema(); schema.addField(fromPrestoTypeToPigSchema(null, mapType.getValueType()));
this.types.put(UNKNOWN.getTypeSignature(), UNKNOWN);