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));
}
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));
}
Aggregations