use of io.prestosql.spi.type.Type in project hetu-core by openlookeng.
the class TestPushPredicateIntoTableScan method nonDeterministicPredicate.
@Test
public void nonDeterministicPredicate() {
Type orderStatusType = createVarcharType(1);
tester().assertThat(pushPredicateIntoTableScan).on(p -> {
p.symbol("orderstatus", orderStatusType);
return p.filter(p.rowExpression("orderstatus = 'O' AND rand() = 0"), p.tableScan(ordersTableHandle, ImmutableList.of(p.symbol("orderstatus", orderStatusType)), ImmutableMap.of(p.symbol("orderstatus", orderStatusType), new TpchColumnHandle("orderstatus", orderStatusType))));
}).matches(filter("rand() = 0", constrainedTableScanWithTableLayout("orders", ImmutableMap.of("orderstatus", singleValue(orderStatusType, utf8Slice("O"))), ImmutableMap.of("orderstatus", "orderstatus"))));
}
use of io.prestosql.spi.type.Type in project hetu-core by openlookeng.
the class TestExpressionDomainTranslator method in.
private InPredicate in(Expression expression, Type expressisonType, List<?> values) {
List<Type> types = nCopies(values.size(), expressisonType);
List<Expression> expressions = literalEncoder.toExpressions(values, types);
return new InPredicate(expression, new InListExpression(expressions));
}
use of io.prestosql.spi.type.Type in project hetu-core by openlookeng.
the class TestJoinEnumerator method createContext.
private Rule.Context createContext() {
PlanNodeIdAllocator planNodeIdAllocator = new PlanNodeIdAllocator();
Map<Symbol, Type> symbols = new HashMap<>();
symbols.put(new Symbol("A1"), BIGINT);
symbols.put(new Symbol("B1"), BIGINT);
PlanSymbolAllocator planSymbolAllocator = new PlanSymbolAllocator(symbols);
CachingStatsProvider statsProvider = new CachingStatsProvider(queryRunner.getStatsCalculator(), Optional.empty(), noLookup(), queryRunner.getDefaultSession(), planSymbolAllocator.getTypes());
CachingCostProvider costProvider = new CachingCostProvider(queryRunner.getCostCalculator(), statsProvider, Optional.empty(), queryRunner.getDefaultSession(), planSymbolAllocator.getTypes());
return new Rule.Context() {
@Override
public Lookup getLookup() {
return noLookup();
}
@Override
public PlanNodeIdAllocator getIdAllocator() {
return planNodeIdAllocator;
}
@Override
public PlanSymbolAllocator getSymbolAllocator() {
return planSymbolAllocator;
}
@Override
public Session getSession() {
return queryRunner.getDefaultSession();
}
@Override
public StatsProvider getStatsProvider() {
return statsProvider;
}
@Override
public CostProvider getCostProvider() {
return costProvider;
}
@Override
public void checkTimeoutNotExhausted() {
}
@Override
public WarningCollector getWarningCollector() {
return WarningCollector.NOOP;
}
};
}
use of io.prestosql.spi.type.Type in project hetu-core by openlookeng.
the class OrcTester method rowType.
private static Type rowType(Type... fieldTypes) {
ImmutableList.Builder<TypeSignatureParameter> typeSignatureParameters = ImmutableList.builder();
for (int i = 0; i < fieldTypes.length; i++) {
String filedName = "field_" + i;
Type fieldType = fieldTypes[i];
typeSignatureParameters.add(TypeSignatureParameter.of(new NamedTypeSignature(Optional.of(new RowFieldName(filedName, false)), fieldType.getTypeSignature())));
}
return METADATA.getFunctionAndTypeManager().getParameterizedType(StandardTypes.ROW, typeSignatureParameters.build());
}
use of io.prestosql.spi.type.Type in project hetu-core by openlookeng.
the class OrcTester method decodeRecordReaderStruct.
private static List<Object> decodeRecordReaderStruct(Type type, List<?> fields) {
List<Type> fieldTypes = type.getTypeParameters();
List<Object> newFields = new ArrayList<>(fields.size());
for (int i = 0; i < fields.size(); i++) {
Type fieldType = fieldTypes.get(i);
Object field = fields.get(i);
newFields.add(decodeRecordReaderValue(fieldType, field));
}
for (int j = fields.size(); j < fieldTypes.size(); j++) {
newFields.add(null);
}
return newFields;
}
Aggregations