influxdata / influxdata/influxdb-client-java
Wrong column type when use wildcard with @Measurement
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 477
- Forks
- 129
- PR merge metrics
- No merged PRs in 30d
Description
__Steps to reproduce:__
```java
@Getter
public abstract class InfluxDbDefaultPoint {
@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 {
public InfluxDbTemperaturePoint(Long deviceId, Double value) {
super(deviceId, value);
}
}
public static void main(String[] args) {
final InfluxDBClient database = InfluxDBClientFactory.create("http://localhost:8200","".toCharArray(),"","");
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**
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the issue with the @Measurement, @Column, InfluxDbDefaultPoint, and InfluxDbTemperaturePoint example through writeMeasurement. Trace how the wildcard generic field value is classified before serialization, then verify that 30.0 is written as a numeric field rather than a string without breaking the non-wildcard case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100