use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.plan.RelOptTable in project calcite by apache.
the class RelMetadataTest method testAverageRowSize.
/**
* Unit test for
* {@link org.apache.calcite.rel.metadata.RelMetadataQuery#getAverageColumnSizes(org.apache.calcite.rel.RelNode)},
* {@link org.apache.calcite.rel.metadata.RelMetadataQuery#getAverageRowSize(org.apache.calcite.rel.RelNode)}.
*/
@Test
public void testAverageRowSize() {
final Project rel = (Project) convertSql("select * from emp, dept");
final Join join = (Join) rel.getInput();
final RelOptTable empTable = join.getInput(0).getTable();
final RelOptTable deptTable = join.getInput(1).getTable();
Frameworks.withPlanner(new Frameworks.PlannerAction<Void>() {
public Void apply(RelOptCluster cluster, RelOptSchema relOptSchema, SchemaPlus rootSchema) {
checkAverageRowSize(cluster, empTable, deptTable);
return null;
}
});
}
use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.plan.RelOptTable in project calcite by apache.
the class RelMetadataTest method checkTwoColumnOrigin.
// WARNING: this requires the two table names to be different
private void checkTwoColumnOrigin(String sql, String expectedTableName1, String expectedColumnName1, String expectedTableName2, String expectedColumnName2, boolean expectedDerived) {
Set<RelColumnOrigin> result = checkColumnOrigin(sql);
assertTrue(result != null);
assertEquals(2, result.size());
for (RelColumnOrigin rco : result) {
RelOptTable actualTable = rco.getOriginTable();
List<String> actualTableName = actualTable.getQualifiedName();
String actualUnqualifiedName = Iterables.getLast(actualTableName);
if (actualUnqualifiedName.equals(expectedTableName1)) {
checkColumnOrigin(rco, expectedTableName1, expectedColumnName1, expectedDerived);
} else {
checkColumnOrigin(rco, expectedTableName2, expectedColumnName2, expectedDerived);
}
}
}
use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.plan.RelOptTable in project calcite by apache.
the class RelMetadataTest method testPredicates.
/**
* Unit test for
* {@link org.apache.calcite.rel.metadata.RelMdPredicates#getPredicates(Join, RelMetadataQuery)}.
*/
@Test
public void testPredicates() {
final Project rel = (Project) convertSql("select * from emp, dept");
final Join join = (Join) rel.getInput();
final RelOptTable empTable = join.getInput(0).getTable();
final RelOptTable deptTable = join.getInput(1).getTable();
Frameworks.withPlanner(new Frameworks.PlannerAction<Void>() {
public Void apply(RelOptCluster cluster, RelOptSchema relOptSchema, SchemaPlus rootSchema) {
checkPredicates(cluster, empTable, deptTable);
return null;
}
});
}
use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.plan.RelOptTable in project calcite by apache.
the class LoptOptimizeJoinRule method isRemovableSelfJoin.
/**
* Determines whether a join is a removable self-join. It is if it's an
* inner join between identical, simple factors and the equality portion of
* the join condition consists of the same set of unique keys.
*
* @param joinRel the join
*
* @return true if the join is removable
*/
public static boolean isRemovableSelfJoin(Join joinRel) {
final RelNode left = joinRel.getLeft();
final RelNode right = joinRel.getRight();
if (joinRel.getJoinType() != JoinRelType.INNER) {
return false;
}
// Make sure the join is between the same simple factor
final RelMetadataQuery mq = joinRel.getCluster().getMetadataQuery();
final RelOptTable leftTable = mq.getTableOrigin(left);
if (leftTable == null) {
return false;
}
final RelOptTable rightTable = mq.getTableOrigin(right);
if (rightTable == null) {
return false;
}
if (!leftTable.getQualifiedName().equals(rightTable.getQualifiedName())) {
return false;
}
// Determine if the join keys are identical and unique
return areSelfJoinKeysUnique(mq, left, right, joinRel.getCondition());
}
use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.plan.RelOptTable in project druid by druid-io.
the class DruidRelsTest method mockDruidRel.
public static <T extends DruidRel<?>> T mockDruidRel(final Class<T> clazz, final Consumer<T> additionalExpectationsFunction, final PartialDruidQuery.Stage stage, @Nullable DruidTable druidTable, @Nullable Project selectProject, @Nullable Filter whereFilter) {
// DruidQueryRels rely on a ton of Calcite stuff like RelOptCluster, RelOptTable, etc, which is quite verbose to
// create real instances of. So, tragically, we'll use EasyMock.
final PartialDruidQuery mockPartialQuery = EasyMock.mock(PartialDruidQuery.class);
EasyMock.expect(mockPartialQuery.stage()).andReturn(stage).anyTimes();
EasyMock.expect(mockPartialQuery.getSelectProject()).andReturn(selectProject).anyTimes();
EasyMock.expect(mockPartialQuery.getWhereFilter()).andReturn(whereFilter).anyTimes();
final RelOptTable mockRelOptTable = EasyMock.mock(RelOptTable.class);
EasyMock.expect(mockRelOptTable.unwrap(DruidTable.class)).andReturn(druidTable).anyTimes();
final T mockRel = EasyMock.mock(clazz);
EasyMock.expect(mockRel.getPartialDruidQuery()).andReturn(mockPartialQuery).anyTimes();
EasyMock.expect(mockRel.getTable()).andReturn(mockRelOptTable).anyTimes();
if (clazz == DruidQueryRel.class) {
EasyMock.expect(((DruidQueryRel) mockRel).getDruidTable()).andReturn(druidTable).anyTimes();
}
additionalExpectationsFunction.accept(mockRel);
EasyMock.replay(mockRel, mockPartialQuery, mockRelOptTable);
return mockRel;
}
Aggregations