HowlSchema tableSchema = getTableSchema();
assertEquals(3, tableSchema.getFields().size());
//Update partition schema to have 3 fields
partitionColumns.add(HowlSchemaUtils.getHowlFieldSchema(new FieldSchema("c3", Constants.STRING_TYPE_NAME, "")));
writeRecords = new ArrayList<HowlRecord>();
for(int i = 0;i < 20;i++) {
List<Object> objList = new ArrayList<Object>();
objList.add(i);
objList.add("strvalue" + i);
objList.add("str2value" + i);
writeRecords.add(new DefaultHowlRecord(objList));
}
Map<String, String> partitionMap = new HashMap<String, String>();
partitionMap.put("part1", "p1value5");
runMRCreate(partitionMap, partitionColumns, writeRecords, 10);
tableSchema = getTableSchema();
//assert that c3 has got added to table schema
assertEquals(4, tableSchema.getFields().size());
assertEquals("c1", tableSchema.getFields().get(0).getName());
assertEquals("c2", tableSchema.getFields().get(1).getName());
assertEquals("c3", tableSchema.getFields().get(2).getName());
assertEquals("part1", tableSchema.getFields().get(3).getName());
//Test that changing column data type fails
partitionMap.clear();
partitionMap.put("part1", "p1value6");
partitionColumns = new ArrayList<HowlFieldSchema>();
partitionColumns.add(HowlSchemaUtils.getHowlFieldSchema(new FieldSchema("c1", Constants.INT_TYPE_NAME, "")));
partitionColumns.add(HowlSchemaUtils.getHowlFieldSchema(new FieldSchema("c2", Constants.INT_TYPE_NAME, "")));
IOException exc = null;
try {
runMRCreate(partitionMap, partitionColumns, writeRecords, 20);
} catch(IOException e) {
exc = e;
}
assertTrue(exc != null);
assertTrue(exc instanceof HowlException);
assertEquals(ErrorType.ERROR_SCHEMA_TYPE_MISMATCH, ((HowlException) exc).getErrorType());
//Test that partition key is not allowed in data
partitionColumns = new ArrayList<HowlFieldSchema>();
partitionColumns.add(HowlSchemaUtils.getHowlFieldSchema(new FieldSchema("c1", Constants.INT_TYPE_NAME, "")));
partitionColumns.add(HowlSchemaUtils.getHowlFieldSchema(new FieldSchema("c2", Constants.STRING_TYPE_NAME, "")));
partitionColumns.add(HowlSchemaUtils.getHowlFieldSchema(new FieldSchema("c3", Constants.STRING_TYPE_NAME, "")));
partitionColumns.add(HowlSchemaUtils.getHowlFieldSchema(new FieldSchema("part1", Constants.STRING_TYPE_NAME, "")));
List<HowlRecord> recordsContainingPartitionCols = new ArrayList<HowlRecord>(20);
for(int i = 0;i < 20;i++) {
List<Object> objList = new ArrayList<Object>();