I have already created the schema as follow :-
create column family Customer_detail_21
with column_type = 'Standard'
and comparator = 'UTF8Type'
and default_validation_class = 'UTF8Type'
and key_validation_class = 'UTF8Type'
and rows_cached = 0.0
and row_cache_save_period = 0
and row_cache_keys_to_save = 0
and keys_cached = 0.0
and key_cache_save_period = 0
and read_repair_chance = 0.0
and gc_grace = 0
and min_compaction_threshold = 4
and max_compaction_threshold = 32
and replicate_on_write = false
and row_cache_provider = 'ConcurrentLinkedHashCacheProvider'
and compaction_strategy = 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy'
and column_metadata = [
{column_name : 'name',
validation_class : UTF8Type,
index_name : 'index_name_27',
index_type : 0,
}];
But when i updated the above schema through following below java code :-
public static void updateSchema() {
System.out.println("Update Schema");
ColumnFamilyDefinition familyDefinition = new ThriftCfDef(
getColumnFamilyDefinition("Customer_detail_21"));
if (familyDefinition != null) {
if (!isColumnPresent(familyDefinition)) {
BasicColumnDefinition columnDefinition = new BasicColumnDefinition();
columnDefinition.setName(StringSerializer.get().toByteBuffer(
"pincode"));
columnDefinition.setValidationClass(ComparatorType.INTEGERTYPE
.getClassName());
columnDefinition.setIndexName("index_pincode_66");
columnDefinition.setIndexType(ColumnIndexType.KEYS);
familyDefinition.addColumnDefinition(columnDefinition);
cluster.updateColumnFamily(familyDefinition, true);
}
}
}
I got the schema as below :-
create column family Customer_detail_21
with column_type = 'Standard'
and comparator = 'UTF8Type'
and default_validation_class = 'UTF8Type'
and key_validation_class = 'UTF8Type'
and rows_cached = 0.0
and row_cache_save_period = 0
and row_cache_keys_to_save = 0
and keys_cached = 0.0
and key_cache_save_period = 0
and read_repair_chance = 0.0
and gc_grace = 0
and min_compaction_threshold = 4
and max_compaction_threshold = 32
and replicate_on_write = false
and row_cache_provider = 'ConcurrentLinkedHashCacheProvider'
and compaction_strategy = 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy'
and column_metadata = [
{column_name : '',
validation_class : UTF8Type,
index_name : 'index_name_26',
index_type : 0,
},
{column_name : 'pincode',
validation_class : IntegerType,
index_name : 'index_pincode_65',
index_type : 0,
}];
As per the above output my previous column name = 'name' is now updated as column name = empty.
so why the old column name is getting empty after update.
as we cannot override the secondary index, that is why we cannot update the existing schema through hector API.