-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Make functionNullability property consistent in ResolvedFunction #13777
Conversation
The mismatch of "nullability" and "functionNullability" could cause failure of JSON deserialization for ResolvedFunction
When running locally from IDE, under debugger I verified that during JSON serialization the If this is a reliable mechanism, that means we don't have a bug (but the change is still a good change). @electrum you probably know how and when this works cc @dain |
@findepi You're right. Or if we want to keep the constructor annotation unchanged
The point is the name of JsonProperty need to be consistent. |
that's what i believe is true
i'd like to understand whether it's "have to" or "should" or "it would be nice to". |
It's not supposed to work that way. AFAICT, that's a behavior change in recent versions of Jackson -- not sure if intentional or a bug, but certainly a backward incompatible change, and at a minimum, very surprising. For example, if you run the following test within Trino: public class Container
{
private int value;
@JsonCreator
public Container(@JsonProperty("foo") int value)
{
this.value = value;
}
@JsonProperty
public int getValue()
{
return value;
}
public static void main(String[] args) {}
{
System.out.println(jsonCodec(Container.class).toJson(new Container(1)));
}
} it produces:
but it you run it within Airlift, it produces:
My guess is that it's linking the getter name to the argument name and inferring the property name from that annotation (and ignoring the fact that the getter already has an annotation and the rules that govern it). This is supported by the fact that if you change the variable name to something else, it starts producing the variant with If intentional, this is a very surprising behavior in Jackson. It's now not possible to look at a getter declaration and make inferences about how the property will be named just from the signature of the method and any annotation on it: @JsonProperty
public int getValue() { ... } |
@findepi Can you please take another look? I'm still experiencing this issue, as of Trino 412. It would be great if we can incorporate this PR since it's harmless and makes the logic more consistent |
@weiatwork it would definitely help if there was a regression test associated with this change |
Thanks @findepi for your response. I initially opened this PR because I ran into the problem with the presence of a file-based access control. Just to clarify, now I can reproduce the problem with the vanilla Trino 412 code, without any customization or addition. A simple SELECT query submitted to server would trigger it. However, the UT |
@weiatwork i am glad you are able to reproduce the problem!
can you perhaps try reproducing the problem as a product test? |
Thanks @findepi. Just FYI, from my side, this can be reproduced by simply launching Trino server (from within IDE), and run a SELECT query from CLI. I doubt this is a common issue for everyone else because it would have been reported already if that's the case. It could be due to some Jackson lib dependency from my local setup that somehow was being picky(?). Anyway, the bottom line is the annotation should be consistent between the constructor and the getters. Otherwise, the potential issue is just there waiting to be triggered. If you think this change is unnecessary, feel free to close the PR. |
My understanding is that
if indeed so, we should still merge the change, but the regression tes is not possible |
The mismatch of "nullability" and "functionNullability" could cause
failure of JSON deserialization for ResolvedFunction
(This PR is to replace #13402 which had merge issue)
The symptom is query that involves function usages fails with error message like:
java.lang.IllegalArgumentException: Invalid JSON bytes for [simple type, class io.trino.metadata.ResolvedFunction]
Root cause is #10183, and specifically 2c1ebd6
The problem is exposed starting from #11217
Repro steps:
Description
Related issues, pull requests, and links
Documentation
(x) No documentation is needed.
( ) Sufficient documentation is included in this PR.
( ) Documentation PR is available with #prnumber.
( ) Documentation issue #issuenumber is filed, and can be handled later.
Release notes
(x) No release notes entries required.
( ) Release notes entries required with the following suggested text: