-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
[Bug] Pulsar client AUTO_CONSUME "double" as "BigDecimal" in JSON schemas #20092
Comments
Thanks for your report @aymkhalil!
Sorry, it is still valid on master. |
I think it's this PR change the behavior: #15687 Note that we now use:
... for deserializing. |
Basically I don't think it's bad but we should adjust to correct schema using schema info. |
I create a patch to fix your use case #20104. You can give it a try and help in review. I don't know if it affects other use case but if it's good to go, I can add your test case :) Thanks for your reporting again especially the reproduce steps. |
Thanks @tisonkun - I verified your patch locally and it works well. I think it is reasonable because IIUC the If it makes sense, one potential test case is to make sure the GenericJsonObject and the JsonNode available via NativeObject return the same node types. For example, before your patch
A test to detect a mismatch would've been one early indicator. |
for user issues:
I think we don't need to think about JsonNode.get("xxxx") it's not the API of Pulsar and the user knows the field name and the user also knows it's the type and how the field encoding. for the need to improve:Line 75 in 58ccf02
now we use GenericJsonRecord.getField() , if is the FloatingPointNumber we return double type directly if the field schema is decimal, we should return decimal. its Pulsar API needs to guarantee.
|
Ideally yes, but my understanding is that the public API is limited and hence nativeObject was exposed (as far as end user is concerned this is part of the API no?). With that in mind, I think it is safer if the native object and the public API behavior match (or I can't think of a good reason why they wouldn't).
This actually demonstrates the confusion because the generic pulsar schema API doesn't have a DECIMAL type. As a user, I think of nativeObject as my source of truth. Let me know if this is the wrong expectation. |
The issue had no activity for 30 days, mark with Stale label. |
Search before asking
Version
Pulsar client 2.10.3, 2.10.2, 2.10.1. Please note the behavior was correct with 2.8.3 and 2.10.0 and regressed starting with 2.10.1
Minimal reproduce step
Run the below program to create a topic with a JSON schema that has an optional double field. Please note the behavior is correct if the field is not optional
What did you expect to see?
The assertion should pass
What did you see instead?
Anything else?
No response
Are you willing to submit a PR?
The text was updated successfully, but these errors were encountered: