use of org.apache.hadoop.hive.metastore.api.FieldSchema in project hive by apache.
the class TestHBaseStore method hashSd.
@Test
public void hashSd() throws Exception {
List<FieldSchema> cols = new ArrayList<FieldSchema>();
cols.add(new FieldSchema("col1", "int", ""));
SerDeInfo serde = new SerDeInfo("serde", "seriallib", null);
StorageDescriptor sd = new StorageDescriptor(cols, "file:/tmp", "input", "output", true, 0, serde, null, null, emptyParameters);
Map<List<String>, String> map = new HashMap<List<String>, String>();
map.put(Arrays.asList("col3"), "col4");
SkewedInfo skew = new SkewedInfo(Arrays.asList("col1"), Arrays.asList(Arrays.asList("col2")), map);
sd.setSkewedInfo(skew);
MessageDigest md = MessageDigest.getInstance("MD5");
byte[] baseHash = HBaseUtils.hashStorageDescriptor(sd, md);
StorageDescriptor changeSchema = new StorageDescriptor(sd);
changeSchema.getCols().add(new FieldSchema("col2", "varchar(32)", "a comment"));
byte[] schemaHash = HBaseUtils.hashStorageDescriptor(changeSchema, md);
Assert.assertFalse(Arrays.equals(baseHash, schemaHash));
StorageDescriptor changeLocation = new StorageDescriptor(sd);
changeLocation.setLocation("file:/somewhere/else");
byte[] locationHash = HBaseUtils.hashStorageDescriptor(changeLocation, md);
Assert.assertArrayEquals(baseHash, locationHash);
}
use of org.apache.hadoop.hive.metastore.api.FieldSchema in project hive by apache.
the class TestHBaseStore method skewInfo.
@Test
public void skewInfo() 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);
StorageDescriptor sd = new StorageDescriptor(cols, "file:/tmp", "input", "output", true, 0, serde, null, null, emptyParameters);
Map<List<String>, String> map = new HashMap<List<String>, String>();
map.put(Arrays.asList("col3"), "col4");
SkewedInfo skew = new SkewedInfo(Arrays.asList("col1"), Arrays.asList(Arrays.asList("col2")), map);
sd.setSkewedInfo(skew);
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.assertEquals(1, t.getSd().getColsSize());
Assert.assertEquals("col1", t.getSd().getCols().get(0).getName());
Assert.assertEquals("int", t.getSd().getCols().get(0).getType());
Assert.assertEquals("", t.getSd().getCols().get(0).getComment());
Assert.assertEquals("serde", t.getSd().getSerdeInfo().getName());
Assert.assertEquals("seriallib", t.getSd().getSerdeInfo().getSerializationLib());
Assert.assertEquals("file:/tmp", t.getSd().getLocation());
Assert.assertEquals("input", t.getSd().getInputFormat());
Assert.assertEquals("output", t.getSd().getOutputFormat());
Assert.assertTrue(t.getSd().isCompressed());
Assert.assertEquals(0, t.getSd().getNumBuckets());
Assert.assertEquals(0, t.getSd().getSortColsSize());
Assert.assertEquals("me", t.getOwner());
Assert.assertEquals("default", t.getDbName());
Assert.assertEquals(tableName, t.getTableName());
Assert.assertEquals(0, t.getParametersSize());
skew = t.getSd().getSkewedInfo();
Assert.assertNotNull(skew);
Assert.assertEquals(1, skew.getSkewedColNamesSize());
Assert.assertEquals("col1", skew.getSkewedColNames().get(0));
Assert.assertEquals(1, skew.getSkewedColValuesSize());
Assert.assertEquals("col2", skew.getSkewedColValues().get(0).get(0));
Assert.assertEquals(1, skew.getSkewedColValueLocationMapsSize());
Assert.assertEquals("col4", skew.getSkewedColValueLocationMaps().get(Arrays.asList("col3")));
}
use of org.apache.hadoop.hive.metastore.api.FieldSchema in project hive by apache.
the class TestHBaseStore method createMultiColumnTable.
private Table createMultiColumnTable(String tblName, String... types) throws Exception {
List<FieldSchema> cols = new ArrayList<FieldSchema>();
for (int i = 0; i < types.length; i++) cols.add(new FieldSchema("col" + i, types[i], ""));
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);
int currentTime = (int) (System.currentTimeMillis() / 1000);
Table table = new Table(tblName, DB, "me", currentTime, currentTime, 0, sd, cols, emptyParameters, null, null, null);
store.createTable(table);
return table;
}
use of org.apache.hadoop.hive.metastore.api.FieldSchema in project hive by apache.
the class TestMetaStoreUtils method testColumnsIncluded.
@Test
public void testColumnsIncluded() {
FieldSchema col1 = new FieldSchema("col1", "string", "col1 comment");
FieldSchema col2 = new FieldSchema("col2", "string", "col2 comment");
FieldSchema col3 = new FieldSchema("col3", "string", "col3 comment");
Assert.assertTrue(MetaStoreUtils.columnsIncluded(Arrays.asList(col1), Arrays.asList(col1)));
Assert.assertTrue(MetaStoreUtils.columnsIncluded(Arrays.asList(col1, col2), Arrays.asList(col1, col2)));
Assert.assertTrue(MetaStoreUtils.columnsIncluded(Arrays.asList(col1, col2), Arrays.asList(col2, col1)));
Assert.assertTrue(MetaStoreUtils.columnsIncluded(Arrays.asList(col1, col2), Arrays.asList(col1, col2, col3)));
Assert.assertTrue(MetaStoreUtils.columnsIncluded(Arrays.asList(col1, col2), Arrays.asList(col3, col2, col1)));
Assert.assertFalse(MetaStoreUtils.columnsIncluded(Arrays.asList(col1, col2), Arrays.asList(col1)));
}
use of org.apache.hadoop.hive.metastore.api.FieldSchema in project hive by apache.
the class ExplainSQRewriteTask method getResultSchema.
public List<FieldSchema> getResultSchema() {
FieldSchema tmpFieldSchema = new FieldSchema();
List<FieldSchema> colList = new ArrayList<FieldSchema>();
tmpFieldSchema.setName(ExplainTask.EXPL_COLUMN_NAME);
tmpFieldSchema.setType(STRING_TYPE_NAME);
colList.add(tmpFieldSchema);
return colList;
}
Aggregations