Search in sources :

Example 1 with Join

use of org.apache.drill.common.logical.data.Join in project drill by axbaretto.

the class JdbcDataTest method testJoin.

@Test
public void testJoin() throws Exception {
    Join join = withModel(MODEL, "HR").sql("select * from emp 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").planContains(Join.class);
    Assert.assertEquals(JoinRelType.INNER, join.getJoinType());
}
Also used : Join(org.apache.drill.common.logical.data.Join) Test(org.junit.Test) JdbcTest(org.apache.drill.categories.JdbcTest)

Example 2 with Join

use of org.apache.drill.common.logical.data.Join in project drill by axbaretto.

the class JdbcDataTest method testRightJoin.

/**
 * Right join is tricky because Drill's "join" operator only supports "left", so we have to flip inputs.
 */
@Test
@Ignore
public void testRightJoin() throws Exception {
    Join join = withModel(MODEL, "HR").sql("select * from emp right join dept on emp.deptId = dept.deptId").returnsUnordered("xx").planContains(Join.class);
    Assert.assertEquals(JoinRelType.LEFT, join.getJoinType());
}
Also used : Join(org.apache.drill.common.logical.data.Join) Ignore(org.junit.Ignore) Test(org.junit.Test) JdbcTest(org.apache.drill.categories.JdbcTest)

Example 3 with Join

use of org.apache.drill.common.logical.data.Join in project drill by axbaretto.

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());
}
Also used : Join(org.apache.drill.common.logical.data.Join) Test(org.junit.Test) JdbcTest(org.apache.drill.categories.JdbcTest)

Example 4 with Join

use of org.apache.drill.common.logical.data.Join in project drill by apache.

the class JdbcDataTest method testJoin.

@Test
public void testJoin() throws Exception {
    Join join = withModel(MODEL, "HR").sql("select * from emp 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").planContains(Join.class);
    Assert.assertEquals(JoinRelType.INNER, join.getJoinType());
}
Also used : Join(org.apache.drill.common.logical.data.Join) Test(org.junit.Test) JdbcTest(org.apache.drill.categories.JdbcTest)

Example 5 with Join

use of org.apache.drill.common.logical.data.Join in project drill by apache.

the class JdbcDataTest method testRightJoin.

/**
 * Right join is tricky because Drill's "join" operator only supports "left", so we have to flip inputs.
 */
@Test
@Ignore
public void testRightJoin() throws Exception {
    Join join = withModel(MODEL, "HR").sql("select * from emp right join dept on emp.deptId = dept.deptId").returnsUnordered("xx").planContains(Join.class);
    Assert.assertEquals(JoinRelType.LEFT, join.getJoinType());
}
Also used : Join(org.apache.drill.common.logical.data.Join) Ignore(org.junit.Ignore) Test(org.junit.Test) JdbcTest(org.apache.drill.categories.JdbcTest)

Aggregations

JdbcTest (org.apache.drill.categories.JdbcTest)10 Join (org.apache.drill.common.logical.data.Join)10 Test (org.junit.Test)10 Ignore (org.junit.Ignore)2