Search in sources :

Example 16 with Type

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"))));
}
Also used : TpchTableLayoutHandle(io.prestosql.plugin.tpch.TpchTableLayoutHandle) BaseRuleTest(io.prestosql.sql.planner.iterative.rule.test.BaseRuleTest) TpchTableHandle(io.prestosql.plugin.tpch.TpchTableHandle) TpchColumnHandle(io.prestosql.plugin.tpch.TpchColumnHandle) Test(org.testng.annotations.Test) SqlParser(io.prestosql.sql.parser.SqlParser) TableHandle(io.prestosql.spi.metadata.TableHandle) TypeAnalyzer(io.prestosql.sql.planner.TypeAnalyzer) PlanMatchPattern.values(io.prestosql.sql.planner.assertions.PlanMatchPattern.values) ImmutableList(com.google.common.collect.ImmutableList) Map(java.util.Map) Domain.singleValue(io.prestosql.spi.predicate.Domain.singleValue) TpchTransactionHandle(io.prestosql.plugin.tpch.TpchTransactionHandle) Slices.utf8Slice(io.airlift.slice.Slices.utf8Slice) Type(io.prestosql.spi.type.Type) PlanMatchPattern.filter(io.prestosql.sql.planner.assertions.PlanMatchPattern.filter) BIGINT(io.prestosql.spi.type.BigintType.BIGINT) ImmutableMap(com.google.common.collect.ImmutableMap) TupleDomain(io.prestosql.spi.predicate.TupleDomain) BeforeClass(org.testng.annotations.BeforeClass) CatalogName(io.prestosql.spi.connector.CatalogName) VarcharType.createVarcharType(io.prestosql.spi.type.VarcharType.createVarcharType) ColumnHandle(io.prestosql.spi.connector.ColumnHandle) Domain(io.prestosql.spi.predicate.Domain) Optional(java.util.Optional) PlanMatchPattern.constrainedTableScanWithTableLayout(io.prestosql.sql.planner.assertions.PlanMatchPattern.constrainedTableScanWithTableLayout) Type(io.prestosql.spi.type.Type) VarcharType.createVarcharType(io.prestosql.spi.type.VarcharType.createVarcharType) TpchColumnHandle(io.prestosql.plugin.tpch.TpchColumnHandle) BaseRuleTest(io.prestosql.sql.planner.iterative.rule.test.BaseRuleTest) Test(org.testng.annotations.Test)

Example 17 with Type

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));
}
Also used : DecimalType(io.prestosql.spi.type.DecimalType) Type(io.prestosql.spi.type.Type) DecimalType.createDecimalType(io.prestosql.spi.type.DecimalType.createDecimalType) CharType.createCharType(io.prestosql.spi.type.CharType.createCharType) VarcharType.createUnboundedVarcharType(io.prestosql.spi.type.VarcharType.createUnboundedVarcharType) InListExpression(io.prestosql.sql.tree.InListExpression) NotExpression(io.prestosql.sql.tree.NotExpression) ComparisonExpression(io.prestosql.sql.tree.ComparisonExpression) Expression(io.prestosql.sql.tree.Expression) InListExpression(io.prestosql.sql.tree.InListExpression) InPredicate(io.prestosql.sql.tree.InPredicate)

Example 18 with Type

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;
        }
    };
}
Also used : Type(io.prestosql.spi.type.Type) CachingStatsProvider(io.prestosql.cost.CachingStatsProvider) PlanNodeIdAllocator(io.prestosql.spi.plan.PlanNodeIdAllocator) HashMap(java.util.HashMap) Symbol(io.prestosql.spi.plan.Symbol) CachingCostProvider(io.prestosql.cost.CachingCostProvider) PlanSymbolAllocator(io.prestosql.sql.planner.PlanSymbolAllocator)

Example 19 with Type

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());
}
Also used : VarbinaryType(io.prestosql.spi.type.VarbinaryType) CharType(io.prestosql.spi.type.CharType) VarcharType(io.prestosql.spi.type.VarcharType) DecimalType(io.prestosql.spi.type.DecimalType) Type(io.prestosql.spi.type.Type) TypeSignatureParameter(io.prestosql.spi.type.TypeSignatureParameter) ImmutableList(com.google.common.collect.ImmutableList) RowFieldName(io.prestosql.spi.type.RowFieldName) NamedTypeSignature(io.prestosql.spi.type.NamedTypeSignature)

Example 20 with Type

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;
}
Also used : VarbinaryType(io.prestosql.spi.type.VarbinaryType) CharType(io.prestosql.spi.type.CharType) VarcharType(io.prestosql.spi.type.VarcharType) DecimalType(io.prestosql.spi.type.DecimalType) Type(io.prestosql.spi.type.Type) Lists.newArrayList(com.google.common.collect.Lists.newArrayList) ArrayList(java.util.ArrayList)

Aggregations

Type (io.prestosql.spi.type.Type)615 Test (org.testng.annotations.Test)206 ImmutableList (com.google.common.collect.ImmutableList)163 List (java.util.List)149 ArrayList (java.util.ArrayList)138 ArrayType (io.prestosql.spi.type.ArrayType)132 VarcharType (io.prestosql.spi.type.VarcharType)116 RowType (io.prestosql.spi.type.RowType)114 Page (io.prestosql.spi.Page)110 Map (java.util.Map)107 Block (io.prestosql.spi.block.Block)104 ImmutableMap (com.google.common.collect.ImmutableMap)100 PrestoException (io.prestosql.spi.PrestoException)92 VarcharType.createUnboundedVarcharType (io.prestosql.spi.type.VarcharType.createUnboundedVarcharType)90 DecimalType (io.prestosql.spi.type.DecimalType)84 Optional (java.util.Optional)81 HashMap (java.util.HashMap)80 DecimalType.createDecimalType (io.prestosql.spi.type.DecimalType.createDecimalType)68 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)67 Slice (io.airlift.slice.Slice)67