-
Notifications
You must be signed in to change notification settings - Fork 28.3k
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-26262][SQL] Runs SQLQueryTestSuite on mixed config sets: WHOLESTAGE_CODEGEN_ENABLED and CODEGEN_FACTORY_MODE #23213
Conversation
Test build #99646 has finished for PR 23213 at commit
|
cc: @cloud-fan @mgaido91 |
} | ||
} | ||
|
||
test("optimized plan should show the rewritten aggregate expression") { |
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.
can we move them to ExplainSuite
?
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.
all the tests?
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.
all the explain related tests.
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.
ok
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.
Please update the PR description too.
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.
+1 for @viirya 's comment. We need to update the title and description of PR and JIRA.
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.
updated! Thanks, guys!
just a question, why didn't we introduce something like what was done in SPARK-24562? I see that these are configs which are valid for all queries, so using what was done in SPARK-24562 is not a good idea, but something similar (eg a file with all the config sets to use)? |
val codegenConfigSets = Array(CODEGEN_ONLY, NO_CODEGEN).map { | ||
case codegenFactoryMode => | ||
Array(SQLConf.CODEGEN_FACTORY_MODE.key -> codegenFactoryMode.toString) | ||
val codegenConfigSets = Array(("false", "NO_CODEGEN"), ("true", "CODEGEN_ONLY")).map { |
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 test all the combinations? e.g. wholeStage=on, codegen=off
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.
ok
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.
will this increase too much test time?
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.
I will check the time later, too.
yea, its similar, but I personally think its orthogonal to SPARK-24562. This pr only targets a default config set for codegen-only and interpreter mode tests. |
yes I agree. I am just asking if it makes sense to create a framework like that. Now it is only about codegen, but in the future we may want to add more configs. What do you think? |
We should create such a framework when we need to have per-file config settings for testing. |
3ef5e3e
to
0305a05
Compare
Test build #99661 has finished for PR 23213 at commit
|
Test build #99663 has finished for PR 23213 at commit
|
Test build #99662 has finished for PR 23213 at commit
|
// plan should show the rewritten aggregate expression. | ||
val df = sql("SELECT k, every(v), some(v), any(v) FROM test_agg GROUP BY k") | ||
checkKeywordsExistsInExplain(df, | ||
"Aggregate [k#x], [k#x, min(v#x) AS every(v)#x, max(v#x) AS some(v)#x, " + |
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.
Since extended=false
in line 33, the test suite only compares with Physical Plan. Maybe, did you change line 33 in your codebase?
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.
The other two failures fail with the same reason.
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.
yea, you're right... I forgot to set true at extended in explain...
Test build #99692 has finished for PR 23213 at commit
|
do you know how long |
I'm looking into that now ;) Just give me more time to check. |
yea, it seemed it was longer by ~4 times;
|
that's a lot of time... Can we think more about the combination of codegen and wholeStage? When we turn on whole stage codegen but turn off codegen, what will happen? |
Sorry, my bad; it was longer than the current master by ~2 times. That's because the current master has already run two config set patterns ( IMHO two config set patterns below could cover most code paths in Spark?
In this case, there is little change in the test time;
WDYT? |
Yes, I am wondering too: which is the difference between: |
how about |
yea, I think they're not totally the same..., but I'm not sure that the test run ( |
But whole stage codegen will not test |
If we look at test coverage, |
Test build #99750 has finished for PR 23213 at commit
|
retest this please |
Test build #99756 has finished for PR 23213 at commit
|
Retest this please. |
@maropu I'd say so, but I am still not sure what (if there is one) is the difference between |
Test build #99762 has finished for PR 23213 at commit
|
these 3 combinations LGTM. |
Test build #99933 has finished for PR 23213 at commit
|
retest this please |
Test build #99942 has finished for PR 23213 at commit
|
Retest this please. |
Ah, I had the same question as #23213 (comment). It would be good to update PR description :-). |
when wholeStageCogen is on, there is no way to avoid codegen, so codegenFactoryMode doesn't make difference. |
I think wholeStageCodegen doesn't disallow using those objects in interpreted mode. The objects can be in interpreted mode if it rolls back from codegen in case of compilation error. |
Test build #99945 has finished for PR 23213 at commit
|
retest this please |
But the test coverage is the same, right? If wholeStageCodege falls back, we are testing the same thing as turning off wholeStageCodegen |
Isn't it possibly that wholeStageCodege doesn't falls back but codegen.factoryMode falls back, and vice verse? The falling back of factoryMode is happened at individual codegen generator. |
The definition of "fallback" is different in wholeStageCodegen. It's effectively turning off wholeStageCodegen. Depending on the |
// note: this is not a robust way to split queries using semicolon, but works for now. | ||
val queries = code.mkString("\n").split("(?<=[^\\\\]);").map(_.trim).filter(_ != "").toSeq | ||
|
||
// When we are regenerating the golden files, we don't need to set any config as they |
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.
I am not sure about this. Imagine a case which is failing without setting a config for instance: I think we should pick one config set (any is fine) instead.
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.
Imagine a case which is failing without setting a config for instance
We will check the result for all different configs, and test will fail, right?
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.
We will check the result for all different configs
For all different configs specified there doesn't mean without setting that config at all. For instance, let's imagine that we add a config for throwing an exception when a decimal overflows (with this behavior being the default): in the current tests, we can just add the config value to "do not throw an exception" for all the config sets which are present there. After this patch, that wouldn't work.
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.
Currently this test framework requires all the cases return the same result(without config and with any combination of configs). Did I miss something?
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.
I think only with any combination of configs is true, not without config.
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.
Do you know which test case leverages this feature? I'm a little surprised that we allow tests without configs have different behavior.
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.
no, I think there is none as of now (this feature is not widely adopted...), but I think it is a case which can happen in the future (as in the example above, which may really be a case if we go on with the creating of a SQL strict mode)
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.
If we do need to test the SQL strict mode, I think we need to adopt SPARK-24562 then.
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.
I mean in general, in the current condition, there is no way you can successfully run the tests if the default value of a config produces (for any reason) an output different from some other values and we want to test only the non-default values. It may not be a problem but I think anyway this is a limitation which we can easily avoid by adding here the SET
s for the first config set if any. So I see no reason why not to do that, which is safer IMHO.
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.
I think it's easier to reason about the test if we require it to always produce the same result without config and with any combination of configs.
If no tests depend on it, I'd like to not bother about it and keep it as it was. We already clear configs with generating result: https://github.com/apache/spark/pull/23213/files#diff-432455394ca50800d5de508861984ca5L157
Thanks for the kind answer @cloud-fan. Then yes, I am +1 for the 3 configs suggested in #23213 (comment). |
Test build #99959 has finished for PR 23213 at commit
|
Test build #99957 has finished for PR 23213 at commit
|
LGTM with the 3 configs in #23213 (comment). |
retest this please |
Test build #100313 has finished for PR 23213 at commit
|
thanks, merging to master! |
…STAGE_CODEGEN_ENABLED and CODEGEN_FACTORY_MODE ## What changes were proposed in this pull request? For better test coverage, this pr proposed to use the 4 mixed config sets of `WHOLESTAGE_CODEGEN_ENABLED` and `CODEGEN_FACTORY_MODE` when running `SQLQueryTestSuite`: 1. WHOLESTAGE_CODEGEN_ENABLED=true, CODEGEN_FACTORY_MODE=CODEGEN_ONLY 2. WHOLESTAGE_CODEGEN_ENABLED=false, CODEGEN_FACTORY_MODE=CODEGEN_ONLY 3. WHOLESTAGE_CODEGEN_ENABLED=true, CODEGEN_FACTORY_MODE=NO_CODEGEN 4. WHOLESTAGE_CODEGEN_ENABLED=false, CODEGEN_FACTORY_MODE=NO_CODEGEN This pr also moved some existing tests into `ExplainSuite` because explain output results are different between codegen and interpreter modes. ## How was this patch tested? Existing tests. Closes apache#23213 from maropu/InterpreterModeTest. Authored-by: Takeshi Yamamuro <yamamuro@apache.org> Signed-off-by: Wenchen Fan <wenchen@databricks.com>
…STAGE_CODEGEN_ENABLED and CODEGEN_FACTORY_MODE ## What changes were proposed in this pull request? For better test coverage, this pr proposed to use the 4 mixed config sets of `WHOLESTAGE_CODEGEN_ENABLED` and `CODEGEN_FACTORY_MODE` when running `SQLQueryTestSuite`: 1. WHOLESTAGE_CODEGEN_ENABLED=true, CODEGEN_FACTORY_MODE=CODEGEN_ONLY 2. WHOLESTAGE_CODEGEN_ENABLED=false, CODEGEN_FACTORY_MODE=CODEGEN_ONLY 3. WHOLESTAGE_CODEGEN_ENABLED=true, CODEGEN_FACTORY_MODE=NO_CODEGEN 4. WHOLESTAGE_CODEGEN_ENABLED=false, CODEGEN_FACTORY_MODE=NO_CODEGEN This pr also moved some existing tests into `ExplainSuite` because explain output results are different between codegen and interpreter modes. ## How was this patch tested? Existing tests. Closes apache#23213 from maropu/InterpreterModeTest. Authored-by: Takeshi Yamamuro <yamamuro@apache.org> Signed-off-by: Wenchen Fan <wenchen@databricks.com>
What changes were proposed in this pull request?
For better test coverage, this pr proposed to use the 4 mixed config sets of
WHOLESTAGE_CODEGEN_ENABLED
andCODEGEN_FACTORY_MODE
when runningSQLQueryTestSuite
:This pr also moved some existing tests into
ExplainSuite
because explain output results are different between codegen and interpreter modes.How was this patch tested?
Existing tests.