Package org.apache.pig.impl.logicalLayer.schema.Schema

Examples of org.apache.pig.impl.logicalLayer.schema.Schema.FieldSchema


        if(sFields.size()!=fsFields.size())
            return INF;
        long score = 0;
        int castCnt=0;
        for(int i=0;i<sFields.size();i++){
            FieldSchema sFS = sFields.get(i);

            // if we have a byte array do not include it
            // in the computation of the score - bytearray
            // fields will be looked at separately outside
            // of this function
            if (sFS.type == DataType.BYTEARRAY)
                continue;

            FieldSchema fsFS = fsFields.get(i);
           
            if(DataType.isSchemaType(sFS.type)){
                if(!FieldSchema.equals(sFS, fsFS, false, true))
                    return INF;
            }
View Full Code Here


        List<FieldSchema> tsLst = toSch.getFields();
        List<ExpressionOperator> args = udf.getArguments();
        int i=-1;
        for (FieldSchema fFSch : fsLst) {
            ++i;
            FieldSchema tFSch = tsLst.get(i);
            if(fFSch.type==tFSch.type) {
                continue;
            }
            insertCastForUDF(udf, fFSch, tFSch, args.get(i));
        }
View Full Code Here

            project.setSentinel(true);
            genPlan.add(project);

            // add casting if necessary by comparing target types
            // to the input schema
            FieldSchema fs = null ;
            try {
                fs = fromSchema.getField(i) ;
            }
            catch(FrontendException fee) {
                int errCode = 1063;
View Full Code Here

                return streamLoaderSpec;
            }
           
            Schema s = op.getSchema();
            if(null != s) {
              FieldSchema fieldSchema = s.findFieldSchema( parentCanonicalName );
                getLoadFuncSpec( fieldSchema, loadFuncSpecMap );
            } else {
                LogicalPlan lp = op.getPlan();
                for(LogicalOperator pred: lp.getPredecessors(op)) {
                    FuncSpec lfSpec = getLoadFuncSpec(pred, parentCanonicalName);
View Full Code Here

        NegativeExpression op = new NegativeExpression(exprPlan, exprOpsMap.get(exp));
        exprOpsMap.put(uniOp, op);
    }

    public void visit(LOMapLookup colOp) throws VisitorException {
        FieldSchema fieldSchema;
        try {
            fieldSchema = colOp.getFieldSchema();
        } catch (FrontendException e) {
            throw new VisitorException( e.getMessage() );
        }
View Full Code Here

        }
        try {
            if(type == DataType.ERROR){
                return Schema.generateNestedSchema(DataType.BAG, DataType.NULL);
            }
            FieldSchema innerFs = new Schema.FieldSchema(null, innerSchema, type);
            Schema innerSch = new Schema(innerFs);
            Schema bagSchema = new Schema(new FieldSchema(null, innerSch, DataType.BAG));
            return bagSchema;
        } catch (FrontendException e) {
            //This should not happen
            throw new RuntimeException("Bug : exception thrown while " +
                    "creating output schema for TOBAG udf", e);
View Full Code Here

    @Override
    public Schema.FieldSchema getFieldSchema() throws FrontendException {
        if(!mIsFieldSchemaComputed) {
            if(userSpecifiedFieldSchema != null) {
                mFieldSchema = new FieldSchema(userSpecifiedFieldSchema);
            } else {
                mFieldSchema = new Schema.FieldSchema(null, mType);
            }
            Schema.FieldSchema parFs  = getExpression().getFieldSchema();
            String canonicalName = (parFs != null ? parFs.canonicalName : null);
View Full Code Here

            return input;
        }
       
        @Override
        public Schema outputSchema(Schema input) {
            FieldSchema fs =
                new Schema.FieldSchema(getSchemaName("UDFTupleNullSchema", input),
                        DataType.TUPLE);
                return new Schema(fs);
        }
View Full Code Here

        // schema for input#1
        Schema inputSchema1 = null ;
        {
            List<FieldSchema> fsList1 = new ArrayList<FieldSchema>() ;
            fsList1.add(new FieldSchema("field1a", DataType.INTEGER)) ;
            fsList1.add(new FieldSchema("field2a", DataType.BYTEARRAY)) ;
            inputSchema1 = new Schema(fsList1) ;
        }

        // set schemas
        load1.setEnforcedSchema(inputSchema1) ;
View Full Code Here

   
    @Test
    public void testSchemaEqual1() {
       
        List<FieldSchema> innerList1 = new ArrayList<FieldSchema>() ;
        innerList1.add(new FieldSchema("11a", DataType.INTEGER)) ;
        innerList1.add(new FieldSchema("11b", DataType.LONG)) ;
       
        List<FieldSchema> innerList2 = new ArrayList<FieldSchema>() ;
        innerList2.add(new FieldSchema("11a", DataType.INTEGER)) ;
        innerList2.add(new FieldSchema("11b", DataType.LONG)) ;
       
        Schema innerSchema1 = new Schema(innerList1) ;
        Schema innerSchema2 = new Schema(innerList2) ;
               
        List<FieldSchema> list1 = new ArrayList<FieldSchema>() ;
        list1.add(new FieldSchema("1a", DataType.BYTEARRAY)) ;
        list1.add(new FieldSchema("1b", innerSchema1)) ;
        list1.add(new FieldSchema("1c", DataType.INTEGER)) ;
       
        List<FieldSchema> list2 = new ArrayList<FieldSchema>() ;
        list2.add(new FieldSchema("1a", DataType.BYTEARRAY)) ;
        list2.add(new FieldSchema("1b", innerSchema2)) ;
        list2.add(new FieldSchema("1c", DataType.INTEGER)) ;
       
        Schema schema1 = new Schema(list1) ;
        Schema schema2 = new Schema(list2) ;
       
        Assert.assertTrue(Schema.equals(schema1, schema2, false, false)) ;
View Full Code Here

TOP

Related Classes of org.apache.pig.impl.logicalLayer.schema.Schema.FieldSchema

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.