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
()
| 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. |
no test coverage detected