-
Notifications
You must be signed in to change notification settings - Fork 28.5k
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
[SPARK-21092][SQL] Wire SQLConf in logical plan and expressions #18299
Conversation
cc @wzhfy for review / CBO cc @sameeragarwal this is what we discussed. |
Test build #78036 has finished for PR 18299 at commit
|
Test build #78038 has finished for PR 18299 at commit
|
Since we have a thread local variable in |
The issue is that SparkSession might change the way they are wired and it's not always the case that when we create a new thread, we set the thread local conf. |
.union(constructIsNotNullConstraints(validConstraints)) | ||
.filter { c => | ||
c.references.nonEmpty && c.references.subsetOf(outputSet) && c.deterministic | ||
} |
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.
should we also bound their size as you suggested?
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.
That belongs in a separate patch.
Got it, thanks. |
assert(aliasedRelation.analyze.constraints.nonEmpty) | ||
|
||
SQLConf.get.setConf(SQLConf.CONSTRAINT_PROPAGATION_ENABLED, false) | ||
assert(aliasedRelation.analyze.constraints.isEmpty) |
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.
unset the config in the end
LGTM except one minor comment. |
Test build #78068 has finished for PR 18299 at commit
|
Test build #78070 has finished for PR 18299 at commit
|
Test build #78071 has finished for PR 18299 at commit
|
Test build #78077 has finished for PR 18299 at commit
|
Merging in master. |
@@ -87,6 +87,11 @@ class SparkSession private( | |||
|
|||
sparkContext.assertNotStopped() | |||
|
|||
// If there is no active SparkSession, uses the default SQL conf. Otherwise, use the session's. | |||
SQLConf.setSQLConfGetter(() => { | |||
SparkSession.getActiveSession.map(_.sessionState.conf).getOrElse(SQLConf.getFallbackConf) |
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.
shall we move this to SparkSession.Builder.getOrCreate
?
## What changes were proposed in this pull request? It is really painful to not have configs in logical plan and expressions. We had to add all sorts of hacks (e.g. pass SQLConf explicitly in functions). This patch exposes SQLConf in logical plan, using a thread local variable and a getter closure that's set once there is an active SparkSession. The implementation is a bit of a hack, since we didn't anticipate this need in the beginning (config was only exposed in physical plan). The implementation is described in `SQLConf.get`. In terms of future work, we should follow up to clean up CBO (remove the need for passing in config). ## How was this patch tested? Updated relevant tests for constraint propagation. Author: Reynold Xin <[email protected]> Closes apache#18299 from rxin/SPARK-21092.
… conf in LogicalPlan ## What changes were proposed in this pull request? After wiring `SQLConf` in logical plan ([PR 18299](apache#18299)), we can remove the need of passing `conf` into `def stats` and `def computeStats`. ## How was this patch tested? Covered by existing tests, plus some modified existing tests. Author: wangzhenhua <[email protected]> Author: Zhenhua Wang <[email protected]> Closes apache#18391 from wzhfy/removeConf.
… conf in LogicalPlan ## What changes were proposed in this pull request? After wiring `SQLConf` in logical plan ([PR 18299](apache#18299)), we can remove the need of passing `conf` into `def stats` and `def computeStats`. ## How was this patch tested? Covered by existing tests, plus some modified existing tests. Author: wangzhenhua <[email protected]> Author: Zhenhua Wang <[email protected]> Closes apache#18391 from wzhfy/removeConf.
It is really painful to not have configs in logical plan and expressions. We had to add all sorts of hacks (e.g. pass SQLConf explicitly in functions). This patch exposes SQLConf in logical plan, using a thread local variable and a getter closure that's set once there is an active SparkSession. The implementation is a bit of a hack, since we didn't anticipate this need in the beginning (config was only exposed in physical plan). The implementation is described in `SQLConf.get`. In terms of future work, we should follow up to clean up CBO (remove the need for passing in config). Updated relevant tests for constraint propagation. Author: Reynold Xin <[email protected]> Closes apache#18299 from rxin/SPARK-21092.
What changes were proposed in this pull request?
It is really painful to not have configs in logical plan and expressions. We had to add all sorts of hacks (e.g. pass SQLConf explicitly in functions). This patch exposes SQLConf in logical plan, using a thread local variable and a getter closure that's set once there is an active SparkSession.
The implementation is a bit of a hack, since we didn't anticipate this need in the beginning (config was only exposed in physical plan). The implementation is described in
SQLConf.get
.In terms of future work, we should follow up to clean up CBO (remove the need for passing in config).
How was this patch tested?
Updated relevant tests for constraint propagation.