Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong column type when use wildcard with @Measurement #609

Open
kalwinskidawid opened this issue Jul 25, 2023 · 1 comment
Open

Wrong column type when use wildcard with @Measurement #609

kalwinskidawid opened this issue Jul 25, 2023 · 1 comment

Comments

@kalwinskidawid
Copy link

kalwinskidawid commented Jul 25, 2023

Steps to reproduce:

@Getter
public abstract class InfluxDbDefaultPoint<T> {

    @Column(timestamp = true)
    private final Instant time;
    @Column(tag = true)
    private final Long deviceId;
    @Column
    private final T value;

    public InfluxDbDefaultPoint(final Long deviceId, final T value) {
        this.time = Instant.now();
        this.deviceId = deviceId;
        this.value = value;
    }
}

@Measurement(name = "temperature")
public class InfluxDbTemperaturePoint extends InfluxDbDefaultPoint<Double> {

    public InfluxDbTemperaturePoint(Long deviceId, Double value) {
        super(deviceId, value);
    }
}

public static void main(String[] args) {
        final InfluxDBClient database = InfluxDBClientFactory.create("http://localhost:8200","<token>".toCharArray(),"<org>","<bucket>");
        database.getWriteApiBlocking().writeMeasurement(WritePrecision.S, new InfluxDbTemperaturePoint(0L,30.0));
    }

When I try to send such a prepared model to influxdb, I get an error: HTTP status code: 422; Message: failure writing points to database: partial write: field type conflict: input field "value" on measurement "temperature" is type string, already exists as type float dropped=1.

Previously I had an InfluxDbTemperaturePoint object without wildcard and it worked fine - it saved double

Expected behavior:
It should save the value 30.0 as float/dobule.

Actual behavior:
It tries to save the value 30.0 as a string.

Specifications:

  • Client Version: 6.9.0
  • InfluxDB Version: v2.7.1
  • JDK Version: Java(TM) SE Runtime Environment (build 19.0.2+7-44)
  • Platform: Windows
@kalwinskidawid kalwinskidawid changed the title Wrong column type when use wildcard in Measurement Wrong column type when use wildcard with @Measurement Jul 25, 2023
@kalwinskidawid
Copy link
Author

I found almost the same problem, but the answer to #531 does not solve my problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant