use of org.apache.hadoop.hive.metastore.api.FieldSchema in project hive by apache.
the class ObjectStore method getType.
private Type getType(MType mtype) {
List<FieldSchema> fields = new ArrayList<FieldSchema>();
if (mtype.getFields() != null) {
for (MFieldSchema field : mtype.getFields()) {
fields.add(new FieldSchema(field.getName(), field.getType(), field.getComment()));
}
}
Type ret = new Type();
ret.setName(mtype.getName());
ret.setType1(mtype.getType1());
ret.setType2(mtype.getType2());
ret.setFields(fields);
return ret;
}
use of org.apache.hadoop.hive.metastore.api.FieldSchema in project hive by apache.
the class SetProcessor method getSchema.
// create a Schema object containing the give column
private Schema getSchema() {
Schema sch = new Schema();
FieldSchema tmpFieldSchema = new FieldSchema();
tmpFieldSchema.setName(SET_COLUMN_NAME);
tmpFieldSchema.setType(STRING_TYPE_NAME);
sch.putToProperties(SERIALIZATION_NULL_FORMAT, defaultNullString);
sch.addToFieldSchemas(tmpFieldSchema);
return sch;
}
use of org.apache.hadoop.hive.metastore.api.FieldSchema in project hive by apache.
the class TestHBaseStore method dropTable.
@Test
public void dropTable() throws Exception {
String tableName = "dtable";
int startTime = (int) (System.currentTimeMillis() / 1000);
List<FieldSchema> cols = new ArrayList<FieldSchema>();
cols.add(new FieldSchema("col1", "int", "nocomment"));
SerDeInfo serde = new SerDeInfo("serde", "seriallib", null);
StorageDescriptor sd = new StorageDescriptor(cols, "file:/tmp", "input", "output", false, 0, serde, null, null, emptyParameters);
Table table = new Table(tableName, "default", "me", startTime, startTime, 0, sd, null, emptyParameters, null, null, null);
store.createTable(table);
Table t = store.getTable("default", tableName);
Assert.assertNotNull(t);
store.dropTable("default", tableName);
Assert.assertNull(store.getTable("default", tableName));
}
use of org.apache.hadoop.hive.metastore.api.FieldSchema in project hive by apache.
the class TestHBaseStore method createPartition.
@Test
public void createPartition() throws Exception {
String tableName = "myparttable";
int startTime = (int) (System.currentTimeMillis() / 1000);
List<FieldSchema> cols = new ArrayList<FieldSchema>();
cols.add(new FieldSchema("col1", "int", "nocomment"));
SerDeInfo serde = new SerDeInfo("serde", "seriallib", null);
StorageDescriptor sd = new StorageDescriptor(cols, "file:/tmp", "input", "output", false, 0, serde, null, null, emptyParameters);
List<FieldSchema> partCols = new ArrayList<FieldSchema>();
partCols.add(new FieldSchema("pc", "string", ""));
Table table = new Table(tableName, DB, "me", startTime, startTime, 0, sd, partCols, emptyParameters, null, null, null);
store.createTable(table);
List<String> vals = Arrays.asList("fred");
StorageDescriptor psd = new StorageDescriptor(sd);
psd.setLocation("file:/tmp/pc=fred");
Partition part = new Partition(vals, DB, tableName, startTime, startTime, psd, emptyParameters);
store.addPartition(part);
Partition p = store.getPartition(DB, tableName, vals);
Assert.assertEquals(1, p.getSd().getColsSize());
Assert.assertEquals("col1", p.getSd().getCols().get(0).getName());
Assert.assertEquals("int", p.getSd().getCols().get(0).getType());
Assert.assertEquals("nocomment", p.getSd().getCols().get(0).getComment());
Assert.assertEquals("serde", p.getSd().getSerdeInfo().getName());
Assert.assertEquals("seriallib", p.getSd().getSerdeInfo().getSerializationLib());
Assert.assertEquals("file:/tmp/pc=fred", p.getSd().getLocation());
Assert.assertEquals("input", p.getSd().getInputFormat());
Assert.assertEquals("output", p.getSd().getOutputFormat());
Assert.assertEquals(DB, p.getDbName());
Assert.assertEquals(tableName, p.getTableName());
Assert.assertEquals(1, p.getValuesSize());
Assert.assertEquals("fred", p.getValues().get(0));
Assert.assertTrue(store.doesPartitionExist(DB, tableName, vals));
Assert.assertFalse(store.doesPartitionExist(DB, tableName, Arrays.asList("bob")));
}
use of org.apache.hadoop.hive.metastore.api.FieldSchema in project hive by apache.
the class TestHBaseStore method dropIndex.
@Test
public void dropIndex() throws Exception {
String tableName = "mytable";
int startTime = (int) (System.currentTimeMillis() / 1000);
List<FieldSchema> cols = new ArrayList<FieldSchema>();
cols.add(new FieldSchema("col1", "int", ""));
SerDeInfo serde = new SerDeInfo("serde", "seriallib", null);
Map<String, String> params = new HashMap<String, String>();
params.put("key", "value");
StorageDescriptor sd = new StorageDescriptor(cols, "file:/tmp", "input", "output", false, 17, serde, Arrays.asList("bucketcol"), Arrays.asList(new Order("sortcol", 1)), params);
Table table = new Table(tableName, "default", "me", startTime, startTime, 0, sd, null, emptyParameters, null, null, null);
store.createTable(table);
String indexName = "myindex";
Index index = new Index(indexName, null, "default", tableName, startTime, startTime, tableName + "__" + indexName + "__", sd, emptyParameters, false);
store.addIndex(index);
store.dropIndex("default", tableName, indexName);
}
Aggregations