-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-34596][SPARK-34607][SQL][FOLLOWUP][TESTS][3.1] Add PlanTest. testFallback and use it
#31764
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
|
cc @cloud-fan , @rednaxelafx , @maropu and @viirya |
|
Thank you for creating a WIP. Could you please clarify "make two more PRs"? |
|
Thank you very much for helping with the follow-up on this @dongjoon-hyun ! Really appreciate it! I've been debugging this on my side as well. There's gotta be something screwing up with the failure (or the lack of failure on master/3.0)... |
|
Test build #135824 has finished for PR 31764 at commit
|
|
Kubernetes integration test starting |
|
Kubernetes integration test status success |
|
Thank you, @kiszk and @rednaxelafx . To @kiszk . I need to make the same PR to
|
|
Thanks. I see. One for |
testFallback to PlanTest and use it properly
testFallback to PlanTest and use it properlytestFallback to PlanTest and use it properly
testFallback to PlanTest and use it properlytestFallback to PlanTest and use it
testFallback to PlanTest and use itPlanTest. testFallback and use it
|
Kubernetes integration test starting |
This is not anymore? |
|
Kubernetes integration test status success |
|
Yes, this is ready for review, @viirya . |
PlanTest. testFallback and use itPlanTest. testFallback and use it
| withSQLConf(SQLConf.CODEGEN_FACTORY_MODE.key -> codegenMode) { | ||
| super.test(testName, testTags: _*)(testFun)(pos) | ||
| } |
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.
Maybe we should run twice, one for FALLBACK and one for NO_CODEGEN.
FALLBACK will run codegen path first and fallback to interpreted mode if codegen fails. So interpreted mode may not run if codegen mode successes.
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 sounds like another use case. Technically, this testFallback is designed to the default mode of this configuration (which is the default of Apache Spark runtime in non-testing mode) instead of a specific mode interpreted mode or codeine.
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.
Maybe, do you want to add testCodegenFail?
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.
Hmm. At the second thought, I understand what was your suggestion. So, your suggestion is to check the occurrence of fallback, right? Then, it makes sense.
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'll update my PR in this afternoon~
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.
test runs the test code twice, one for codegen and one for interpreted. It is for test coverage.
If testFallback only runs for fallback mode, then it might only runs codegen and skips interpreted mode if codegen successes. So the test coverage is less, I think.
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.
Hi, @viirya . I tried to revise, but it seems strange to me.
test runs the test code twice, one for codegen and one for interpreted. It is for test coverage.
If testFallback only runs for fallback mode, then it might only runs codegen and skips interpreted mode if codegen successes. So the test coverage is less, I think.
testFallback is not aiming to replace test in line 41. Instead, testFallback is added because PlanTest bans all derived classes from testing FALLBACK mode. Before this PR, there is no way to test FALLBACK mode.
As we know, CODEGEN_FACTORY_MODE has three modes: FALLBACK, CODEGEN_ONLY, NO_CODEGEN.
As we guess in the name, testFallback, this test is specifically for FALLBACK mode and is added for some test cases which works only at FALLBACK mode as @rednaxelafx described.
So, testFallback doesn't aim to mean (1) CODEGEN_ONLY should fails and (2) NO_CODEGEN should passed. If you want to test this (both (1) and (2)), we should make another test function like testCodegenFailNoCodegenPass.
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.
FALLBACK mode is not a special path other than codegen and interpreted path. Under FALLBACK mode, Spark runs first codegen path and then interpreted path if codegen fails.
So it sounds weird that some test cases works only at FALLBACK mode, so we only need to run it with FALLBACK mode. Doesn't it just mean the test cases may fail under codegen but can success under interpreted?
Wrapping the test function with FALLBACK config, means we may only run the test in codegen path, if codegen path successes. It skips interpreted path in the case.
So, it may unintentionally avoid the test coverage of interpreted path. That means, if we use testFallback, it might only test codegen path if codegen path successes. Interpreted path will not be tested for the case.
The current testFallback only makes sense if we only want to make sure the test case works, no matter it is codegen or interpreted mode. If this is the purpose, then it is fine.
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.
Hi, @viirya . It seems that you missed @rednaxelafx 's comment, #31709 (comment) .
So it sounds weird that some test cases works only at FALLBACK mode, so we only need to run it with FALLBACK mode. Doesn't it just mean the test cases may fail under codegen but can success under interpreted?
|
I created a PR for master branch. |
|
Test build #135833 has finished for PR 31764 at commit
|
|
|
||
| test("ANSI mode: cast string to timestamp with parse error") { | ||
| val activeConf = conf | ||
| val activeConf = conf.clone() |
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 we have to clone the conf here?
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.
agree, I thought that this was a tentative workaround.
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.
@dongjoon-hyun Can #31775 allow us to revert this?
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 so.
| } | ||
| } | ||
|
|
||
| protected def testFallback( |
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 current test framework assumes that codegen and non-codegen should have consistent behaviors, while this codegen bug breaks the assumption. The test case fails with codegen but passes with non-codegen.
+1 to add this for such test cases. One thing I'm curious about is why this test works in master...
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 to add it, too.
| testTags: Tag*)(testFun: => Any)(implicit pos: source.Position): Unit = { | ||
| val codegenMode = CodegenObjectFactoryMode.FALLBACK.toString | ||
| withSQLConf(SQLConf.CODEGEN_FACTORY_MODE.key -> codegenMode) { | ||
| super.test(testName, testTags: _*)(testFun)(pos) |
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.
nit: How about adding an additional message here, e.g., testName +" (codegen fallback mode)"?
| MalformedClassObject.MalformedNameExample(42), | ||
| "nested Scala class should work") | ||
| "nested Scala class should work", | ||
| useFallback = true) |
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.
How about leaving some comments here about why we need the fallback based on the Kris investigation? #31709 (comment)
|
Hi, All. Currently, this PR is related two stuff.
For (2), it seems that I found another solution. I'll make another PR for that. |
|
I made a PR for recovering branch-3.1. |
|
@dongjoon-hyun Should we move #31775 for branch-3.1? Then, will you close this PR? |
|
No~, @kiszk . I believe this is a kind of refactoring of |
|
I see. |
|
Anyway, I'll make this as a draft for now. |
What changes were proposed in this pull request?
This PR aims to add
testFallbackfunction toPlanTest.masterandbranch-3.0, too. So, after having a complete patch, I'll make two more PRs to master/branch-3.0.Why are the changes needed?
Some test cases only work in
CodegenObjectFactoryMode.FALLBACKmode whilePlanTestdoesn't support it because it always overrides the test case and run twice withCODEGEN_ONLYandNO_CODEGEN.Does this PR introduce any user-facing change?
No.
How was this patch tested?
Pass the CIs.