use of org.apache.drill.common.logical.data.Join in project drill by apache.
the class JdbcDataTest method testJoinOnSubquery.
/**
* Join on subquery; also tests that if a field of the same name exists in both inputs, both fields make it through
* the join.
*/
@Test
public void testJoinOnSubquery() throws Exception {
Join join = withModel(MODEL, "HR").sql("select * from (\n" + "select deptId, lastname, 'x' as name from emp) as e\n" + " join dept on e.deptId = dept.deptId").returnsUnordered("DEPTID=31; LASTNAME=Rafferty; NAME=x; DEPTID0=31; NAME0=Sales", "DEPTID=33; LASTNAME=Jones; NAME=x; DEPTID0=33; NAME0=Engineering", "DEPTID=33; LASTNAME=Steinberg; NAME=x; DEPTID0=33; NAME0=Engineering", "DEPTID=34; LASTNAME=Robinson; NAME=x; DEPTID0=34; NAME0=Clerical", "DEPTID=34; LASTNAME=Smith; NAME=x; DEPTID0=34; NAME0=Clerical").planContains(Join.class);
Assert.assertEquals(JoinRelType.INNER, join.getJoinType());
}
use of org.apache.drill.common.logical.data.Join in project drill by axbaretto.
the class JdbcDataTest method testFullJoin.
@Test
public void testFullJoin() throws Exception {
Join join = withModel(MODEL, "HR").sql("select * from emp full join dept on emp.deptId = dept.deptId").returnsUnordered("DEPTID=31; LASTNAME=Rafferty; DEPTID0=31; NAME=Sales", "DEPTID=33; LASTNAME=Jones; DEPTID0=33; NAME=Engineering", "DEPTID=33; LASTNAME=Steinberg; DEPTID0=33; NAME=Engineering", "DEPTID=34; LASTNAME=Robinson; DEPTID0=34; NAME=Clerical", "DEPTID=34; LASTNAME=Smith; DEPTID0=34; NAME=Clerical", "DEPTID=null; LASTNAME=John; DEPTID0=null; NAME=null", "DEPTID=null; LASTNAME=null; DEPTID0=35; NAME=Marketing").planContains(Join.class);
Assert.assertEquals(JoinRelType.FULL, join.getJoinType());
}
use of org.apache.drill.common.logical.data.Join in project drill by axbaretto.
the class JdbcDataTest method testLeftJoin.
@Test
public void testLeftJoin() throws Exception {
Join join = withModel(MODEL, "HR").sql("select * from emp left join dept on emp.deptId = dept.deptId").returnsUnordered("DEPTID=31; LASTNAME=Rafferty; DEPTID0=31; NAME=Sales", "DEPTID=33; LASTNAME=Jones; DEPTID0=33; NAME=Engineering", "DEPTID=33; LASTNAME=Steinberg; DEPTID0=33; NAME=Engineering", "DEPTID=34; LASTNAME=Robinson; DEPTID0=34; NAME=Clerical", "DEPTID=34; LASTNAME=Smith; DEPTID0=34; NAME=Clerical", "DEPTID=null; LASTNAME=John; DEPTID0=null; NAME=null").planContains(Join.class);
Assert.assertEquals(JoinRelType.LEFT, join.getJoinType());
}
use of org.apache.drill.common.logical.data.Join in project drill by apache.
the class JdbcDataTest method testLeftJoin.
@Test
public void testLeftJoin() throws Exception {
Join join = withModel(MODEL, "HR").sql("select * from emp left join dept on emp.deptId = dept.deptId").returnsUnordered("DEPTID=31; LASTNAME=Rafferty; DEPTID0=31; NAME=Sales", "DEPTID=33; LASTNAME=Jones; DEPTID0=33; NAME=Engineering", "DEPTID=33; LASTNAME=Steinberg; DEPTID0=33; NAME=Engineering", "DEPTID=34; LASTNAME=Robinson; DEPTID0=34; NAME=Clerical", "DEPTID=34; LASTNAME=Smith; DEPTID0=34; NAME=Clerical", "DEPTID=null; LASTNAME=John; DEPTID0=null; NAME=null").planContains(Join.class);
Assert.assertEquals(JoinRelType.LEFT, join.getJoinType());
}
use of org.apache.drill.common.logical.data.Join in project drill by apache.
the class JdbcDataTest method testFullJoin.
@Test
public void testFullJoin() throws Exception {
Join join = withModel(MODEL, "HR").sql("select * from emp full join dept on emp.deptId = dept.deptId").returnsUnordered("DEPTID=31; LASTNAME=Rafferty; DEPTID0=31; NAME=Sales", "DEPTID=33; LASTNAME=Jones; DEPTID0=33; NAME=Engineering", "DEPTID=33; LASTNAME=Steinberg; DEPTID0=33; NAME=Engineering", "DEPTID=34; LASTNAME=Robinson; DEPTID0=34; NAME=Clerical", "DEPTID=34; LASTNAME=Smith; DEPTID0=34; NAME=Clerical", "DEPTID=null; LASTNAME=John; DEPTID0=null; NAME=null", "DEPTID=null; LASTNAME=null; DEPTID0=35; NAME=Marketing").planContains(Join.class);
Assert.assertEquals(JoinRelType.FULL, join.getJoinType());
}