-
Notifications
You must be signed in to change notification settings - Fork 28.3k
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
[SPARK-23877][SQL][followup] use PhysicalOperation to simplify the handling of Project and Filter over partitioned relation #21111
Closed
Closed
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 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
This file contains 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
This file contains 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
This file contains 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 |
---|---|---|
|
@@ -24,6 +24,7 @@ import org.apache.spark.sql.QueryTest | |
import org.apache.spark.sql.catalyst.expressions.NamedExpression | ||
import org.apache.spark.sql.catalyst.plans.logical.{Distinct, Filter, Project, SubqueryAlias} | ||
import org.apache.spark.sql.hive.test.TestHiveSingleton | ||
import org.apache.spark.sql.internal.SQLConf.OPTIMIZER_METADATA_ONLY | ||
import org.apache.spark.sql.test.SQLTestUtils | ||
import org.apache.spark.sql.types.{IntegerType, StructField, StructType} | ||
|
||
|
@@ -32,13 +33,22 @@ class OptimizeHiveMetadataOnlyQuerySuite extends QueryTest with TestHiveSingleto | |
|
||
import spark.implicits._ | ||
|
||
before { | ||
override def beforeAll(): Unit = { | ||
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. make this test suite to follow the existing style in |
||
super.beforeAll() | ||
sql("CREATE TABLE metadata_only (id bigint, data string) PARTITIONED BY (part int)") | ||
(0 to 10).foreach(p => sql(s"ALTER TABLE metadata_only ADD PARTITION (part=$p)")) | ||
} | ||
|
||
override protected def afterAll(): Unit = { | ||
try { | ||
sql("DROP TABLE IF EXISTS metadata_only") | ||
} finally { | ||
super.afterAll() | ||
} | ||
} | ||
|
||
test("SPARK-23877: validate metadata-only query pushes filters to metastore") { | ||
withTable("metadata_only") { | ||
withSQLConf(OPTIMIZER_METADATA_ONLY.key -> "true") { | ||
val startCount = HiveCatalogMetrics.METRIC_PARTITIONS_FETCHED.getCount | ||
|
||
// verify the number of matching partitions | ||
|
@@ -50,7 +60,7 @@ class OptimizeHiveMetadataOnlyQuerySuite extends QueryTest with TestHiveSingleto | |
} | ||
|
||
test("SPARK-23877: filter on projected expression") { | ||
withTable("metadata_only") { | ||
withSQLConf(OPTIMIZER_METADATA_ONLY.key -> "true") { | ||
val startCount = HiveCatalogMetrics.METRIC_PARTITIONS_FETCHED.getCount | ||
|
||
// verify the matching partitions | ||
|
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.
I believe this is already fixed in https://issues.apache.org/jira/browse/SPARK-21884
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.
Yes, that does fix it but that's in a non-obvious way. What isn't clear is what guarantees that the rows used to construct the LocalRelation will never need to be serialized. Would it be reasonable for a future commit to remove the
@transient
modifier and re-introduce the problem?I would rather this return the data in a non-recursive structure, but it's a minor point.
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's very unlikely. SPARK-21884 guarantees Spark won't serialize the rows and we have regression tests to protect us. BTW it would be a lot of work to make sure all the places that create
LocalRelation
do not use recursive structure. I'll add some comments toLocalRelation
to emphasize it.