Write the schema for an alias to System.out. @param alias Alias whose schema will be written out @return Schema of alias dumped @throws IOException
(String alias)
| 883 | * @throws IOException |
| 884 | */ |
| 885 | public Schema dumpSchema(String alias) throws IOException { |
| 886 | try { |
| 887 | pigContext.inDumpSchema = true; |
| 888 | if ("@".equals(alias)) { |
| 889 | alias = getLastRel(); |
| 890 | } |
| 891 | LogicalRelationalOperator op = getOperatorForAlias( alias ); |
| 892 | LogicalSchema schema = op.getSchema(); |
| 893 | |
| 894 | boolean pretty = "true".equals(pigContext.getProperties() |
| 895 | .getProperty(PRETTY_PRINT_SCHEMA_PROPERTY)); |
| 896 | |
| 897 | if (schema != null) { |
| 898 | Schema s = org.apache.pig.newplan.logical.Util.translateSchema(schema); |
| 899 | System.out.println(alias + ": " + (pretty ? s.prettyPrint() : s.toString())); |
| 900 | return s; |
| 901 | } else { |
| 902 | System.out.println("Schema for " + alias + " unknown."); |
| 903 | return null; |
| 904 | } |
| 905 | } catch (FrontendException fee) { |
| 906 | int errCode = 1001; |
| 907 | String msg = "Unable to describe schema for alias " + alias; |
| 908 | throw new FrontendException (msg, errCode, PigException.INPUT, false, null, fee); |
| 909 | } finally { |
| 910 | pigContext.inDumpSchema = false; |
| 911 | } |
| 912 | } |
| 913 | |
| 914 | /** |
| 915 | * Write the schema for a nestedAlias to System.out. Denoted by |