Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -885,6 +885,9 @@ case class ShowTablesCommand(
// Note: tableIdentifierPattern should be non-empty, otherwise a [[ParseException]]
// should have been thrown by the sql parser.
val table = catalog.getTableMetadata(TableIdentifier(tableIdentifierPattern.get, Some(db)))

DDLUtils.verifyPartitionProviderIsHive(sparkSession, table, "SHOW TABLE EXTENDED")

val tableIdent = table.identifier
val normalizedSpec = PartitioningUtils.normalizePartitionSpec(
partitionSpec.get,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3073,6 +3073,16 @@ abstract class DDLSuite extends QueryTest with SQLTestUtils {
}
}
}

test("SPARK-33670: show partitions from a datasource table") {
import testImplicits._
val t = "part_datasrc"
withTable(t) {
val df = (1 to 3).map(i => (i, s"val_$i", i * 2)).toDF("a", "b", "c")
df.write.partitionBy("a").format("parquet").mode(SaveMode.Overwrite).saveAsTable(t)
assert(sql(s"SHOW TABLE EXTENDED LIKE '$t' PARTITION(a = 1)").count() === 1)
}
}
}

object FakeLocalFsFileSystem {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ class PartitionProviderCompatibilitySuite
s"ALTER TABLE $tableName PARTITION (partCol=1) SET LOCATION '/foo'",
s"ALTER TABLE $tableName DROP PARTITION (partCol=1)",
s"DESCRIBE $tableName PARTITION (partCol=1)",
s"SHOW PARTITIONS $tableName")
s"SHOW PARTITIONS $tableName",
s"SHOW TABLE EXTENDED LIKE '$tableName' PARTITION (partCol=1)")

withSQLConf(SQLConf.HIVE_MANAGE_FILESOURCE_PARTITIONS.key -> "true") {
for (cmd <- unsupportedCommands) {
Expand Down Expand Up @@ -124,10 +125,15 @@ class PartitionProviderCompatibilitySuite
}
// disabled
withSQLConf(SQLConf.HIVE_MANAGE_FILESOURCE_PARTITIONS.key -> "false") {
val e = intercept[AnalysisException] {
spark.sql(s"show partitions test")
Seq(
"SHOW PARTITIONS test",
"SHOW TABLE EXTENDED LIKE 'test' PARTITION (partCol=1)"
).foreach { showPartitions =>
val e = intercept[AnalysisException] {
spark.sql(showPartitions)
}
assert(e.getMessage.contains("filesource partition management is disabled"))
}
assert(e.getMessage.contains("filesource partition management is disabled"))
spark.sql("refresh table test")
assert(spark.sql("select * from test").count() == 5)
}
Expand Down