Hi everyone. I’ve encountered an issue while trying to add a new attribute to an existing schema programmatically, and I was hoping you could assist me in resolving it.
The schema configuration is as follows:
./geomesa-accumulo get-sft-config -c myNamespace.geomesa -z 127.0.0.1 -i accumulo -u root -p GisPwd -f SignalBuilder --format spec
Result:
*geo:Point,time:Date,cam:String:keep-stats=true,imei:String,dir:Double,alt:Double,vlc:Double,sl:Integer,ds:Integer,dir_y:Double,poi_azimuth_x:Double,poi_azimuth_y:Double;
geomesa.stats.enable='true',geomesa.z.splits='4',geomesa.feature.expiry='time(30 days)',geomesa.table.partition='time',geomesa.index.dtg='time',
geomesa.indices='z3:7:3:geo:time,z2:5:3:geo,attr:8:3:cam:time',geomesa.attr.splits='4',geomesa.z3.interval='week'
I tried to add a new attribute sourceType
to this schema programmatically using the following code:
private void createOrUpdateSchema(DataStore ds, String typeName) throws IOException {
SimpleFeatureType existingSFT = ds.getSchema(typeName);
if (existingSFT != null) {
if (existingSFT.getDescriptor("sourceType") == null) {
SimpleFeatureTypeBuilder builder = new SimpleFeatureTypeBuilder();
builder.init(existingSFT);
builder.add("sourceType", String.class);
SimpleFeatureType updatedSFT = builder.buildFeatureType();
ds.updateSchema(typeName, updatedSFT);
}
}
}
However, when I run this code, it throws the following exception:
java.lang.UnsupportedOperationException: Changing the default date attribute is not supported
At the same time, when I use the GeoMesa CLI tool to add the same attribute, it works without any issues:
./geomesa-accumulo update-schema -c myNamespace.geomesa -z 127.0.0.1 -i accumulo -u root -p GisPwd -f SignalBuilder --add-attribute sourceType:String
INFO Preparing to update schema 'SignalBuilder':
1: Adding attribute 'sourceType' of type java.lang.String
Continue (y/n)? y
INFO Updating, please wait...
INFO Update complete
Question:
Why does adding a new attribute via the Java API (updateSchema
) fail with the error Changing the default date attribute is not supported
, while the same operation using the CLI tool succeeds? How can I achieve this programmatically without using the CLI?
I appreciate your time and any guidance you can provide.
--
Best regards,
Rinchin Gomboev