-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-33452][SQL] Support v2 SHOW PARTITIONS #30398
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
Closed
Closed
Changes from 42 commits
Commits
Show all changes
46 commits
Select commit
Hold shift + click to select a range
65daf5d
Add ShowPartitionsExec
MaxGekk ef84a73
Add logical node ShowPartitions
MaxGekk 6934fa1
ShowPartitionsStatement -> ShowPartitions
MaxGekk c62b30b
Resolve ShowPartitions -> ShowPartitionsExec
MaxGekk d1190c7
Remove `verify(s"SHOW PARTITIONS $t")`
MaxGekk e086c32
Pass `UnresolvedTableOrView` to `ShowPartitions`
MaxGekk 7e06381
Throw an exception for non-partitioned table
MaxGekk 9cbbbe1
Fix ShowPartitionsParserSuite
MaxGekk 04c9317
Ignore test in PartitionedTablePerfStatsSuite
MaxGekk ed915c9
Check partition spec
MaxGekk ade84ba
Remove a comment
MaxGekk 3a457f9
pass Table to ShowPartitionsExec
MaxGekk 8700ed5
Change type of partition spec in ShowPartitions
MaxGekk dfbad25
Revert a test in v1/ShowPartitionsSuite
MaxGekk d9e4bd2
Draft implementation of ShowPartitionsExec
MaxGekk 761966b
Handle None as partitionSpec
MaxGekk db45677
Move view check to CheckAnalysis
MaxGekk 5b15dc3
Check that a table supports partitioning
MaxGekk f6b6814
Remove wrong check from ShowPartitionsExec
MaxGekk 8c59e8a
Add v2 test for non-partitioning columns
MaxGekk b62ed58
Move the test "non-partitioning columns" to the common trait
MaxGekk 6d14c56
Move a positive test to the common trait
MaxGekk b800229
Use runShowPartitionsSql()
MaxGekk ac0d2f1
Move checking by all partitioned columns to the common trait
MaxGekk 18cdaf6
Move the test "show everything more than 5 part keys" to the common t…
MaxGekk 35af49f
Merge remote-tracking branch 'origin/master' into show-partitions-exe…
MaxGekk a08177e
Remove unused imports
MaxGekk 797da17
Remove an unused import
MaxGekk c1faacb
Fix indentations
MaxGekk 0d8738c
Fix PartitionedTablePerfStatsSuite
MaxGekk c34995f
Pass time zone id to Cast
MaxGekk c6ea9d9
Merge remote-tracking branch 'origin/master' into show-partitions-exe…
MaxGekk feffb90
Move table creation to the common trait
MaxGekk bf5154a
Refactoring: remove unused `defaultNamespace`
MaxGekk 69cfa0b
Merge remote-tracking branch 'remotes/origin/master' into show-partit…
MaxGekk 0a1f972
fix error msg
MaxGekk a4acf40
fix merge conflicts
MaxGekk 9db9923
List by partition names
MaxGekk 1cd1e34
Fix build
MaxGekk 555ef3f
Merge remote-tracking branch 'origin/master' into show-partitions-exe…
MaxGekk 0fe4a61
Fix merge
MaxGekk d3c344a
UnresolvedTableOrView -> UnresolvedTable
MaxGekk 37d7801
Merge remote-tracking branch 'origin/master' into show-partitions-exe…
MaxGekk fbc5820
Address Wenchen's review comment
MaxGekk d16aec7
Merge remote-tracking branch 'remotes/origin/master' into show-partit…
MaxGekk dc211e6
Remove unused param `tableName` from convertToPartIdent()
MaxGekk 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
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
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
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
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
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
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
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
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
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
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
65 changes: 65 additions & 0 deletions
65
...ore/src/main/scala/org/apache/spark/sql/execution/datasources/v2/ShowPartitionsExec.scala
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,65 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. | ||
| * The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| * (the "License"); you may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package org.apache.spark.sql.execution.datasources.v2 | ||
|
|
||
| import org.apache.spark.sql.catalyst.InternalRow | ||
| import org.apache.spark.sql.catalyst.analysis.ResolvedPartitionSpec | ||
| import org.apache.spark.sql.catalyst.catalog.ExternalCatalogUtils.escapePathName | ||
| import org.apache.spark.sql.catalyst.expressions.{Attribute, Cast, Literal} | ||
| import org.apache.spark.sql.connector.catalog.{SupportsPartitionManagement, TableCatalog} | ||
| import org.apache.spark.sql.execution.LeafExecNode | ||
| import org.apache.spark.sql.internal.SQLConf | ||
| import org.apache.spark.sql.types.StringType | ||
| import org.apache.spark.unsafe.types.UTF8String | ||
|
|
||
| /** | ||
| * Physical plan node for showing partitions. | ||
| */ | ||
| case class ShowPartitionsExec( | ||
| output: Seq[Attribute], | ||
| catalog: TableCatalog, | ||
| table: SupportsPartitionManagement, | ||
| partitionSpec: Option[ResolvedPartitionSpec]) extends V2CommandExec with LeafExecNode { | ||
| override protected def run(): Seq[InternalRow] = { | ||
| val (names, ident) = partitionSpec | ||
| .map(spec => (spec.names, spec.ident)) | ||
| // listPartitionByNames() should return all partitions if the partition spec | ||
| // does not specify any partition names. | ||
| .getOrElse((Seq.empty[String], InternalRow.empty)) | ||
| val partitionIdentifiers = table.listPartitionByNames(names.toArray, ident) | ||
| // Converting partition identifiers as `InternalRow` of partition values, | ||
| // for instance InternalRow(value0, value1, ..., valueN), to `InternalRow`s | ||
| // with a string in the format: "col0=value0/col1=value1/.../colN=valueN". | ||
| val schema = table.partitionSchema() | ||
| val len = schema.length | ||
| val partitions = new Array[String](len) | ||
| val timeZoneId = SQLConf.get.sessionLocalTimeZone | ||
| partitionIdentifiers.map { row => | ||
| var i = 0 | ||
| while (i < len) { | ||
| val dataType = schema(i).dataType | ||
| val partValue = row.get(i, dataType) | ||
| val partValueStr = Cast(Literal(partValue, dataType), StringType, Some(timeZoneId)) | ||
| .eval().toString | ||
| partitions(i) = escapePathName(schema(i).name) + "=" + escapePathName(partValueStr) | ||
| i += 1 | ||
| } | ||
| InternalRow(UTF8String.fromString(partitions.mkString("/"))) | ||
| } | ||
| } | ||
| } |
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
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
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.
Uh oh!
There was an error while loading. Please reload this page.
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.
multiPart.getOrElse(Seq.empty[String])this looks weird. How can the table name beSeq.empty? And I don't see other parser rules doing the same thing. They are simply usingvisitMultipartIdentifier(ctx.multipartIdentifier). Why do we diverge here?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.
fixed