Skip to content

Conversation

@maropu
Copy link
Member

@maropu maropu commented Sep 11, 2020

What changes were proposed in this pull request?

This PR intends to set CODEGEN_ONLY at CODEGEN_FACTORY_MODE in test spark context so that tests can fail if errors happen when generating expr code.

Why are the changes needed?

I noticed that the code generation of SafeProjection failed in the existing test (https://issues.apache.org/jira/browse/SPARK-32828) but it passed because FALLBACK was set at CODEGEN_FACTORY_MODE (by default) in SharedSparkSession. To get aware of these failures quickly, I think its worth setting CODEGEN_ONLY at CODEGEN_FACTORY_MODE.

Does this PR introduce any user-facing change?

No.

How was this patch tested?

Existing tests.

@SparkQA
Copy link

SparkQA commented Sep 11, 2020

Test build #128547 has finished for PR 29721 at commit 8b9b5e4.

  • This patch fails due to an unknown error code, -9.
  • This patch merges cleanly.
  • This patch adds the following public classes (experimental):
  • case class FailedCodegenExpr(child: Expression) extends UnaryExpression with CodegenFallback

@SparkQA
Copy link

SparkQA commented Sep 11, 2020

Test build #128555 has finished for PR 29721 at commit 0484de4.

  • This patch fails due to an unknown error code, -9.
  • This patch merges cleanly.
  • This patch adds no public classes.

@maropu
Copy link
Member Author

maropu commented Sep 11, 2020

GA passed. cc: @cloud-fan @viirya

private lazy val proj = FailedCodegenProjection.createObject(child :: Nil)
override def dataType: DataType = LongType
override def eval(input: InternalRow): Any = {
proj(input).getLong(0)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test proves that if eval fails, the query fails. I think we should override doCodeGen and produce invalid code there?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test proves that, if the codegen of proj fails, the query fails. If CODEGEN_FACTORY_MODE=fallback, proj falls back into an interpreted one.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then shall we just add a test in CodeGeneratorWithInterpretedFallbackSuite, to make sure that FailedCodegenProjection fails with default codegen mode?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My point is that, the test here is not really an end-to-end test. It's just used to trigger FailedCodegenProjection

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's just used to trigger FailedCodegenProjection

Yea, yes. This test just triggers the the codegen failure of FailedCodegenProjection in executor sides and it checks the failure correctly propagates to a driver side in SharedSparkSession by setting the config CODEGEN_FACTORY_MODE=codegen_only in SparkConf:
https://github.com/apache/spark/pull/29721/files#diff-ef6933b96996929c402e3a36296b2590R71

CodeGeneratorWithInterpretedFallbackSuite is placed in the catalyst package, so it is not related to adding the config in SharedSparkSession. But, if the existing tests in CodeGeneratorWithInterpretedFallbackSuite look enough, I think it is okay to drop the added tests and just add the config CODEGEN_FACTORY_MODE in SharedSparkSession.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea I think it's OK to just change the config in test.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay ~

@maropu maropu changed the title [SPARK-32851][SQL][TEST] Tests should fail if errors happen when generating expr code [SPARK-32851][SQL][TEST] Tests should fail if errors happen when generating projection code Sep 11, 2020
This reverts commit 0484de4.
This reverts commit 8b9b5e4.
@SparkQA
Copy link

SparkQA commented Sep 11, 2020

Test build #128571 has finished for PR 29721 at commit a0b69cf.

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

@maropu maropu closed this in 4269c2c Sep 11, 2020
@maropu
Copy link
Member Author

maropu commented Sep 11, 2020

Thanks! Merged to master.

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.

5 participants