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

Exception for long field when value can be represented with a integer #32

Open
JeremieBergeron opened this issue Oct 29, 2024 · 0 comments · May be fixed by #33
Open

Exception for long field when value can be represented with a integer #32

JeremieBergeron opened this issue Oct 29, 2024 · 0 comments · May be fixed by #33

Comments

@JeremieBergeron
Copy link

When specifying a value for a field of type "long" that falls within the 32-bit integer range (like 2147483647), the generator raises an exception because it appears to expect values that don’t overlap with the 32-bit integer representation. Oddly, values that exceed the 32-bit integer range (such as 2147483648) work as expected, suggesting an issue with how values are parsed or type-checked within the generator.

Exception Details

The generator throws the following exception when specifying 2147483647:

Exception in thread "main" java.lang.RuntimeException: Invalid option for record schema: type org.apache.avro.generic.GenericData$Record, value '{"a": "exemple", "b": 2147483647}'

In contrast, values outside the 32-bit integer range, like 2147483648, do not trigger this error.

Example JSON Schema

Here’s the schema that causes the exception:

{
    "namespace": "datagen.example",
    "name": "users",
    "type": "record",
    "fields": [
        {
            "name": "a",
            "type": "string"
        },
        {
            "name": "b",
            "type": "long"
        }
    ],
    "arg.properties": {
        "options": [
            {
                "a": "exemple",
                "b": 2147483647
            }
        ]
    }
}

However, if we use 2147483648 for "b", it works correctly.

Tested version: confluentinc/avro-random-generator@1a87c97

@JeremieBergeron JeremieBergeron changed the title Exception for long field when value is can be represented with a integer Exception for long field when value can be represented with a integer Oct 29, 2024
@JeremieBergeron JeremieBergeron linked a pull request Oct 29, 2024 that will close this issue
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

Successfully merging a pull request may close this issue.

1 participant