Java Code Examples for org.apache.pig.newplan.logical.relational.LogicalSchema#LogicalFieldSchema
The following examples show how to use
org.apache.pig.newplan.logical.relational.LogicalSchema#LogicalFieldSchema .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FilterAboveForeach.java From spork with Apache License 2.0 | 6 votes |
/** * checks if a relational operator contains all of the specified uids * @param op LogicalRelational operator that should contain the uid * @param uids Uids to check for * @return true if given LogicalRelationalOperator has all the given uids */ private boolean hasAll(LogicalRelationalOperator op, Pair<List<Long>, List<Byte>> uidWithTypes) throws FrontendException { LogicalSchema schema = op.getSchema(); if (schema==null) return false; List<Long> uids = uidWithTypes.first; List<Byte> types = uidWithTypes.second; for (int i=0;i<uids.size();i++) { boolean found = false; for (LogicalSchema.LogicalFieldSchema fs : schema.getFields()) { if (fs.uid==uids.get(i) && fs.type==types.get(i)) found = true; } if (!found) return false; } return true; }
Example 2
Source File: Util.java From spork with Apache License 2.0 | 6 votes |
/** * This function translates the new LogicalSchema into old Schema format required * by PhysicalOperators * @param schema LogicalSchema to be converted to Schema * @return Schema that is converted from LogicalSchema * @throws FrontendException */ public static Schema translateSchema(LogicalSchema schema) { if (schema == null) { return null; } Schema s2 = new Schema(); List<LogicalSchema.LogicalFieldSchema> ll = schema.getFields(); for (LogicalSchema.LogicalFieldSchema f: ll) { Schema.FieldSchema f2 = null; try { f2 = new Schema.FieldSchema(f.alias, translateSchema(f.schema), f.type); f2.canonicalName = ((Long)f.uid).toString(); s2.add(f2); } catch (FrontendException e) { } } return s2; }
Example 3
Source File: NotEqualExpression.java From spork with Apache License 2.0 | 5 votes |
@Override public LogicalSchema.LogicalFieldSchema getFieldSchema() throws FrontendException { if (fieldSchema!=null) return fieldSchema; fieldSchema = new LogicalSchema.LogicalFieldSchema(null, null, DataType.BOOLEAN); uidOnlyFieldSchema = fieldSchema.mergeUid(uidOnlyFieldSchema); return fieldSchema; }
Example 4
Source File: DivideExpression.java From spork with Apache License 2.0 | 5 votes |
@Override public LogicalSchema.LogicalFieldSchema getFieldSchema() throws FrontendException { if (fieldSchema!=null) return fieldSchema; fieldSchema = new LogicalSchema.LogicalFieldSchema(null, null, getLhs().getType()); uidOnlyFieldSchema = fieldSchema.mergeUid(uidOnlyFieldSchema); return fieldSchema; }
Example 5
Source File: MultiplyExpression.java From spork with Apache License 2.0 | 5 votes |
@Override public LogicalSchema.LogicalFieldSchema getFieldSchema() throws FrontendException { if (fieldSchema!=null) return fieldSchema; fieldSchema = new LogicalSchema.LogicalFieldSchema(null, null, getLhs().getType()); uidOnlyFieldSchema = fieldSchema.mergeUid(uidOnlyFieldSchema); return fieldSchema; }
Example 6
Source File: BinCondExpression.java From spork with Apache License 2.0 | 5 votes |
@Override public LogicalSchema.LogicalFieldSchema getFieldSchema() throws FrontendException { if (fieldSchema!=null) return fieldSchema; //TypeCheckingExpVisitor will ensure that lhs and rhs have same schema LogicalFieldSchema argFs = getLhs().getFieldSchema(); fieldSchema = argFs.deepCopy(); fieldSchema.resetUid(); uidOnlyFieldSchema = fieldSchema.mergeUid(uidOnlyFieldSchema); return fieldSchema; }
Example 7
Source File: GreaterThanEqualExpression.java From spork with Apache License 2.0 | 5 votes |
@Override public LogicalSchema.LogicalFieldSchema getFieldSchema() throws FrontendException { if (fieldSchema!=null) return fieldSchema; fieldSchema = new LogicalSchema.LogicalFieldSchema(null, null, DataType.BOOLEAN); uidOnlyFieldSchema = fieldSchema.mergeUid(uidOnlyFieldSchema); return fieldSchema; }
Example 8
Source File: TypeCastInserter.java From spork with Apache License 2.0 | 5 votes |
private boolean atLeastOneCastNeeded(LogicalSchema determinedSchema, LogicalSchema s) { for (int i = 0; i < s.size(); i++) { LogicalSchema.LogicalFieldSchema fs = s.getField(i); if (fs.type != DataType.BYTEARRAY && (determinedSchema == null || (!fs.isEqual(determinedSchema.getField(i))))) { // we have to cast this field from the default BYTEARRAY type to // whatever the user specified in the 'AS' clause of the LOAD // statement (the fs.type). return true; } } return false; }
Example 9
Source File: OrExpression.java From spork with Apache License 2.0 | 5 votes |
@Override public LogicalSchema.LogicalFieldSchema getFieldSchema() throws FrontendException { if (fieldSchema!=null) return fieldSchema; fieldSchema = new LogicalSchema.LogicalFieldSchema(null, null, DataType.BOOLEAN); uidOnlyFieldSchema = fieldSchema.mergeUid(uidOnlyFieldSchema); return fieldSchema; }
Example 10
Source File: Util.java From spork with Apache License 2.0 | 5 votes |
public static LogicalSchema.LogicalFieldSchema translateFieldSchema(Schema.FieldSchema fs) { LogicalSchema newSchema = null; if (fs.schema!=null) { newSchema = translateSchema(fs.schema); } LogicalSchema.LogicalFieldSchema newFs = new LogicalSchema.LogicalFieldSchema(fs.alias, newSchema, fs.type); return newFs; }
Example 11
Source File: LessThanExpression.java From spork with Apache License 2.0 | 5 votes |
@Override public LogicalSchema.LogicalFieldSchema getFieldSchema() throws FrontendException { if (fieldSchema!=null) return fieldSchema; fieldSchema = new LogicalSchema.LogicalFieldSchema(null, null, DataType.BOOLEAN); uidOnlyFieldSchema = fieldSchema.mergeUid(uidOnlyFieldSchema); return fieldSchema; }
Example 12
Source File: ModExpression.java From spork with Apache License 2.0 | 5 votes |
@Override public LogicalSchema.LogicalFieldSchema getFieldSchema() throws FrontendException { if (fieldSchema!=null) return fieldSchema; fieldSchema = new LogicalSchema.LogicalFieldSchema(null, null, getLhs().getType()); uidOnlyFieldSchema = fieldSchema.mergeUid(uidOnlyFieldSchema); return fieldSchema; }
Example 13
Source File: ScalarExpression.java From spork with Apache License 2.0 | 5 votes |
@Override public LogicalSchema.LogicalFieldSchema getFieldSchema() throws FrontendException { if (fieldSchema!=null) return fieldSchema; // TODO: apparently there is a problem with some test cases where implicitReferencedOperator can be null, // even for a scalar UDF. Need more investigation. For now, simulate the old code to make these // test case pass. if( implicitReferencedOperator != null ) { List<Operator> args = plan.getSuccessors(this); if(args != null && args.size() > 0 ){ int pos = (Integer)((ConstantExpression)args.get(0)).getValue(); LogicalRelationalOperator inp = (LogicalRelationalOperator)implicitReferencedOperator; if( inp.getSchema() != null){ LogicalFieldSchema inpFs = inp.getSchema().getField(pos); fieldSchema = new LogicalFieldSchema(inpFs); // fieldSchema.alias = "ReadScalars_" + fieldSchema.alias; }else{ fieldSchema = new LogicalFieldSchema(null, null, DataType.BYTEARRAY); } return fieldSchema; }else{ //predecessors haven't been setup, return null return null; } } else { return super.getFieldSchema(); } }
Example 14
Source File: AddExpression.java From spork with Apache License 2.0 | 5 votes |
@Override public LogicalSchema.LogicalFieldSchema getFieldSchema() throws FrontendException { if (fieldSchema!=null) return fieldSchema; fieldSchema = new LogicalSchema.LogicalFieldSchema(null, null, getLhs().getType()); uidOnlyFieldSchema = fieldSchema.mergeUid(uidOnlyFieldSchema); return fieldSchema; }
Example 15
Source File: PigTypeConverter.java From metacat with Apache License 2.0 | 5 votes |
private Type toCanonicalArrayType(final LogicalSchema.LogicalFieldSchema field) { final LogicalSchema.LogicalFieldSchema subField = field.schema.getField(0); final Type elementType; if (subField.type == DataType.TUPLE && !TypeUtils.isNullOrEmpty(subField.schema.getFields()) && NAME_ARRAY_ELEMENT.equals(subField.schema.getFields().get(0).alias)) { elementType = toCanonicalType(subField.schema.getFields().get(0)); } else { elementType = toCanonicalType(subField); } return new ArrayType(elementType); }
Example 16
Source File: PigTypeConverter.java From metacat with Apache License 2.0 | 5 votes |
private Type toCanonicalRowType(final LogicalSchema.LogicalFieldSchema field) { final List<Type> fieldTypes = Lists.newArrayList(); final List<String> fieldNames = Lists.newArrayList(); for (LogicalSchema.LogicalFieldSchema logicalFieldSchema : field.schema.getFields()) { fieldTypes.add(toCanonicalType(logicalFieldSchema)); fieldNames.add(logicalFieldSchema.alias); } return RowType.createRowType(fieldTypes, fieldNames); }
Example 17
Source File: NotExpression.java From spork with Apache License 2.0 | 5 votes |
@Override public LogicalSchema.LogicalFieldSchema getFieldSchema() throws FrontendException { if (fieldSchema!=null) return fieldSchema; fieldSchema = new LogicalSchema.LogicalFieldSchema(null, null, DataType.BOOLEAN); uidOnlyFieldSchema = fieldSchema.mergeUid(uidOnlyFieldSchema); return fieldSchema; }
Example 18
Source File: CastExpression.java From spork with Apache License 2.0 | 4 votes |
public CastExpression(OperatorPlan plan, LogicalExpression exp, LogicalSchema.LogicalFieldSchema fs) { super("Cast", plan, exp); castSchema = fs.deepCopy(); castSchema.resetUid(); }
Example 19
Source File: PigTypes.java From calcite with Apache License 2.0 | 2 votes |
/** * Converts a Pig schema field to relational type. * * @param pigField Pig schema field * @return Relational type */ static RelDataType convertSchemaField(LogicalSchema.LogicalFieldSchema pigField) { return convertSchemaField(pigField, true); }
Example 20
Source File: TypeCheckingExpVisitor.java From spork with Apache License 2.0 | 2 votes |
/** * add cast to convert the input of exp * {@link LogicalExpression} arg to type toType * @param exp * @param toType * @param arg * @throws FrontendException */ private void insertCast(LogicalExpression exp, byte toType, LogicalExpression arg) throws FrontendException { LogicalFieldSchema toFs = new LogicalSchema.LogicalFieldSchema(null, null, toType); insertCast(exp, toFs, arg); }