MCPcopy Create free account
hub / github.com/apache/pig / testJoinSchema2

Method testJoinSchema2

test/org/apache/pig/test/TestJoinLocal.java:67–107  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

65 }
66
67 @Test
68 public void testJoinSchema2() throws Exception {
69 // test join where one load does not have schema
70 String[] input1 = {
71 "1\t2",
72 "2\t3",
73 "3\t4"
74 };
75 String[] input2 = {
76 "1\thello",
77 "4\tbye",
78 };
79
80 String firstInput = createInputFile("a.txt", input1);
81 String secondInput = createInputFile("b.txt", input2);
82 Tuple expectedResultCharArray =
83 (Tuple)Util.getPigConstant("('1','2','1','hello','1','2','1','hello')");
84
85 Tuple expectedResult = TupleFactory.getInstance().newTuple();
86 for(Object field : expectedResultCharArray.getAll()){
87 expectedResult.append(new DataByteArray(field.toString()));
88 }
89
90 // with schema
91 String script = "a = load '"+ Util.encodeEscape(firstInput) +"' ; " +
92 //re-using alias a for new operator below, doing this intentionally
93 // because such use case has been seen
94 "a = foreach a generate $0 as i, $1 as j ;" +
95 "b = load '"+ Util.encodeEscape(secondInput) +"' as (k, l); " +
96 "c = join a by $0, b by $0;" +
97 "d = foreach c generate i,j,k,l,a::i as ai,a::j as aj,b::k as bk,b::l as bl;";
98 Util.registerMultiLineQuery(pigServer, script);
99 Iterator<Tuple> it = pigServer.openIterator("d");
100 assertTrue(it.hasNext());
101 Tuple res = it.next();
102 assertEquals(expectedResult, res);
103 assertFalse(it.hasNext());
104 deleteInputFile(firstInput);
105 deleteInputFile(secondInput);
106
107 }
108
109 @Test
110 public void testMultiOuterJoinFailure() throws Exception {

Callers

nothing calls this directly

Calls 14

createInputFileMethod · 0.95
getPigConstantMethod · 0.95
getInstanceMethod · 0.95
getAllMethod · 0.95
appendMethod · 0.95
encodeEscapeMethod · 0.95
deleteInputFileMethod · 0.95
openIteratorMethod · 0.80
newTupleMethod · 0.65
toStringMethod · 0.45
hasNextMethod · 0.45

Tested by

no test coverage detected