use of io.crate.analyze.MultiSourceSelect in project crate by crate.
the class RelationNormalizerTest method testSubSelectOnJoinsWithFilter.
@Test
public void testSubSelectOnJoinsWithFilter() throws Exception {
QueriedRelation relation = normalize("select col1, col2 from ( " + " select t1.a as col1, t2.i as col2, t2.y as col3 " + " from t1, t2 where t2.y > 60) as t " + "where col1 = 'a' order by col3");
assertThat(relation, instanceOf(MultiSourceSelect.class));
assertThat(relation.querySpec(), isSQL("SELECT doc.t1.a, doc.t2.i ORDER BY doc.t2.y"));
// make sure that where clause was pushed down and didn't disappear somehow
RelationSource t1 = ((MultiSourceSelect) relation).sources().get(T3.T1);
assertThat(t1.querySpec().where().query(), isSQL("(doc.t1.a = 'a')"));
RelationSource t2 = ((MultiSourceSelect) relation).sources().get(T3.T2);
assertThat(t2.querySpec().where().query(), isSQL("(true AND (doc.t2.y > 60))"));
}
use of io.crate.analyze.MultiSourceSelect in project crate by crate.
the class RelationNormalizerTest method testSubSelectOnRightJoinWithFilterRewrittenToInner.
@Test
public void testSubSelectOnRightJoinWithFilterRewrittenToInner() throws Exception {
QueriedRelation relation = normalize("select col1, col2 from ( " + " select t1.a as col1, t2.i as col2, t2.y as col3 " + " from t1 right join t2 on t1.a = t2.b where t1.x > 60) as t " + "where col2 = 10 order by col3");
assertThat(relation, instanceOf(MultiSourceSelect.class));
MultiSourceSelect mss = (MultiSourceSelect) relation;
assertThat(mss.querySpec(), isSQL("SELECT doc.t1.a, doc.t2.i ORDER BY doc.t2.y"));
assertThat(mss.joinPairs().get(0).joinType(), is(JoinType.INNER));
assertThat(mss.joinPairs().get(0).condition(), isSQL("(doc.t1.a = doc.t2.b)"));
// make sure that where clause was pushed down and didn't disappear somehow
RelationSource t1 = mss.sources().get(T3.T1);
assertThat(t1.querySpec().where().query(), isSQL("(doc.t1.x > 60)"));
RelationSource t2 = mss.sources().get(T3.T2);
assertThat(t2.querySpec().where().query(), isSQL("(doc.t2.i = 10)"));
}
use of io.crate.analyze.MultiSourceSelect in project crate by crate.
the class MultiSourceFetchPushDownTest method pushDown.
private void pushDown(String stmt) {
SelectAnalyzedStatement a = e.analyze(stmt);
assertThat(a.relation(), instanceOf(MultiSourceSelect.class));
mss = (MultiSourceSelect) a.relation();
pd = new MultiSourceFetchPushDown(mss);
pd.process();
}
Aggregations