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 @@ -200,7 +200,6 @@ case class CatalogTableType private(name: String)
object CatalogTableType {
val EXTERNAL = new CatalogTableType("EXTERNAL")
val MANAGED = new CatalogTableType("MANAGED")
val INDEX = new CatalogTableType("INDEX")
val VIEW = new CatalogTableType("VIEW")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -637,12 +637,11 @@ case class ShowPartitionsCommand(
* Validate and throws an [[AnalysisException]] exception under the following conditions:
* 1. If the table is not partitioned.
* 2. If it is a datasource table.
* 3. If it is a view or index table.
* 3. If it is a view.
*/
if (tab.tableType == VIEW ||
tab.tableType == INDEX) {
if (tab.tableType == VIEW) {
throw new AnalysisException(
s"SHOW PARTITIONS is not allowed on a view or index table: ${tab.qualifiedName}")
s"SHOW PARTITIONS is not allowed on a view: ${tab.qualifiedName}")
}

if (tab.partitionColumnNames.isEmpty) {
Expand Down Expand Up @@ -725,7 +724,6 @@ case class ShowCreateTableCommand(table: TableIdentifier) extends RunnableComman
case EXTERNAL => " EXTERNAL TABLE"
case VIEW => " VIEW"
case MANAGED => " TABLE"
case INDEX => reportUnsupportedError(Seq("index table"))
}

builder ++= s"CREATE$tableTypeString ${table.quotedString}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ private[hive] case class MetastoreRelation(
tTable.setTableType(catalogTable.tableType match {
case CatalogTableType.EXTERNAL => HiveTableType.EXTERNAL_TABLE.toString
case CatalogTableType.MANAGED => HiveTableType.MANAGED_TABLE.toString
case CatalogTableType.INDEX => HiveTableType.INDEX_TABLE.toString
case CatalogTableType.VIEW => HiveTableType.VIRTUAL_VIEW.toString
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -379,8 +379,9 @@ private[hive] class HiveClientImpl(
tableType = h.getTableType match {
case HiveTableType.EXTERNAL_TABLE => CatalogTableType.EXTERNAL
case HiveTableType.MANAGED_TABLE => CatalogTableType.MANAGED
case HiveTableType.INDEX_TABLE => CatalogTableType.INDEX
case HiveTableType.VIRTUAL_VIEW => CatalogTableType.VIEW
case HiveTableType.INDEX_TABLE =>
throw new AnalysisException("Hive index table is not supported.")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

can this be an error triggered error? if not i'd throw a different exception since at this point it's a bug in spark.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This can be triggered. Users can get the special index table name by SHOW TABLES and read it.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Any function who invokes getTableOption might trigger it.

For example, when we create a table that has the same name as an existing Index table, the message we will get is

Hive index table is not supported

This might be confusing to external users, because they are not creating a Hive index table.

In Hive, the error message we will get is

hive> create table default__t21_id1__ (col1 int);
FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask. AlreadyExistsException(message:Table default__t21_id1__ already exists)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This mostly won't happen, but we can improve it by introducing a isTableExists API in HiveClient, do you wanna work on it? thanks!

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Sure, I can do it today. Thanks!

},
schema = schema,
partitionColumnNames = partCols.map(_.name),
Expand Down Expand Up @@ -757,7 +758,6 @@ private[hive] class HiveClientImpl(
HiveTableType.EXTERNAL_TABLE
case CatalogTableType.MANAGED =>
HiveTableType.MANAGED_TABLE
case CatalogTableType.INDEX => HiveTableType.INDEX_TABLE
case CatalogTableType.VIEW => HiveTableType.VIRTUAL_VIEW
})
// Note: In Hive the schema and partition columns must be disjoint sets
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ class HiveCommandSuite extends QueryTest with SQLTestUtils with TestHiveSingleto
val message4 = intercept[AnalysisException] {
sql("SHOW PARTITIONS parquet_view1")
}.getMessage
assert(message4.contains("is not allowed on a view or index table"))
assert(message4.contains("is not allowed on a view"))
}
}

Expand Down