Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [geomesa-users] -EXT- Need Help with Adding Attribute to GeoMesa Schema Programmatically
  • From: "Lahr-Vivaz, Emilio" <Emilio.Lahr-Vivaz@xxxxxxxxxxx>
  • Date: Fri, 17 Jan 2025 18:00:16 +0000
  • Accept-language: en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=ga-ccri.com; dmarc=pass action=none header.from=ga-ccri.com; dkim=pass header.d=ga-ccri.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector5401; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=+hN5U8QLDkiHrVISjhMhs7OPpLBfn5E1aUacta4yBHQ=; b=j+RCfhLQC/UZbPQ+AZkHlGzwvZHMe+Hiry/Q6BZpHhp47cZrT5LDHY4bNx1tTG45nUsFx6Dz5NxWAdi5dVEvD6bRFL7jggJFTcMDv6YHujFM4r6EIjM1hpd95Ql30CTLYcBzhx8CcNR2uiVMHE9/7j7KHscnPMuforRPT36gcseIuTDzhP8yMBRTlUThze9du3whMGAGWvPdU6OnNM5/30KwccDIcHQjKPY1gc9f0fB8WDVDjRUZ3YqVQtiFSTYofRCNtn6jRQBclPfLZ/hEqJy9ysbRSQL5RBu0YfzxxXtciJ1UNF1lSIaUokAt2QjVdQBmm67H7wKlfHgHq5Iu+A==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector5401; d=microsoft.com; cv=none; b=NfjvmQN+ZP9DPMIlJCpDMjid+flwJ2YQ+DnDUoSGS6X1BJ6jNAisoIG9SkfQWc/guNP4sXGfrfHjDVZrmqVAym+G25qbg+zPEqxiK84NB7YwVOwdXZGaGGmW1ykNc/AHB1/xy6CaqmWcRGT2t+eCQnMaS1/8Q/AE6SWMXAU+7oOrUb/TEDfwo2sK5QT0wONMN3Ecjg6c5uFLg3fRxyoThALMNFOUkJizR8CjQbiyUkkVs8Sr0DKSAbRu4VbULYA1RzCwMiyF60yDv9j1SRFJILZUm2B///p5uxhkq2FP3oP6KINx5ZUorZvOGYJT0JVavBzmuXF+tXyazzGHN1RCPw==
  • Delivered-to: geomesa-users@xxxxxxxxxxx
  • List-archive: <https://dev.eclipse.org/mailman/private/geomesa-users/>
  • List-help: <mailto:geomesa-users-request@eclipse.org?subject=help>
  • List-subscribe: <https://dev.eclipse.org/mailman/listinfo/geomesa-users>, <mailto:geomesa-users-request@eclipse.org?subject=subscribe>
  • List-unsubscribe: <https://dev.eclipse.org/mailman/options/geomesa-users>, <mailto:geomesa-users-request@eclipse.org?subject=unsubscribe>
  • Msip_labels:
  • Thread-index: AQHbaP2/M3q5wrFpLEmjtvo9JNkGxbMbQFw8
  • Thread-topic: -EXT-[geomesa-users] Need Help with Adding Attribute to GeoMesa Schema Programmatically

Hello,


Otherwise, it thinks you're trying to make changes that you aren't intending.

Thanks,

Emilio Lahr-Vivaz
General Atomics, CCRi


From: geomesa-users <geomesa-users-bounces@xxxxxxxxxxx> on behalf of Rinchin Gomboev via geomesa-users <geomesa-users@xxxxxxxxxxx>
Sent: Friday, January 17, 2025 11:34 AM
To: Geomesa project user mailing list <geomesa-users@xxxxxxxxxxx>
Cc: Rinchin Gomboev <gomboev.rinchin@xxxxxxxxx>
Subject: -EXT-[geomesa-users] Need Help with Adding Attribute to GeoMesa Schema Programmatically
 

WARNING:  This message is from an external source.  Evaluate the message carefully BEFORE clicking on links or opening attachments.

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


Back to the top