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

Method testWithDereferenceOperator

test/org/apache/pig/test/TestCase.java:245–280  ·  view source on GitHub ↗

Verify that CASE statement works when expressions contain dereference operators. @throws Exception

()

Source from the content-addressed store, hash-verified

243 * @throws Exception
244 */
245 @Test
246 public void testWithDereferenceOperator() throws Exception {
247 PigServer pigServer = new PigServer(Util.getLocalTestMode());
248 Data data = resetData(pigServer);
249
250 data.set("foo",
251 tuple("a","x",1),
252 tuple("a","y",1),
253 tuple("b","x",2),
254 tuple("b","y",2),
255 tuple("c","x",3),
256 tuple("c","y",3)
257 );
258
259 pigServer.registerQuery("A = LOAD 'foo' USING mock.Storage() AS (c1:chararray, c2:chararray, i:int);");
260 pigServer.registerQuery("B = GROUP A BY (c1, i);");
261 pigServer.registerQuery("C = FOREACH B GENERATE group.i, (" +
262 " CASE group.i % 3" +
263 " WHEN 0 THEN '3n'" +
264 " WHEN 1 THEN '3n+1'" +
265 " ELSE '3n+2'" +
266 " END" +
267 "), A.(c1, c2);");
268 pigServer.registerQuery("STORE C INTO 'bar' USING mock.Storage();");
269
270 List<Tuple> out = data.get("bar");
271
272 String[] expected = new String[] {
273 "(1,3n+1,{(a,x),(a,y)})",
274 "(2,3n+2,{(b,x),(b,y)})",
275 "(3,3n,{(c,x),(c,y)})"
276 };
277 Schema s = pigServer.dumpSchema("C");
278 Util.checkQueryOutputs(out.iterator(), expected, org.apache.pig.newplan.logical.Util.translateSchema(s),
279 Util.isSparkExecType(Util.getLocalTestMode()));
280 }
281
282 /**
283 * Verify that FrontendException is thrown when case expression is missing,

Callers

nothing calls this directly

Calls 11

getLocalTestModeMethod · 0.95
setMethod · 0.95
registerQueryMethod · 0.95
getMethod · 0.95
dumpSchemaMethod · 0.95
checkQueryOutputsMethod · 0.95
isSparkExecTypeMethod · 0.95
resetDataMethod · 0.80
translateSchemaMethod · 0.80
iteratorMethod · 0.65
tupleMethod · 0.45

Tested by

no test coverage detected