Skip to content
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] Support 'show partitions' sql #2521

Merged
merged 6 commits into from
Dec 18, 2023

Conversation

XuQianJin-Stars
Copy link
Contributor

@XuQianJin-Stars XuQianJin-Stars commented Dec 18, 2023

Purpose

fix 'show partitions' sql's bug

image
  1. create table with partition's field type is not the same
CREATE TABLE T (a VARCHAR(10), b CHAR(10),c BIGINT,dt LONG,hh VARCHAR(4))
            PARTITIONED BY (dt, hh)
            TBLPROPERTIES ('primary-key'='a,b,dt,hh', 'bucket'='3')
  1. insert some data
INSERT INTO T VALUES('a','b',1,20230816,'1132')
INSERT INTO T VALUES('a','b',1,20230816,'1133')
INSERT INTO T VALUES('a','b',1,20230816,'1134')
  1. show partitions xxxx PARTITION(xxxx)
show partitions T PARTITION (hh='1132')

Tests

PaimonPartitionManagementTest

API and Format

Documentation

@@ -237,4 +237,36 @@ public void testNonnull() {
spark.sql("DROP TABLE IF EXISTS S");
}
}

@Test
public void testShowPartitionsPartitioned() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe put these in a new test class named ShowCommandTest which will contain case related to SHOW commands.

case t @ ShowPartitions(PaimonRelation(table), specOpt, _) if t.resolved =>
PaimonShowTablePartitionsCommand(
table,
specOpt.map(s => s.asInstanceOf[ResolvedPartitionSpec]))
Copy link
Contributor

Choose a reason for hiding this comment

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

try this, maybe it can work too:

import org.apache.spark.sql.execution.datasources.v2.DataSourceV2Implicits._
specOpt.asResolvedPartitionSpecs

Copy link
Contributor Author

Choose a reason for hiding this comment

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

asResolvedPartitionSpecs

This is useful for Seq[PartitionSpec].

@YannByron
Copy link
Contributor

+1 for nice catch.

@JingsongLi
Copy link
Contributor

Thanks @XuQianJin-Stars , merging...

@JingsongLi JingsongLi merged commit 0ec1bb6 into apache:master Dec 18, 2023
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants