This repository was archived by the owner on Jun 14, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 116
[Gold Standard] Enable stats with spark 2.4 with a sample query #429
Open
apoorvedave1
wants to merge
2
commits into
microsoft:master
Choose a base branch
from
apoorvedave1:stats
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| SELECT | ||
| catalog_sales.cs_bill_customer_sk, | ||
| store_sales.ss_customer_sk | ||
| FROM catalog_sales, store_sales | ||
| WHERE catalog_sales.cs_sold_date_sk = store_sales.ss_sold_date_sk | ||
| LIMIT 100 |
14 changes: 14 additions & 0 deletions
14
src/test/resources/tpcds/spark-2.4/approved-plans-v1_4/q0/explain.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| == Physical Plan == | ||
| CollectLimit 100 | ||
| +- *(5) Project [cs_bill_customer_sk#1, ss_customer_sk#2] | ||
| +- *(5) SortMergeJoin [cs_sold_date_sk#3], [ss_sold_date_sk#4], Inner | ||
| :- *(2) Sort [cs_sold_date_sk#3 ASC NULLS FIRST], false, 0 | ||
| : +- Exchange hashpartitioning(cs_sold_date_sk#3, 200) | ||
| : +- *(1) Project [cs_sold_date_sk#3, cs_bill_customer_sk#1] | ||
| : +- *(1) Filter isnotnull(cs_sold_date_sk#3) | ||
| : +- *(1) FileScan parquet default.catalog_sales[cs_sold_date_sk#3,cs_bill_customer_sk#1] Batched: true, Format: Parquet, Location [not included in comparison]/{warehouse_dir}/catalog_sales], PartitionFilters: [], PushedFilters: [IsNotNull(cs_sold_date_sk)], ReadSchema: struct<cs_sold_date_sk:int,cs_bill_customer_sk:int> | ||
| +- *(4) Sort [ss_sold_date_sk#4 ASC NULLS FIRST], false, 0 | ||
| +- Exchange hashpartitioning(ss_sold_date_sk#4, 200) | ||
| +- *(3) Project [ss_sold_date_sk#4, ss_customer_sk#2] | ||
| +- *(3) Filter isnotnull(ss_sold_date_sk#4) | ||
| +- *(3) FileScan parquet default.store_sales[ss_sold_date_sk#4,ss_customer_sk#2] Batched: true, Format: Parquet, Location [not included in comparison]/{warehouse_dir}/store_sales], PartitionFilters: [], PushedFilters: [IsNotNull(ss_sold_date_sk)], ReadSchema: struct<ss_sold_date_sk:int,ss_customer_sk:int> | ||
22 changes: 22 additions & 0 deletions
22
src/test/resources/tpcds/spark-2.4/approved-plans-v1_4/q0/simplified.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| CollectLimit | ||
| WholeStageCodegen | ||
| Project [cs_bill_customer_sk,ss_customer_sk] | ||
| SortMergeJoin [cs_sold_date_sk,ss_sold_date_sk] | ||
| InputAdapter | ||
| WholeStageCodegen | ||
| Sort [cs_sold_date_sk] | ||
| InputAdapter | ||
| Exchange [cs_sold_date_sk] #1 | ||
| WholeStageCodegen | ||
| Project [cs_bill_customer_sk,cs_sold_date_sk] | ||
| Filter [cs_sold_date_sk] | ||
| Scan parquet default.catalog_sales [cs_bill_customer_sk,cs_sold_date_sk] [cs_bill_customer_sk,cs_sold_date_sk] | ||
| InputAdapter | ||
| WholeStageCodegen | ||
| Sort [ss_sold_date_sk] | ||
| InputAdapter | ||
| Exchange [ss_sold_date_sk] #2 | ||
| WholeStageCodegen | ||
| Project [ss_customer_sk,ss_sold_date_sk] | ||
| Filter [ss_sold_date_sk] | ||
| Scan parquet default.store_sales [ss_customer_sk,ss_sold_date_sk] [ss_customer_sk,ss_sold_date_sk] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,7 +5,6 @@ | |
| * | ||
| * The below license was copied from: https://github.com/FasterXML/jackson-module-scala/blob/2.10/src/main/resources/META-INF/LICENSE | ||
| */ | ||
|
|
||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
|
|
@@ -38,7 +37,7 @@ trait TPCDSBase extends SparkFunSuite with SparkInvolvedSuite { | |
|
|
||
| // The TPCDS queries below are based on v1.4. | ||
| // TODO: Fix bulid pipeline for q49 and reenable q49. | ||
| val tpcdsQueries = Seq("q1") | ||
| val tpcdsQueries = Seq("q0") | ||
|
|
||
| private val tableColumns = Map( | ||
| "store_sales" -> | ||
|
|
@@ -554,17 +553,35 @@ trait TPCDSBase extends SparkFunSuite with SparkInvolvedSuite { | |
| """.stripMargin) | ||
| } | ||
|
|
||
| private val originalCBCEnabled = conf.cboEnabled | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. all changes below this line onward are directly picked from spark codebase. Refer https://github.com/apache/spark/blob/master/sql/core/src/test/scala/org/apache/spark/sql/TPCDSBase.scala#L609 |
||
| private val originalJoinReorderEnabled = conf.joinReorderEnabled | ||
|
|
||
| override def beforeAll(): Unit = { | ||
| super.beforeAll() | ||
| if (injectStats) { | ||
| // Sets configurations for enabling the optimization rules that | ||
| // exploit data statistics. | ||
| conf.setConf(SQLConf.CBO_ENABLED, true) | ||
| conf.setConf(SQLConf.JOIN_REORDER_ENABLED, true) | ||
| } | ||
| tableNames.foreach { tableName => | ||
| createTable(spark, tableName) | ||
| if (injectStats) { | ||
| // To simulate plan generation on actual TPC-DS data, injects data stats here | ||
| spark.sessionState.catalog.alterTableStats( | ||
| TableIdentifier(tableName), Some(TPCDSTableStats.sf100TableStats(tableName))) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| override def afterAll(): Unit = { | ||
| conf.setConf(SQLConf.CBO_ENABLED, originalCBCEnabled) | ||
| conf.setConf(SQLConf.JOIN_REORDER_ENABLED, originalJoinReorderEnabled) | ||
| tableNames.foreach { tableName => | ||
| spark.sessionState.catalog.dropTable(TableIdentifier(tableName), true, true) | ||
| } | ||
| super.afterAll() | ||
| } | ||
|
|
||
| protected def injectStats: Boolean = true | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Note: SortMergeJoin is used here because stats are enabled.