Search in sources :

Example 1 with TestingColumnHandle

use of io.prestosql.testing.TestingMetadata.TestingColumnHandle in project hetu-core by openlookeng.

the class TestLocalProperties method testJsonSerialization.

@Test
public void testJsonSerialization() throws Exception {
    ObjectMapper mapper = new ObjectMapperProvider().get().registerModule(new SimpleModule().addDeserializer(ColumnHandle.class, new JsonDeserializer<ColumnHandle>() {

        @Override
        public ColumnHandle deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException {
            return new ObjectMapperProvider().get().readValue(jsonParser, TestingColumnHandle.class);
        }
    }));
    TestingColumnHandle columnHandle = new TestingColumnHandle("a");
    LocalProperty<ColumnHandle> property1 = new ConstantProperty<>(columnHandle);
    assertEquals(property1, mapper.readValue(mapper.writeValueAsString(property1), new TypeReference<LocalProperty<ColumnHandle>>() {
    }));
    LocalProperty<ColumnHandle> property2 = new SortingProperty<>(columnHandle, SortOrder.ASC_NULLS_FIRST);
    assertEquals(property2, mapper.readValue(mapper.writeValueAsString(property2), new TypeReference<LocalProperty<ColumnHandle>>() {
    }));
    LocalProperty<ColumnHandle> property3 = new GroupingProperty<>(ImmutableList.of(columnHandle));
    assertEquals(property3, mapper.readValue(mapper.writeValueAsString(property3), new TypeReference<LocalProperty<ColumnHandle>>() {
    }));
}
Also used : TestingColumnHandle(io.prestosql.testing.TestingMetadata.TestingColumnHandle) ColumnHandle(io.prestosql.spi.connector.ColumnHandle) ConstantProperty(io.prestosql.spi.connector.ConstantProperty) GroupingProperty(io.prestosql.spi.connector.GroupingProperty) SortingProperty(io.prestosql.spi.connector.SortingProperty) JsonDeserializer(com.fasterxml.jackson.databind.JsonDeserializer) ObjectMapperProvider(io.airlift.json.ObjectMapperProvider) TestingColumnHandle(io.prestosql.testing.TestingMetadata.TestingColumnHandle) DeserializationContext(com.fasterxml.jackson.databind.DeserializationContext) TypeReference(com.fasterxml.jackson.core.type.TypeReference) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) SimpleModule(com.fasterxml.jackson.databind.module.SimpleModule) JsonParser(com.fasterxml.jackson.core.JsonParser) Test(org.testng.annotations.Test)

Example 2 with TestingColumnHandle

use of io.prestosql.testing.TestingMetadata.TestingColumnHandle in project hetu-core by openlookeng.

the class TestTypeValidator method setUp.

@BeforeMethod
public void setUp() {
    planSymbolAllocator = new PlanSymbolAllocator();
    columnA = planSymbolAllocator.newSymbol("a", BIGINT);
    columnB = planSymbolAllocator.newSymbol("b", INTEGER);
    columnC = planSymbolAllocator.newSymbol("c", DOUBLE);
    columnD = planSymbolAllocator.newSymbol("d", DATE);
    // varchar(3), to test type only coercion
    columnE = planSymbolAllocator.newSymbol("e", VarcharType.createVarcharType(3));
    Map<Symbol, ColumnHandle> assignments = ImmutableMap.<Symbol, ColumnHandle>builder().put(columnA, new TestingColumnHandle("a")).put(columnB, new TestingColumnHandle("b")).put(columnC, new TestingColumnHandle("c")).put(columnD, new TestingColumnHandle("d")).put(columnE, new TestingColumnHandle("e")).build();
    baseTableScan = new TableScanNode(newId(), TEST_TABLE_HANDLE, ImmutableList.copyOf(assignments.keySet()), assignments, TupleDomain.all(), Optional.empty(), ReuseExchangeOperator.STRATEGY.REUSE_STRATEGY_DEFAULT, new UUID(0, 0), 0, false);
}
Also used : TestingColumnHandle(io.prestosql.testing.TestingMetadata.TestingColumnHandle) ColumnHandle(io.prestosql.spi.connector.ColumnHandle) TestingColumnHandle(io.prestosql.testing.TestingMetadata.TestingColumnHandle) TableScanNode(io.prestosql.spi.plan.TableScanNode) Symbol(io.prestosql.spi.plan.Symbol) UUID(java.util.UUID) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 3 with TestingColumnHandle

use of io.prestosql.testing.TestingMetadata.TestingColumnHandle in project hetu-core by openlookeng.

the class TestEffectivePredicateExtractor method setUp.

@BeforeMethod
public void setUp() {
    scanAssignments = ImmutableMap.<Symbol, ColumnHandle>builder().put(A, new TestingColumnHandle("a")).put(B, new TestingColumnHandle("b")).put(C, new TestingColumnHandle("c")).put(D, new TestingColumnHandle("d")).put(E, new TestingColumnHandle("e")).put(F, new TestingColumnHandle("f")).build();
    Map<Symbol, ColumnHandle> assignments = Maps.filterKeys(scanAssignments, Predicates.in(ImmutableList.of(A, B, C, D, E, F)));
    baseTableScan = TableScanNode.newInstance(newId(), makeTableHandle(TupleDomain.all()), ImmutableList.copyOf(assignments.keySet()), assignments, ReuseExchangeOperator.STRATEGY.REUSE_STRATEGY_DEFAULT, new UUID(0, 0), 0, false);
    expressionNormalizer = new ExpressionIdentityNormalizer();
}
Also used : TestingColumnHandle(io.prestosql.testing.TestingMetadata.TestingColumnHandle) ColumnHandle(io.prestosql.spi.connector.ColumnHandle) TestingColumnHandle(io.prestosql.testing.TestingMetadata.TestingColumnHandle) Symbol(io.prestosql.spi.plan.Symbol) UUID(java.util.UUID) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 4 with TestingColumnHandle

use of io.prestosql.testing.TestingMetadata.TestingColumnHandle in project hetu-core by openlookeng.

the class TestPhasedExecutionSchedule method createTableScanPlanFragment.

public static PlanFragment createTableScanPlanFragment(String name, ReuseExchangeOperator.STRATEGY strategy, UUID reuseTableScanMappingId, Integer consumerTableScanNodeCount) {
    Symbol symbol = new Symbol("column");
    PlanNode planNode = TableScanNode.newInstance(new PlanNodeId(name), TEST_TABLE_HANDLE, ImmutableList.of(symbol), ImmutableMap.of(symbol, new TestingColumnHandle("column")), strategy, reuseTableScanMappingId, consumerTableScanNodeCount, false);
    return createFragment(planNode);
}
Also used : PlanNodeId(io.prestosql.spi.plan.PlanNodeId) TestingColumnHandle(io.prestosql.testing.TestingMetadata.TestingColumnHandle) PlanNode(io.prestosql.spi.plan.PlanNode) Symbol(io.prestosql.spi.plan.Symbol)

Example 5 with TestingColumnHandle

use of io.prestosql.testing.TestingMetadata.TestingColumnHandle in project hetu-core by openlookeng.

the class TestPhasedExecutionSchedule method createBroadcastJoinPlanFragment.

private static PlanFragment createBroadcastJoinPlanFragment(String name, PlanFragment buildFragment) {
    Symbol symbol = new Symbol("column");
    PlanNode tableScan = TableScanNode.newInstance(new PlanNodeId(name), TEST_TABLE_HANDLE, ImmutableList.of(symbol), ImmutableMap.of(symbol, new TestingColumnHandle("column")), ReuseExchangeOperator.STRATEGY.REUSE_STRATEGY_DEFAULT, new UUID(0, 0), 0, false);
    RemoteSourceNode remote = new RemoteSourceNode(new PlanNodeId("build_id"), buildFragment.getId(), ImmutableList.of(), Optional.empty(), REPLICATE);
    PlanNode join = new JoinNode(new PlanNodeId(name + "_id"), INNER, tableScan, remote, ImmutableList.of(), ImmutableList.<Symbol>builder().addAll(tableScan.getOutputSymbols()).addAll(remote.getOutputSymbols()).build(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(REPLICATED), Optional.empty(), ImmutableMap.of());
    return createFragment(join);
}
Also used : PlanNodeId(io.prestosql.spi.plan.PlanNodeId) TestingColumnHandle(io.prestosql.testing.TestingMetadata.TestingColumnHandle) RemoteSourceNode(io.prestosql.sql.planner.plan.RemoteSourceNode) PlanNode(io.prestosql.spi.plan.PlanNode) Symbol(io.prestosql.spi.plan.Symbol) JoinNode(io.prestosql.spi.plan.JoinNode) UUID(java.util.UUID)

Aggregations

TestingColumnHandle (io.prestosql.testing.TestingMetadata.TestingColumnHandle)7 Symbol (io.prestosql.spi.plan.Symbol)6 UUID (java.util.UUID)5 PlanNodeId (io.prestosql.spi.plan.PlanNodeId)4 ColumnHandle (io.prestosql.spi.connector.ColumnHandle)3 JoinNode (io.prestosql.spi.plan.JoinNode)2 PlanNode (io.prestosql.spi.plan.PlanNode)2 TableScanNode (io.prestosql.spi.plan.TableScanNode)2 PartitioningScheme (io.prestosql.sql.planner.PartitioningScheme)2 PlanFragment (io.prestosql.sql.planner.PlanFragment)2 PlanFragmentId (io.prestosql.sql.planner.plan.PlanFragmentId)2 RemoteSourceNode (io.prestosql.sql.planner.plan.RemoteSourceNode)2 BeforeMethod (org.testng.annotations.BeforeMethod)2 JsonParser (com.fasterxml.jackson.core.JsonParser)1 TypeReference (com.fasterxml.jackson.core.type.TypeReference)1 DeserializationContext (com.fasterxml.jackson.databind.DeserializationContext)1 JsonDeserializer (com.fasterxml.jackson.databind.JsonDeserializer)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 SimpleModule (com.fasterxml.jackson.databind.module.SimpleModule)1 ImmutableMultimap (com.google.common.collect.ImmutableMultimap)1