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

ParseException while parsing uintiger and IEEE-754 64-bit floating-point number using the InfluxParser #10993

Open
raminqaf opened this issue Mar 14, 2021 · 0 comments

Comments

@raminqaf
Copy link

raminqaf commented Mar 14, 2021

Affected Version

ArtifactID: druid-influx-extensions
Version: 0.13.0-incubating

Description

My team and I are currently working on a project, and we used the InfluxParser in our project to parse string line protocols to data point objects. After testing it with different field value types we noticed that some of the field values are not supported. As for an example, consider the following test:

    @Test
    void shouldNotParseLineWithFieldValueAsUnsignedIntegerToDataPoint() {
        final String lineProtocol = "myMeasurement fieldKey=12485903u";

        final Point actualDataPoint = InfluxParser.parseToDataPoint(lineProtocol);

        assert actualDataPoint != null;
        final Long expectedFieldValue = 12485903L;
        assertEquals(expectedFieldValue, actualDataPoint.getField("fieldKey"));
    }

Currently, this test throws a ParseException and fails. The reason behind it is that in the InfluxLineProtogol.g4 the value context NUMBER doesn't support u yet.

This issue also arises whenever we tested IEEE-754 64-bit floating-point numbers, which is supported by InfluxDB. Consider the following test case:

    @Test
    void shouldParseLineWithFieldValueAsFloatToDataPoint() throws ParseException {
        final String lineProtocol = "myMeasurement fieldKey=-1.234456e+78";
        final Point actualDataPoint = InfluxParser.parseToDataPoint(lineProtocol);

        assert actualDataPoint != null;
        final double expectedFieldValue =-1.234456e+78;
        assertEquals(expectedFieldValue, actualDataPoint.getField("fieldKey"));
    }

Unfortunately, this test will fail since the parser is not caple of parsing the float filed value. The parser should parse these lines since they are all examples provided by InfluxDB documentation.
If necessary I will create a PR and contribute :)

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