make query context changes backwards compatible#12564
make query context changes backwards compatible#12564abhishekagarwal87 merged 4 commits intoapache:masterfrom
Conversation
| QueryContext getQueryContext(); | ||
| default QueryContext getQueryContext() | ||
| { | ||
| return IS_LEGACY_CONTEXT; |
There was a problem hiding this comment.
From looking at the code in this PR, why not return null and do null tests?
There was a problem hiding this comment.
heh, I just left a comment about the same thing here #12396 (comment)
I considered this, but decided against it because it didn't seem like actual implementations should legitimately return null and so seemed strange to mark @Nullable. Im not very attached to this though, so I could do the null thing instead, and mark it as @Nullable and update the javadocs to note that its not actually nullable and is only for backwards compatibility and explain the implications.
There was a problem hiding this comment.
which since you're the 2nd person to suggest it, couple with the fact that i initially considered doing it that way, maybe it would be better?
Adds a default implementation of getQueryContext, which was added to the Query interface in apache#12396. Query is marked with @ExtensionPoint, and lately we have been trying to be less volatile on these interfaces by providing default implementations to be more chill for extension writers. The way this default implementation is done in this PR is a bit strange due to the way that getQueryContext is used (mutated with system default and system generated keys); the default implementation has a specific object that it returns, and I added another temporary default method isLegacyContext that checks if the getQueryContext returns that object or not. If not, callers fall back to using getContext and withOverriddenContext to set these default and system values. I am open to other ideas as well, but this way should work at least without exploding, and added some tests to ensure that it is wired up correctly for QueryLifecycle, including the context authorization stuff. The added test shows the strange behavior if query context authorization is enabled, mainly that the system default and system generated query context keys also need to be granted as permissions for things to function correctly. This is not great, so I mentioned it in the javadocs as well. Not sure if it needs to be called out anywhere else.
Adds a default implementation of getQueryContext, which was added to the Query interface in #12396. Query is marked with @ExtensionPoint, and lately we have been trying to be less volatile on these interfaces by providing default implementations to be more chill for extension writers. The way this default implementation is done in this PR is a bit strange due to the way that getQueryContext is used (mutated with system default and system generated keys); the default implementation has a specific object that it returns, and I added another temporary default method isLegacyContext that checks if the getQueryContext returns that object or not. If not, callers fall back to using getContext and withOverriddenContext to set these default and system values. I am open to other ideas as well, but this way should work at least without exploding, and added some tests to ensure that it is wired up correctly for QueryLifecycle, including the context authorization stuff. The added test shows the strange behavior if query context authorization is enabled, mainly that the system default and system generated query context keys also need to be granted as permissions for things to function correctly. This is not great, so I mentioned it in the javadocs as well. Not sure if it needs to be called out anywhere else. Co-authored-by: Clint Wylie <cwylie@apache.org>
Adds a default implementation of
getQueryContext, which was added to theQueryinterface in #12396.Queryis marked with@ExtensionPoint, and lately we have been trying to be less volatile on these interfaces by providing default implementations to be more chill for extension writers.The way this default implementation is done in this PR is a bit strange due to the way that
getQueryContextis used (mutated with system default and system generated keys); the default implementation has a specific object that it returns, and I added another temporary default methodisLegacyContextthat checks if thegetQueryContextreturns that object or not. If not, callers fall back to usinggetContextandwithOverriddenContextto set these default and system values.I am open to other ideas as well, but this way should work at least without exploding, and added some tests to ensure that it is wired up correctly for
QueryLifecycle, including the context authorization stuff.The added test shows the strange behavior if query context authorization is enabled, mainly that the system default and system generated query context keys also need to be granted as permissions for things to function correctly. This is not great, so I mentioned it in the javadocs as well. Not sure if it needs to be called out anywhere else.