Skip to content

Conversation

@LantaoJin
Copy link
Contributor

What changes were proposed in this pull request?

Add a new test suite CTEHintSuite

Why are the changes needed?

This ticket is to address the below comments to help us understand the test coverage of SQL HINT for CTE.
#29062 (comment)
#29062 (comment)

Does this PR introduce any user-facing change?

No

How was this patch tested?

Add a test suite.

@SparkQA
Copy link

SparkQA commented Aug 5, 2020

Test build #127092 has finished for PR 29359 at commit 773eacd.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds the following public classes (experimental):
  • class CTEHintSuite extends PlanTest with SharedSparkSession with AdaptiveSparkPlanHelper

@LantaoJin
Copy link
Contributor Author

cc @gatorsmile @cloud-fan

import org.apache.log4j.Level

import org.apache.spark.sql.catalyst.plans.PlanTest
import org.apache.spark.sql.catalyst.plans.logical.{BROADCAST, HintInfo, Join, JoinHint, Repartition, RepartitionByExpression, ResolvedHint, SHUFFLE_HASH, SHUFFLE_MERGE, SHUFFLE_REPLICATE_NL}
Copy link
Member

Choose a reason for hiding this comment

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

nit: I think its okay to fold it: import org.apache.spark.sql.catalyst.plans.logical._

import org.apache.spark.sql.execution.adaptive.AdaptiveSparkPlanHelper
import org.apache.spark.sql.test.SharedSparkSession

class CTEHintSuite extends PlanTest with SharedSparkSession with AdaptiveSparkPlanHelper {
Copy link
Member

Choose a reason for hiding this comment

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

we need AdaptiveSparkPlanHelper?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will remove it. I just copy it from JoinHintSuite :P

@SparkQA
Copy link

SparkQA commented Aug 6, 2020

Test build #127134 has finished for PR 29359 at commit 6f8a2cc.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds the following public classes (experimental):
  • class CTEHintSuite extends PlanTest with SharedSparkSession

@SparkQA
Copy link

SparkQA commented Aug 6, 2020

Test build #127135 has finished for PR 29359 at commit ce94127.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds the following public classes (experimental):
  • class CTEHintSuite extends QueryTest with SharedSparkSession


class CTEHintSuite extends QueryTest with SharedSparkSession {

def verifyCoalesceHint(df: DataFrame): Unit = {
Copy link
Member

Choose a reason for hiding this comment

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

nit: Coalesce -> Repartition?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ResolveCoalesceHints accepts names "COALESCE", "REPARTITION", and "REPARTITION_BY_RANGE".

class ResolveCoalesceHints(conf: SQLConf) extends Rule[LogicalPlan] {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed to def verifyCoalesceOrRepartitionHint

val repartitions = plan collect {
case r: Repartition => r
case r: RepartitionByExpression => r
case _: ResolvedHint => fail("ResolvedHint should not appear after optimize.")
Copy link
Member

Choose a reason for hiding this comment

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

Is this error message correct even if the test is for an analyzed plan? https://github.com/apache/spark/pull/29359/files#diff-0d893e4fe9a621d3e084c2913c533e00R38

sql(s"""
|WITH cte AS (SELECT /*+ REPARTITION(3) */ * FROM t)
|SELECT * FROM cte
""".stripMargin),
Copy link
Member

Choose a reason for hiding this comment

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

nit format:

      checkAnswer(
        sql(
          s"""
             |WITH cte AS (SELECT /*+ REPARTITION(3) */ * FROM t)
             |SELECT * FROM cte
             |""".stripMargin),
        Row(1) :: Nil)

@SparkQA
Copy link

SparkQA commented Aug 7, 2020

Test build #127176 has finished for PR 29359 at commit 4256339.

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

@LantaoJin
Copy link
Contributor Author

retest this please

@SparkQA
Copy link

SparkQA commented Aug 7, 2020

Test build #127187 has finished for PR 29359 at commit 4256339.

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

}
}

test("SPARK-32237: Hint in CTE") {
Copy link
Contributor

Choose a reason for hiding this comment

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

Actually we can remove it now. It's already covered by Resolve coalesce hint in CTE.

@SparkQA
Copy link

SparkQA commented Aug 10, 2020

Test build #127251 has finished for PR 29359 at commit a7c4d32.

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

@cloud-fan
Copy link
Contributor

github action passed, merging to master, thanks!

@cloud-fan cloud-fan closed this in f80a480 Aug 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants