}
@Test
public void testRetrieveDataFromMap() throws Exception {
pigServerLocal = new PigServer(ExecType.LOCAL);
Data data = resetData(pigServerLocal);
Map<String, String> mapv1 = new HashMap<String, String>();
mapv1.put("key1", "v11");
mapv1.put("key2", "v12");
Map<String, String> mapv2 = new HashMap<String, String>();
mapv2.put("key1", "v21");
mapv2.put("key2", "v22");
data.set("testMap", "maps:map[chararray]", tuple(mapv1), tuple(mapv2));
String schemaDescription = new String(
"{" +
"\"type\": \"record\"," +
"\"name\": \"record\"," +
"\"fields\" : [" +
"{\"name\" : \"maps\", \"type\" :{\"type\" : \"map\", \"values\" : \"string\"}}" +
"]" +
"}");
pigServerLocal.registerQuery("A = LOAD 'testMap' USING mock.Storage();");
pigServerLocal.registerQuery("STORE A INTO '" + createOutputName() + "' USING AvroStorage('"+ schemaDescription +"');");
pigServerLocal.registerQuery("B = LOAD '" + createOutputName() + "' USING AvroStorage();");
pigServerLocal.registerQuery("C = FOREACH B generate maps#'key1';");
pigServerLocal.registerQuery("STORE C INTO 'out' USING mock.Storage();");
List<Tuple> out = data.get("out");
assertEquals(tuple("v11"), out.get(0));
assertEquals(tuple("v21"), out.get(1));
}