Package org.apache.pig

Examples of org.apache.pig.ResourceSchema$ResourceFieldSchema


    public void testSchemaConversion2() throws Exception {  
        pig.registerQuery("A = LOAD 'originput' using org.apache.pig.piggybank.storage.PigStorageSchema(',') as (f1:chararray, f2:int);");
        pig.registerQuery("B = group A by f1;");
        Schema origSchema = pig.dumpSchema("B");
        ResourceSchema rs1 = new ResourceSchema(origSchema);
        pig.registerQuery("STORE B into 'cout' using org.apache.pig.piggybank.storage.PigStorageSchema();");
       
        pig.registerQuery("C = LOAD 'cout' using org.apache.pig.piggybank.storage.PigStorageSchema();");
        Schema genSchema = pig.dumpSchema("C");
        ResourceSchema rs2 = new ResourceSchema(genSchema);
        assertTrue("generated schema equals original" , ResourceSchema.equals(rs1, rs2));
       
        pig.registerQuery("C1 = LOAD 'cout' as (a0:chararray, A: {t: (f1:chararray, f2:int) } );");
        pig.registerQuery("D = foreach C1 generate a0, SUM(A.f2);");
View Full Code Here


  for (int i = 0; i < cols.size(); i++) {
      fieldSchemaList.add(new FieldSchema(cols.get(i), HiveRCSchemaUtil
        .findPigDataType(types.get(i))));
  }

  pigSchema = new ResourceSchema(new Schema(fieldSchemaList));

  props = new Properties();

  // setting table schema properties for ColumnarSerDe
  // these properties are never changed by the columns to read filter,
View Full Code Here

                int errCode = 2104;
                String msg = "Error while determining schema of SequenceFileStorage data.";
                throw new ExecException(msg, errCode, PigException.BUG, e);
            }
        }
        return new ResourceSchema(s);
    }
View Full Code Here

    throws ExecException, SchemaMergeException, FrontendException {
        String [] aliases ={"f1", "f2"};
        byte[] types = {DataType.CHARARRAY, DataType.INTEGER};
        Schema origSchema = TypeCheckingTestUtil.genFlatSchema(
                aliases,types);
        ResourceSchema rsSchema = new ResourceSchema(origSchema);
        assertEquals("num fields", aliases.length, rsSchema.getFields().length);
        ResourceSchema.ResourceFieldSchema[] fields = rsSchema.getFields();
        for (int i=0; i<fields.length; i++) {
            assertEquals(fields[i].getName(), aliases[i]);
            assertEquals(fields[i].getType(), types[i]);
        }
        Schema genSchema = Schema.getPigSchema(rsSchema);
View Full Code Here

                                new Schema.FieldSchema("t0",
                                        TypeCheckingTestUtil.genFlatSchema(
                                                aliases,types),
                                                DataType.TUPLE)), DataType.BAG));
                       
        ResourceSchema rsSchema = new ResourceSchema(origSchema);

        Schema genSchema = Schema.getPigSchema(rsSchema);
        assertTrue("generated schema equals original",
                Schema.equals(genSchema, origSchema, true, false));
    }
View Full Code Here

        SortColInfo col2 = new SortColInfo("f1", 1, SortColInfo.Order.DESCENDING);
        colList.add(col1);
        colList.add(col2);
        SortInfo sortInfo = new SortInfo(colList);
                       
        ResourceSchema rsSchema = new ResourceSchema(origSchema, sortInfo);

        Schema genSchema = Schema.getPigSchema(rsSchema);
        assertTrue("generated schema equals original",
                Schema.equals(genSchema, origSchema, true, false));
        assertTrue(rsSchema.getSortKeys()[0]==0);
        assertTrue(rsSchema.getSortKeys()[1]==1);
        assertTrue(rsSchema.getSortKeyOrders()[0]==ResourceSchema.Order.ASCENDING);
        assertTrue(rsSchema.getSortKeyOrders()[1]==ResourceSchema.Order.DESCENDING);
    }
View Full Code Here

                    .setName("fld1").setType(DataType.DOUBLE),
                new ResourceFieldSchema()
                    .setName("fld2").setType(DataType.INTEGER)
        };
              
        ResourceSchema rSchema0 = new ResourceSchema()
            .setFields(level0);
       
        ResourceFieldSchema[] level1 =
            new ResourceFieldSchema[] {
                new ResourceFieldSchema()
                    .setName("t1").setType(DataType.TUPLE)
                    .setSchema(rSchema0)
        };
       
        ResourceSchema rSchema1 = new ResourceSchema()
            .setFields(level1);
       
        ResourceFieldSchema[] level2 =
            new ResourceFieldSchema[] {
                new ResourceFieldSchema()
                    .setName("t2").setType(DataType.BAG)
                    .setSchema(rSchema1)
        };
       
        ResourceSchema origSchema = new ResourceSchema()
            .setFields(level2);       
       
        Schema pSchema = Schema.getPigSchema(origSchema);
               
        assertTrue(CheckTwoLevelAccess(pSchema));
               
        assertTrue(ResourceSchema.equals(origSchema, new ResourceSchema(pSchema)));
    }
View Full Code Here

                    .setName("fld1").setType(DataType.DOUBLE),       
                new ResourceFieldSchema()
                    .setName("fld2").setType(DataType.INTEGER)
        };
       
        ResourceSchema rSchema0 = new ResourceSchema()
            .setFields(level0);
       
        ResourceFieldSchema[] level2 = new ResourceFieldSchema[] {
                new ResourceFieldSchema()
                    .setName("t2").setType(DataType.BAG).setSchema(rSchema0)
View Full Code Here

        ResourceFieldSchema[] level0 = new ResourceFieldSchema[] {
                new ResourceFieldSchema()
                    .setName("fld0").setType(DataType.CHARARRAY)
        };
       
        ResourceSchema rSchema0 = new ResourceSchema()
            .setFields(level0);
       
        ResourceFieldSchema[] level2 = new ResourceFieldSchema[] {
                new ResourceFieldSchema()
                    .setName("t2").setType(DataType.BAG).setSchema(rSchema0)
View Full Code Here

        Schema level0 = TypeCheckingTestUtil.genFlatSchema(
                aliases,types);
        Schema.FieldSchema fld0 =
            new Schema.FieldSchema("f0", level0, DataType.BAG);
        Schema level1 = new Schema(fld0);
        Schema genSchema = Schema.getPigSchema(new ResourceSchema(level1));
        assertTrue(CheckTwoLevelAccess(genSchema));
    }
View Full Code Here

TOP

Related Classes of org.apache.pig.ResourceSchema$ResourceFieldSchema

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.