Skip to content

Conversation

@dilipbiswal
Copy link
Contributor

What changes were proposed in this pull request?

This PR adds Native execution of SHOW TBLPROPERTIES command.

Command Syntax:

SHOW TBLPROPERTIES table_name[(property_key_literal)]

How was this patch tested?

Tests added in HiveComandSuiie and DDLCommandSuite

*/
def isTemporaryTable(name: TableIdentifier): Boolean = {
val db = name.database.getOrElse(currentDb)
val table = formatTableName(name.table)
Copy link
Contributor

Choose a reason for hiding this comment

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

if/else is trivial

Copy link
Member

Choose a reason for hiding this comment

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

yeah, please do !name.database.isDefined && tempTables.contains(table)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks.. will make the change.

@SparkQA
Copy link

SparkQA commented Apr 2, 2016

Test build #54783 has finished for PR 12133 at commit 386f492.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds the following public classes (experimental):
    • case class ShowTablePropertiesCommand(

@SparkQA
Copy link

SparkQA commented Apr 3, 2016

Test build #54789 has finished for PR 12133 at commit 6b7bf59.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.


if (catalog.isTemporaryTable(table)) {
throw new AnalysisException("This operation is unsupported for temporary tables")
}
Copy link
Member

Choose a reason for hiding this comment

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

I'd use tableExists to check if the table exists. If not, throw an analysis exception.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Simon, you mean we should call a tableExist first before calling the getTable ? getTable does return a TableNotFound exception already if table is not found..

Copy link
Member

Choose a reason for hiding this comment

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

I am not sure if we can expect all external catalogs have this behavior. Because the return type of getTable is CatalogTable, instead of Option[CatalogTable], I'd expect it might return a null. At least I didn't see this in getTable's comment. If it is true, I think it is better to say it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Its documented here

Its good to also add it in the SessionCatalog.getTable doc. I will add a comment.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah. Thanks. I think it is better.

@SparkQA
Copy link

SparkQA commented Apr 3, 2016

Test build #54798 has finished for PR 12133 at commit 8ab51ea.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

}
}

test("show tables") {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this test here? You are testing SHOW TABLES commands, instead of SHOW TBLPROPERTIES commands.

Copy link
Contributor

Choose a reason for hiding this comment

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

Nevermind - I got it.

@SparkQA
Copy link

SparkQA commented Apr 3, 2016

Test build #54805 has finished for PR 12133 at commit c779c4b.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

table: TableIdentifier,
propertyKey: Option[String]) extends RunnableCommand {

override val output: Seq[Attribute] = {
Copy link
Contributor

Choose a reason for hiding this comment

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

MINOR/NIT: This is still more elaborate than it needs to be. Why not:

val schema = AttributeReference("value", StringType, nullable = false)() :: Nil
propertyKey match {
  case None => AttributeReference("key", StringType, nullable = false)() :: schema
  case _ => schema
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks !! It looks much better now !! I have made the change ..

@SparkQA
Copy link

SparkQA commented Apr 3, 2016

Test build #54808 has finished for PR 12133 at commit 09f3a53.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@dilipbiswal
Copy link
Contributor Author

cc @hvanhovell

@hvanhovell
Copy link
Contributor

LGTM

@gatorsmile
Copy link
Member

cc @yhuai @andrewor14

@hvanhovell
Copy link
Contributor

Merging to master. Thanks!

@asfgit asfgit closed this in 2715bc6 Apr 5, 2016
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.

5 participants