-
Notifications
You must be signed in to change notification settings - Fork 2.2k
[BugFix] Fix usage and record for changing warehouse in inline comment (backport #66677) #66734
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
Conversation
|
Cherry-pick of 04bebb8 has failed: To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally |
|
@mergify[bot]: Backport conflict, please reslove the conflict and resubmit the pr |
🧪 CI InsightsHere's what we observed from your CI run for 117bcbc. ✅ Passed Jobs With Interesting Signals
|
c2bba20 to
117bcbc
Compare
|
@cursor review |
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.
Why I'm doing:
For the inline comment
/*+SET_VAR(warehouse=wh2)*/, both the warehouse recorded in Query Detail and the warehouse actually used at runtime are incorrect.Warehouse recorded in Query Detail
addRunningQueryDetailis called first, and only later doesprocessQueryScopeHintparse the warehouse hint.addRunningQueryDetail, callprocessQueryScopeSetVarHintto update the session variables, and restore the original session variables at the end ofaddRunningQueryDetail.Warehouse actually used by the query
ConnectContext.computeResource. This is a cache that is only reset when a query finishes. At query start,computeResourcehas already cached the current session variable’s warehouse, so a later inlineSET_VARhint won’t refresh the cachedcomputeResource.SET_VARupdates session variables viasetSystemVariable, also updatecomputeResource, similar to howSetExecutorhandlesset warehouse = 'wh2'.What I'm doing:
Fixes #issue
What type of PR is this:
Does this PR entail a change in behavior?
If yes, please specify the type of change:
Checklist:
Bugfix cherry-pick branch check:
Note
Ensure changing
warehousevia inlineSET_VARor session variable resets compute resource and updates query detail, coordinator, and audit log.processQueryScopeHint, if the current warehouse changed, updateQueryDetail.warehouseand re-add running query detail.VariableMgr.setSystemVariable(...)now acceptsConnectContext; when settingwarehouse, invokehandleSetWarehouseto reset/ensure compute resource accordingly.handleSetWarehouseresets compute resource when warehouse changes; otherwise re-acquires for availability.setSystemVariablewithout context.set warehouse, assertingQueryDetail.warehouse, coordinator's compute resource, and audit event warehouse.SET warehousein shared-data mode.Written by Cursor Bugbot for commit 2b0ee90. This will update automatically on new commits. Configure here.
This is an automatic backport of pull request #66677 done by [Mergify](https://mergify.com).
Note
Processes inline SET_VAR hints prior to adding running query detail (with session var backup/restore), plus minor refactors in hint handling.
processQueryScopeSetVarHint()to apply query-scopeSET_VARhints by cloning and updatingSessionVariable.addRunningQueryDetail, callprocessQueryScopeSetVarHint()before buildingQueryDetail, then restore original session variables infinally.new ConcurrentHashMap<>(context.getUserVariables())when cloning user variables.@VisibleForTestingfromprocessQueryScopeHint.Written by Cursor Bugbot for commit 117bcbc. This will update automatically on new commits. Configure here.