Package org.apache.hcatalog.data.schema

Examples of org.apache.hcatalog.data.schema.HCatFieldSchema


            client.dropDatabase(dbName, true, HCatClient.DropDBMode.CASCADE);
            client.createDatabase(HCatCreateDBDesc.create(dbName).build());
            String messageBusTopicName = "MY.topic.name";
            Map<String, String> tableProperties = new HashMap<String, String>(1);
            tableProperties.put(HCatConstants.HCAT_MSGBUS_TOPIC_NAME, messageBusTopicName);
            client.createTable(HCatCreateTableDesc.create(dbName, tableName, Arrays.asList(new HCatFieldSchema("foo", Type.STRING, ""))).tblProps(tableProperties).build());

            assertEquals("MessageBus topic-name doesn't match!", messageBusTopicName, client.getMessageBusTopicName(dbName, tableName));
            client.dropDatabase(dbName, true, HCatClient.DropDBMode.CASCADE);
            client.close();
        }
View Full Code Here


            final String tableName = "myTable";

            client.dropDatabase(dbName, true, HCatClient.DropDBMode.CASCADE);

            client.createDatabase(HCatCreateDBDesc.create(dbName).build());
            List<HCatFieldSchema> columnSchema = Arrays.asList(new HCatFieldSchema("foo", Type.INT, ""),
                    new HCatFieldSchema("bar", Type.STRING, ""));

            List<HCatFieldSchema> partitionSchema = Arrays.asList(new HCatFieldSchema("dt", Type.STRING, ""),
                    new HCatFieldSchema("grid", Type.STRING, ""));

            client.createTable(HCatCreateTableDesc.create(dbName, tableName, columnSchema).partCols(partitionSchema).build());

            HCatTable table = client.getTable(dbName, tableName);
            List<HCatFieldSchema> partitionColumns = table.getPartCols();
View Full Code Here

            final String tableName = "myTable";

            client.dropDatabase(dbName, true, HCatClient.DropDBMode.CASCADE);

            client.createDatabase(HCatCreateDBDesc.create(dbName).build());
            List<HCatFieldSchema> columnSchema = Arrays.asList(new HCatFieldSchema("foo", Type.INT, ""),
                    new HCatFieldSchema("bar", Type.STRING, ""));

            List<HCatFieldSchema> partitionSchema = Arrays.asList(new HCatFieldSchema("dt", Type.STRING, ""),
                    new HCatFieldSchema("grid", Type.STRING, ""));

            client.createTable(HCatCreateTableDesc.create(dbName, tableName, columnSchema).partCols(new ArrayList<HCatFieldSchema>(partitionSchema)).build());

            Map<String, String> partitionSpec = new HashMap<String, String>();
            partitionSpec.put("grid", "AB");
View Full Code Here

            final String tableName = "myTable";

            client.dropDatabase(dbName, true, HCatClient.DropDBMode.CASCADE);

            client.createDatabase(HCatCreateDBDesc.create(dbName).build());
            List<HCatFieldSchema> columnSchema = Arrays.asList(new HCatFieldSchema("foo", Type.INT, ""),
                    new HCatFieldSchema("bar", Type.STRING, ""));

            List<HCatFieldSchema> partitionSchema = Arrays.asList(new HCatFieldSchema("dt", Type.STRING, ""),
                    new HCatFieldSchema("grid", Type.STRING, ""));

            client.createTable(HCatCreateTableDesc.create(dbName, tableName, columnSchema).partCols(new ArrayList<HCatFieldSchema>(partitionSchema)).build());

            Map<String, String> partitionSpec = new HashMap<String, String>();
            partitionSpec.put("grid", "AB");
View Full Code Here

                        0, 0, 0, sd, new ArrayList<FieldSchema>(), new HashMap<String, String>(),
                        "viewOriginalText", "viewExpandedText", TableType.EXTERNAL_TABLE.name());
        Table table = new Table(apiTable);

        List<HCatFieldSchema> expectedHCatSchema =
                Lists.newArrayList(new HCatFieldSchema("username", HCatFieldSchema.Type.STRING, null));

        Assert.assertEquals(new HCatSchema(expectedHCatSchema),
                HCatUtil.getTableSchemaWithPtnCols(table));

        // Add a partition key & ensure its reflected in the schema.
        List<FieldSchema> partitionKeys =
                Lists.newArrayList(new FieldSchema("dt", serdeConstants.STRING_TYPE_NAME, null));
        table.getTTable().setPartitionKeys(partitionKeys);
        expectedHCatSchema.add(new HCatFieldSchema("dt", HCatFieldSchema.Type.STRING, null));
        Assert.assertEquals(new HCatSchema(expectedHCatSchema),
                HCatUtil.getTableSchemaWithPtnCols(table));
    }
View Full Code Here

                        0, 0, 0, sd, new ArrayList<FieldSchema>(), new HashMap<String, String>(),
                        "viewOriginalText", "viewExpandedText", TableType.EXTERNAL_TABLE.name());
        Table table = new Table(apiTable);

        List<HCatFieldSchema> expectedHCatSchema = Lists.newArrayList(
                new HCatFieldSchema("myint", HCatFieldSchema.Type.INT, null),
                new HCatFieldSchema("mystring", HCatFieldSchema.Type.STRING, null),
                new HCatFieldSchema("underscore_int", HCatFieldSchema.Type.INT, null));

        Assert.assertEquals(new HCatSchema(expectedHCatSchema),
                HCatUtil.getTableSchemaWithPtnCols(table));
    }
View Full Code Here

        }
    }

    private HCatSchema getSchema() throws HCatException {
        HCatSchema schema = new HCatSchema(new ArrayList<HCatFieldSchema>());
        schema.append(new HCatFieldSchema("a0", HCatFieldSchema.Type.INT,
                ""));
        schema.append(new HCatFieldSchema("a1",
                HCatFieldSchema.Type.STRING, ""));
        schema.append(new HCatFieldSchema("a2",
                HCatFieldSchema.Type.STRING, ""));
        return schema;
    }
View Full Code Here

        }
    }

    private HCatSchema getSchema() throws HCatException {
        HCatSchema schema = new HCatSchema(new ArrayList<HCatFieldSchema>());
        schema.append(new HCatFieldSchema("a0", HCatFieldSchema.Type.INT,
                ""));
        schema.append(new HCatFieldSchema("a1",
                HCatFieldSchema.Type.STRING, ""));
        schema.append(new HCatFieldSchema("a2",
                HCatFieldSchema.Type.STRING, ""));
        return schema;
    }
View Full Code Here

        bagSubFieldSchemas[0].setSchema(new ResourceSchema().setFields(innerTupleFieldSchemas));
        ResourceSchema expected = new ResourceSchema().setFields(bagSubFieldSchemas);

        // Get the actual converted schema.
        HCatSchema actualHCatSchema = new HCatSchema(Lists.newArrayList(
            new HCatFieldSchema("innerLlama", HCatFieldSchema.Type.STRING, null)));
        HCatFieldSchema actualHCatFieldSchema =
            new HCatFieldSchema("llama", HCatFieldSchema.Type.ARRAY, actualHCatSchema, null);
        ResourceSchema actual = PigHCatUtil.getBagSubSchema(actualHCatFieldSchema);

        Assert.assertEquals(expected.toString(), actual.toString());
    }
View Full Code Here

        ResourceFieldSchema[] bagSubFieldSchemas = new ResourceFieldSchema[1];
        bagSubFieldSchemas[0] = new ResourceFieldSchema().setName(innerTupleName)
            .setDescription("The tuple in the bag")
            .setType(DataType.TUPLE);
        HCatFieldSchema arrayElementFieldSchema = hfs.getArrayElementSchema().get(0);
        if (arrayElementFieldSchema.getType() == Type.STRUCT) {
            bagSubFieldSchemas[0].setSchema(getTupleSubSchema(arrayElementFieldSchema));
        } else if (arrayElementFieldSchema.getType() == Type.ARRAY) {
            ResourceSchema s = new ResourceSchema();
            List<ResourceFieldSchema> lrfs = Arrays.asList(getResourceSchemaFromFieldSchema(arrayElementFieldSchema));
            s.setFields(lrfs.toArray(new ResourceFieldSchema[0]));
            bagSubFieldSchemas[0].setSchema(s);
        } else {
View Full Code Here

TOP

Related Classes of org.apache.hcatalog.data.schema.HCatFieldSchema

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.