Skip to content

Conversation

@dongjoon-hyun
Copy link
Member

@dongjoon-hyun dongjoon-hyun commented Mar 6, 2021

What changes were proposed in this pull request?

This PR aims to add testFallback function to PlanTest.

  • This PR is created for branch-3.1 because it is broken for now. However, all relevant patches are in master and branch-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.FALLBACK mode while PlanTest doesn't support it because it always overrides the test case and run twice with CODEGEN_ONLY and NO_CODEGEN.

Does this PR introduce any user-facing change?

No.

How was this patch tested?

Pass the CIs.

@dongjoon-hyun
Copy link
Member Author

dongjoon-hyun commented Mar 6, 2021

cc @cloud-fan , @rednaxelafx , @maropu and @viirya

@kiszk
Copy link
Member

kiszk commented Mar 6, 2021

Thank you for creating a WIP. Could you please clarify "make two more PRs"?

@rednaxelafx
Copy link
Contributor

Thank you very much for helping with the follow-up on this @dongjoon-hyun ! Really appreciate it!
Your proposed fix here look nice.

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)...

@SparkQA
Copy link

SparkQA commented Mar 6, 2021

Test build #135824 has finished for PR 31764 at commit 1a5a015.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA
Copy link

SparkQA commented Mar 6, 2021

Kubernetes integration test starting
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/40406/

@SparkQA
Copy link

SparkQA commented Mar 6, 2021

Kubernetes integration test status success
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/40406/

@dongjoon-hyun
Copy link
Member Author

Thank you, @kiszk and @rednaxelafx .

To @kiszk . I need to make the same PR to master and branch-3.1 in order to pass the CI.

Thank you for creating a WIP. Could you please clarify "make two more PRs"?

@kiszk
Copy link
Member

kiszk commented Mar 6, 2021

Thanks. I see. One for master. One for branch-3.1.

@dongjoon-hyun dongjoon-hyun changed the title [WIP] Use fallback [SPARK-34596][SQL][FOLLOWUP][TESTS] Add testFallback to PlanTest and use it properly Mar 6, 2021
@dongjoon-hyun dongjoon-hyun changed the title [SPARK-34596][SQL][FOLLOWUP][TESTS] Add testFallback to PlanTest and use it properly [SPARK-34596][SPARK-34607][SQL][FOLLOWUP][TESTS] Add testFallback to PlanTest and use it properly Mar 6, 2021
@dongjoon-hyun dongjoon-hyun changed the title [SPARK-34596][SPARK-34607][SQL][FOLLOWUP][TESTS] Add testFallback to PlanTest and use it properly [SPARK-34596][SPARK-34607][SQL][FOLLOWUP][TESTS] Add testFallback to PlanTest and use it Mar 6, 2021
@dongjoon-hyun dongjoon-hyun changed the title [SPARK-34596][SPARK-34607][SQL][FOLLOWUP][TESTS] Add testFallback to PlanTest and use it [SPARK-34596][SPARK-34607][SQL][FOLLOWUP][TESTS] Add PlanTest. testFallback and use it Mar 6, 2021
@dongjoon-hyun dongjoon-hyun marked this pull request as ready for review March 6, 2021 17:56
@SparkQA
Copy link

SparkQA commented Mar 6, 2021

Kubernetes integration test starting
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/40415/

@viirya
Copy link
Member

viirya commented Mar 6, 2021

This is WIP because the tests still fail even in Fallback mode.

This is not anymore?

@SparkQA
Copy link

SparkQA commented Mar 6, 2021

Kubernetes integration test status success
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/40415/

@dongjoon-hyun
Copy link
Member Author

Yes, this is ready for review, @viirya .

@dongjoon-hyun dongjoon-hyun changed the title [SPARK-34596][SPARK-34607][SQL][FOLLOWUP][TESTS] Add PlanTest. testFallback and use it [SPARK-34596][SPARK-34607][SQL][FOLLOWUP][TESTS][3.1] Add PlanTest. testFallback and use it Mar 6, 2021
Comment on lines +59 to +61
withSQLConf(SQLConf.CODEGEN_FACTORY_MODE.key -> codegenMode) {
super.test(testName, testTags: _*)(testFun)(pos)
}
Copy link
Member

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.

Copy link
Member Author

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.

Copy link
Member Author

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?

Copy link
Member Author

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.

Copy link
Member Author

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~

Copy link
Member

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.

Copy link
Member Author

@dongjoon-hyun dongjoon-hyun Mar 7, 2021

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.

Copy link
Member

@viirya viirya Mar 7, 2021

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.

Copy link
Member Author

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?

@dongjoon-hyun
Copy link
Member Author

@SparkQA
Copy link

SparkQA commented Mar 6, 2021

Test build #135833 has finished for PR 31764 at commit ed5c3c0.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.


test("ANSI mode: cast string to timestamp with parse error") {
val activeConf = conf
val activeConf = conf.clone()
Copy link
Contributor

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?

Copy link
Member

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.

Copy link
Member

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?

Copy link
Member

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(
Copy link
Contributor

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...

Copy link
Member

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)
Copy link
Member

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)
Copy link
Member

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)

@dongjoon-hyun
Copy link
Member Author

Hi, All.

Currently, this PR is related two stuff.

  1. testFallback is designed to clarify the goal of test case.
  2. Recovering branch-3.1.

For (2), it seems that I found another solution. I'll make another PR for that.

@dongjoon-hyun
Copy link
Member Author

@kiszk
Copy link
Member

kiszk commented Mar 8, 2021

@dongjoon-hyun Should we move #31775 for branch-3.1? Then, will you close this PR?

@dongjoon-hyun
Copy link
Member Author

dongjoon-hyun commented Mar 8, 2021

No~, @kiszk . testFallback is required for the two test cases of SPARK-34596 and SPARK34607 because we had better explicitly use testFallback for those test case whose behavior is not runnable in both modes.

I believe this is a kind of refactoring of PlanTest to clarify the purpose and intention of the test cases.

@kiszk
Copy link
Member

kiszk commented Mar 8, 2021

I see.

@dongjoon-hyun
Copy link
Member Author

Anyway, I'll make this as a draft for now.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants