-
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
HHH-15133 - Use specified result-type to better infer "shape" of query results with implicit selections #4890
Conversation
…y results with implicit selections
2 things of note:
|
Oh nice! Thanks! |
Another case where I cannot reproduce these failures locally. Locally, the entire build passes with H2 specifically |
Hm, actually I must have been on the wrong branch. I am able to reproduce it. Though as of yet I have no explanation why. The only thing I can think of is that my change somehow messed up the I'll look further next week. |
So this is actually an interesting discussion. Consider this (the failing) query:
This comes from documentation. The outcome is wrong even though the test actually passed. The reason it is wrong is that an
Basically, this was never supported in 6.0 at the moment. My work here actually does add support for it. So within this PR, accessing that first row as above is fine. However the test now fails because there is currently a mismatch in terms of trying to ascertain whether the row is "duplicate". The query selects Most likely, the correct solution is to use the Essentially, what is the correct outcome here considering an array per-row is being returned in terms of how we check for duplicates? I think the "the filtered result" assertion in the test (the number of results) is correct; it just did not properly check previously for what is actually returned. What say y'all? Everyone agree with that? [1] There is a distinction between the "result type" as determined strictly based on the query compared to the "expected return type" specified when creating the |
Ultimately this is the code block where this breaks down (
The only time we perform "unique-ing" is when a single entity is selected. |
IMO when |
That does not feel strange to you? Sure feels strange to me. |
yeap it looks strange to me! |
Strange because (1) you think we shouldn't de-duplicate single |
Strange because the same query will return different number of results based on whether I select the entity or its identifier e.g.
Since I added it, yes I am aware ;) |
Are you suggesting to remove the by default de-duplication for single entity select queries or to change to de-duplicating every single select item query? |
I'm questioning whether I want to make these consistent. I like to think of telling a user about this and how easy it is to explain a feature. Not sure this is easy to explain/understand. Let's talk about it tomorrow when we meet up |
…y results with implicit selections
Function<String, SqmStatement<?>> creator) { | ||
log.tracef( "QueryPlan#resolveHqlInterpretation( `%s` )", queryString ); | ||
final StatisticsImplementor statistics = statisticsSupplier.get(); | ||
final boolean stats = statistics.isStatisticsEnabled(); | ||
final long startTime = ( stats ) ? System.nanoTime() : 0L; | ||
|
||
final String cacheKey; | ||
if ( expectedResultType != null && expectedResultType.isArray() ) { | ||
cacheKey = queryString + "_array"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed, prepending "array_"
would be better to avoid possible collisions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other than the cache key determination I think this looks good
@sebersole I think what you're seeing is fine and perfectly consistent, as long as this in-memory dupe removal is only done to counteract the effect of a OTOH, if dupe removal ever happens for anything other than a fetch join, I think we're really in trouble here. (But I don't think it does.) |
It technically does it for all entity results, regardless of whether there are collection join fetches which is of course the only kind of join fetch we care about here. So here's the question then... Changing this up causes a lot of test-suite failures. Which at this point will affect early adopters of 6.0. As a case-in-point, I'll work on a version of this that only does de-dup with entity results with collection join fetches. I won't change any tests. Then we can see the impact |
OK, perfect. |
…y results with implicit selections
So this PR is finished as far as the outlined behavior. See I'll start on the other promised one shortly. I plan on releasing 6.0 Final tomorrow, so let's get this sorted. Final was supposed to be today, so not stopping that train again. |
Here you go - #4924 |
public void setDeDuplicationEnabled(boolean enabled) { | ||
this.deDupEnabled = enabled; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
who is calling this method?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At the moment, no one; so we could drop it.
I added that as part of initial work for supporting https://hibernate.atlassian.net/browse/HHH-15149. But decided to delay that work until after 6.0 Final to better percolate.
HHH-15133 - Use specified result-type to better infer "shape" of query results with implicit selections
https://hibernate.atlassian.net/browse/HHH-15133