@Override public void checkSchema(ResourceSchema resourceSchema) throws IOException { /* Schema provided by user and the schema computed by Pig * at the time of calling store must match. */ Schema runtimeSchema = Schema.getPigSchema(resourceSchema); if (pigSchema != null) { if (!Schema.equals(runtimeSchema, pigSchema, false, true)) { throw new FrontendException("Schema provided in store statement doesn't match with the Schema" + "returned by Pig run-time. Schema provided in HCatStorer: " + pigSchema.toString() + " Schema received from Pig runtime: " + runtimeSchema.toString(), PigHCatUtil.PIG_EXCEPTION_CODE); } } else { pigSchema = runtimeSchema; } UDFContext.getUDFContext().getUDFProperties(this.getClass(), new String[]{sign}).setProperty(PIG_SCHEMA, ObjectSerializer.serialize(pigSchema)); }
@Test public void testSchemaSerializationPlusBase64() throws Exception { Schema schemaFromString = Utils.getSchemaFromString("name:bytearray,links:{(missing:chararray)}"); Schema schemaSaved = IOUtils.deserializeFromBase64(IOUtils.serializeToBase64(schemaFromString)); assertEquals(schemaFromString.toString(), schemaSaved.toString()); }
@Test(expected = Exception.class) public void testLoadingOfBagSchema() throws Exception { assertNotNull(Utils.getSchemaFromString(Utils.getSchemaFromString("name:bytearray,links:{(missing:chararray)}").toString())); }
public String toString() { return s.toString(); } }
/** * @param pigSchema the pig schema to turn into a string representation * @return the sctring representation of the schema */ static String pigSchemaToString(Schema pigSchema) { final String pigSchemaString = pigSchema.toString(); return pigSchemaString.substring(1, pigSchemaString.length() - 1); }
/** * @param pigSchema * the pig schema to turn into a string representation * @return the sctring representation of the schema */ static String pigSchemaToString(Schema pigSchema) { final String pigSchemaString = pigSchema.toString(); return pigSchemaString.substring(1, pigSchemaString.length() - 1); }
private void saveSchemaToUDFContext() { if (signature != null && inputSchema != null) { String schemaString = inputSchema.toString(); getProperties(signature).put("inputSchema", schemaString.substring(1, schemaString.length() - 1)); } }
public String getSchemaString() { return getSchema().toString(); }
@Override public String toString() { StringBuilder sb = new StringBuilder(); if (alias != null) { sb.append(alias); sb.append(": "); } sb.append(DataType.findTypeName(type)); if (schema != null) { sb.append("("); sb.append(schema.toString()); sb.append(")"); } // if (canonicalName != null) { // sb.append(" cn: "); // sb.append(canonicalName); // } return sb.toString(); }
public static void main(String[] args) throws Exception { if (args.length > 0) { Class<? extends TBase<?, ?>> tClass = ThriftUtils.getTypeRef(args[0]).getRawClass(); System.out.println(args[0] + " : " + toSchema(tClass).toString()); System.out.println(toPigScript(tClass, ThriftPigLoader.class)); } } }
@Override public void checkSchema(ResourceSchema resourceSchema) throws IOException { /* Schema provided by user and the schema computed by Pig * at the time of calling store must match. */ Schema runtimeSchema = Schema.getPigSchema(resourceSchema); if (pigSchema != null) { if (!Schema.equals(runtimeSchema, pigSchema, false, true)) { throw new FrontendException("Schema provided in store statement doesn't match with the Schema" + "returned by Pig run-time. Schema provided in HCatStorer: " + pigSchema.toString() + " Schema received from Pig runtime: " + runtimeSchema.toString(), PigHCatUtil.PIG_EXCEPTION_CODE); } } else { pigSchema = runtimeSchema; } UDFContext.getUDFContext().getUDFProperties(this.getClass(), new String[]{sign}).setProperty(PIG_SCHEMA, ObjectSerializer.serialize(pigSchema)); }
@Override public void checkSchema(ResourceSchema resourceSchema) throws IOException { /* Schema provided by user and the schema computed by Pig * at the time of calling store must match. */ Schema runtimeSchema = Schema.getPigSchema(resourceSchema); if (pigSchema != null) { if (!Schema.equals(runtimeSchema, pigSchema, false, true)) { throw new FrontendException("Schema provided in store statement doesn't match with the Schema" + "returned by Pig run-time. Schema provided in HCatStorer: " + pigSchema.toString() + " Schema received from Pig runtime: " + runtimeSchema.toString(), PigHCatUtil.PIG_EXCEPTION_CODE); } } else { pigSchema = runtimeSchema; } UDFContext.getUDFContext().getUDFProperties(this.getClass(), new String[]{sign}).setProperty(PIG_SCHEMA, ObjectSerializer.serialize(pigSchema)); }
@Override public Schema outputSchema(Schema input) { if (null != this.schemaFunction) { try { Tuple t = TupleFactory.getInstance().newTuple(1); // Strip enclosing '{}' from schema t.set(0, input.toString().replaceAll("^\\{", "").replaceAll("\\}$", "")); return Utils.getSchemaFromString((String) this.schemaFunction.exec(t)); } catch (ParserException pe) { throw new RuntimeException(pe); } catch (IOException ioe) { throw new RuntimeException(ioe); } } else { return this.schema; } }
/** * The toString method just leverages Schema's printing. * * @param context the context the method is being executed in * @return a String representation of the encapsulated Schema object */ @JRubyMethod(name = {"to_s", "inspect"}) public RubyString toString(ThreadContext context) { return RubyString.newString(context.getRuntime(), internalSchema.toString()); }
System.out.println(alias + ": " + (pretty ? s.prettyPrint() : s.toString())); return s; } else {
if (nestedSc!=null) { Schema s = org.apache.pig.newplan.logical.Util.translateSchema(nestedSc); System.out.println(alias+ "::" + nestedAlias + ": " + s.toString()); return s;
throw new RuntimeException("Expected input format of (bag, 'field') pairs. " +"Did not receive a bag at index: "+i+", alias: "+bagName+". " +"Instead received type: "+DataType.findTypeName(outerField.type)+" in schema:"+input.toString()); FieldSchema tupleField = outerField.schema.getField(0); tupleName = tupleField.alias; log.debug("output schema: "+outputSchema.toString()); } catch (FrontendException e) { e.printStackTrace();