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

Method getAliasToSchemaMap

test/org/apache/pig/pigunit/PigTest.java:276–301  ·  view source on GitHub ↗

Returns a Map that has alias to it's schema. @return A map that has alias name as a key and the alias's schema as a value @throws FrontendException If there was an error dumping the schema

()

Source from the content-addressed store, hash-verified

274 * @throws FrontendException If there was an error dumping the schema
275 */
276 public Map<String, String> getAliasToSchemaMap() throws FrontendException, IOException, ParseException {
277 HashMap<String, String> aliasSchemas = new HashMap<String, String>();
278 registerScript();
279 PigServer server = getPigServer();
280 Set<String> aliasKeySet = server.getAliasKeySet();
281 for (String alias: aliasKeySet) {
282 try {
283 StringBuilder tsb = new StringBuilder();
284 Schema.stringifySchema(tsb, server.dumpSchema(alias), DataType.TUPLE, Integer.MIN_VALUE);
285 aliasSchemas.put(alias, tsb.toString());
286 } catch (FrontendException e) {
287 /**
288 * If PigServer fails to describe a schema for an alias a FrontendException is thrown.
289 * PigServer.getAliasKeySet() returns aliases that cannot have their schema described.
290 * We want to skip over these particular aliases.
291 */
292 if (e.getErrorCode() == 1001) {
293 //Let's print a warning
294 System.out.println(e.getMessage());
295 } else {
296 throw e;
297 }
298 }
299 }
300 return aliasSchemas;
301 }
302
303 /**
304 * Creates a temp file and populates it with the specified mock data.

Callers 1

testAliasSchemaMapMethod · 0.80

Calls 9

registerScriptMethod · 0.95
getPigServerMethod · 0.95
getAliasKeySetMethod · 0.95
stringifySchemaMethod · 0.95
dumpSchemaMethod · 0.95
putMethod · 0.45
toStringMethod · 0.45
getErrorCodeMethod · 0.45
getMessageMethod · 0.45

Tested by

no test coverage detected