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

HIVE-28620: Query result is cached in case of IOWD if the subquery is not trivial #5537

Merged
merged 6 commits into from
Nov 13, 2024

Conversation

abstractdog
Copy link
Contributor

@abstractdog abstractdog commented Nov 12, 2024

What changes were proposed in this pull request?

Pass the root QB object to different operator tree generation paths. Behavior change is not expected because the root QB is only used in getDestinationFilePath with this patch.

Why are the changes needed?

To reach flags that were set on the root QB and apply the whole query. Otherwise, a lot of bad things can happen, details in jira.

Does this PR introduce any user-facing change?

No.

Is the change a dependency upgrade?

No.

How was this patch tested?

Tested on cluster, unit test added.
The patch is uploaded in 2 commits (will be squashed of course), the first commit contains the unit test case which fails without the fix, which is in the second commit.

@deniskuzZ
Copy link
Member

deniskuzZ commented Nov 12, 2024

It seems to me that this could be done with fewer code changes, however, I could be completely wrong, but to be safe I think we should ask review from @kasakrisz
can't we pass the needed flags from the rootQB to qb?

@abstractdog
Copy link
Contributor Author

abstractdog commented Nov 12, 2024

It seems to me that this could be done with fewer code changes, however, I could be completely wrong, but to be safe I think we should ask review from @kasakrisz can't we pass the needed flags from the rootQB to qb?

I was thinking about the same
there are flags that should not change across the different levels, like the one that this patch is about: isInsertOverwriteDir
if it's set once, it applies to the whole query theoretically: there is no such thing as "some query blocks suggest that the query is IOWD, while others don't"
how to implement this properly in this SemanticAnalyzer monster...is a completely different question :D open to ideas

I believe the worst thing that's currently happening is this:


a field variable is changed while running a recursive method, with all due respect, but without knowing the context, this looks awful :(
however, I wasn't brave enough to touch it for the sake of this fix

@abstractdog
Copy link
Contributor Author

It seems to me that this could be done with fewer code changes, however, I could be completely wrong, but to be safe I think we should ask review from @kasakrisz can't we pass the needed flags from the rootQB to qb?

I was thinking about the same there are flags that should not change across the different levels, like the one that this patch is about: isInsertOverwriteDir if it's set once, it applies to the whole query theoretically: there is no such thing as "some query blocks suggest that the query is IOWD, while others don't" how to implement this properly in this SemanticAnalyzer monster...is a completely different question :D open to ideas

I believe the worst thing that's currently happening is this:

a field variable is changed while running a recursive method, with all due respect, but without knowing the context, this looks awful :(
however, I wasn't brave enough to touch it for the sake of this fix

wait, maybe I have to revise what I said

      Operator<?> operator = genPlan(qb, qbexpr);

looks like the original qb is passed to the method, so I can reuse it, let me try :D

@abstractdog
Copy link
Contributor Author

abstractdog commented Nov 12, 2024

pushed 392c9b9
thanks for the good catch @deniskuzZ , looks like almost all the signature changes were unnecessary, except where the actual issue happened: getDestinationFilePath, where this.qb was silently used
I also changed qb param to qbParam in genPlan, it's dangerous that a param can hide the field in java, especially in this context

new test case passed with the latest change

}
}

// if any filters are present in the join tree, push them on top of the
// table
pushJoinFilters(qb, qb.getQbJoinTree(), aliasToOpInfo);
srcOpInfo = genJoinPlan(qb, aliasToOpInfo);
pushJoinFilters(qpParam, qpParam.getQbJoinTree(), aliasToOpInfo);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Passing qpParam.getQbJoinTree() is not necessary if qpParam is also passed.

@deniskuzZ
Copy link
Member

sonar reported number of new findings

@abstractdog
Copy link
Contributor Author

sonar reported number of new findings

checked, most of them are not introduced now, I was only able to fix one exception in the unit test

Copy link

sonarcloud bot commented Nov 13, 2024

@abstractdog
Copy link
Contributor Author

is this ready for a +1 guys? :)

@abstractdog abstractdog merged commit 3482c0b into apache:master Nov 13, 2024
6 checks passed
Copy link
Member

@deniskuzZ deniskuzZ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM +1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants