Search in sources :

Example 11 with PlannerBase

use of org.apache.flink.table.planner.delegation.PlannerBase in project flink by apache.

the class CatalogStatisticsTest method testGetPartitionStatsWithUnknownColumnStats.

@Test
public void testGetPartitionStatsWithUnknownColumnStats() throws Exception {
    TestPartitionableSourceFactory.createTemporaryTable(tEnv, "PartT", true);
    createPartitionStats("A", 1);
    createPartitionStats("A", 2);
    createPartitionColumnStats("A", 2);
    RelNode t1 = ((PlannerBase) ((TableEnvironmentImpl) tEnv).getPlanner()).optimize(TableTestUtil.toRelNode(tEnv.sqlQuery("select id, name from PartT where part1 = 'A'")));
    FlinkRelMetadataQuery mq = FlinkRelMetadataQuery.reuseOrCreate(t1.getCluster().getMetadataQuery());
    assertEquals(200.0, mq.getRowCount(t1), 0.0);
    // long type
    assertNull(mq.getDistinctRowCount(t1, ImmutableBitSet.of(0), null));
    assertNull(mq.getColumnNullCount(t1, 0));
    assertNull(mq.getColumnInterval(t1, 0));
    // string type
    assertNull(mq.getDistinctRowCount(t1, ImmutableBitSet.of(1), null));
    assertNull(mq.getColumnNullCount(t1, 1));
}
Also used : RelNode(org.apache.calcite.rel.RelNode) PlannerBase(org.apache.flink.table.planner.delegation.PlannerBase) FlinkRelMetadataQuery(org.apache.flink.table.planner.plan.metadata.FlinkRelMetadataQuery) Test(org.junit.Test)

Example 12 with PlannerBase

use of org.apache.flink.table.planner.delegation.PlannerBase in project flink by apache.

the class CatalogStatisticsTest method testGetPartitionStatsWithUnknownRowCount.

@Test
public void testGetPartitionStatsWithUnknownRowCount() throws Exception {
    TestPartitionableSourceFactory.createTemporaryTable(tEnv, "PartT", true);
    createPartitionStats("A", 1, TableStats.UNKNOWN.getRowCount());
    createPartitionColumnStats("A", 1);
    createPartitionStats("A", 2);
    createPartitionColumnStats("A", 2);
    RelNode t1 = ((PlannerBase) ((TableEnvironmentImpl) tEnv).getPlanner()).optimize(TableTestUtil.toRelNode(tEnv.sqlQuery("select id, name from PartT where part1 = 'A'")));
    FlinkRelMetadataQuery mq = FlinkRelMetadataQuery.reuseOrCreate(t1.getCluster().getMetadataQuery());
    assertEquals(100_000_000, mq.getRowCount(t1), 0.0);
    assertEquals(Arrays.asList(8.0, 43.5), mq.getAverageColumnSizes(t1));
    // long type
    assertEquals(46.0, mq.getDistinctRowCount(t1, ImmutableBitSet.of(0), null), 0.0);
    assertEquals(154.0, mq.getColumnNullCount(t1, 0), 0.0);
    assertEquals(ValueInterval$.MODULE$.apply(BigDecimal.valueOf(-123L), BigDecimal.valueOf(763322L), true, true), mq.getColumnInterval(t1, 0));
    // string type
    assertEquals(40.0, mq.getDistinctRowCount(t1, ImmutableBitSet.of(1), null), 0.0);
    assertEquals(0.0, mq.getColumnNullCount(t1, 1), 0.0);
    assertNull(mq.getColumnInterval(t1, 1));
}
Also used : RelNode(org.apache.calcite.rel.RelNode) PlannerBase(org.apache.flink.table.planner.delegation.PlannerBase) FlinkRelMetadataQuery(org.apache.flink.table.planner.plan.metadata.FlinkRelMetadataQuery) Test(org.junit.Test)

Aggregations

PlannerBase (org.apache.flink.table.planner.delegation.PlannerBase)12 RelNode (org.apache.calcite.rel.RelNode)7 Test (org.junit.Test)5 List (java.util.List)4 Transformation (org.apache.flink.api.dag.Transformation)4 RowData (org.apache.flink.table.data.RowData)4 ExecNode (org.apache.flink.table.planner.plan.nodes.exec.ExecNode)4 ExecNodeConfig (org.apache.flink.table.planner.plan.nodes.exec.ExecNodeConfig)4 ExecNodeContext (org.apache.flink.table.planner.plan.nodes.exec.ExecNodeContext)4 Collections (java.util.Collections)3 Collectors (java.util.stream.Collectors)3 FlinkRelMetadataQuery (org.apache.flink.table.planner.plan.metadata.FlinkRelMetadataQuery)3 ExecEdge (org.apache.flink.table.planner.plan.nodes.exec.ExecEdge)3 InputProperty (org.apache.flink.table.planner.plan.nodes.exec.InputProperty)3 LogicalType (org.apache.flink.table.types.logical.LogicalType)3 RowType (org.apache.flink.table.types.logical.RowType)3 ArrayList (java.util.ArrayList)2 Arrays (java.util.Arrays)2 FlinkVersion (org.apache.flink.FlinkVersion)2 JsonCreator (org.apache.flink.shaded.jackson2.com.fasterxml.jackson.annotation.JsonCreator)2