Skip to content

Conversation

@gatorsmile
Copy link
Member

@gatorsmile gatorsmile commented Sep 21, 2016

What changes were proposed in this pull request?

This PR is to backport #15054 and #15160 to Spark 2.0.

  • When the permanent tables/views do not exist but the temporary view exists, the expected error should be NoSuchTableException for partition-related ALTER TABLE commands. However, it always reports a confusing error message. For example,
Partition spec is invalid. The spec (a, b) must match the partition spec () defined in table '`testview`';
  • When the permanent tables/views do not exist but the temporary view exists, the expected error should be NoSuchTableException for ALTER TABLE ... UNSET TBLPROPERTIES. However, it reports a missing table property. For example,
Attempted to unset non-existent property 'p' in table '`testView`';
  • When ANALYZE TABLE is called on a view or a temporary view, we should issue an error message. However, it reports a strange error:
ANALYZE TABLE is not supported for Project
  • When inserting into a temporary view that is generated from Range, we will get the following error message:
assertion failed: No plan for 'InsertIntoTable Range (0, 10, step=1, splits=Some(1)), false, false
+- Project [1 AS 1#20]
   +- OneRowRelation$

This PR is to fix the above four issues.

There is no place in Spark SQL that need SessionCatalog.tableExists to check temp views, so this PR makes SessionCatalog.tableExists only check permanent table/view and removes some hacks.

How was this patch tested?

Added multiple test cases

@SparkQA
Copy link

SparkQA commented Sep 21, 2016

Test build #65702 has finished for PR 15174 at commit 9efbe6b.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds the following public classes (experimental):
    • case class ShowColumnsCommand(tableName: TableIdentifier) extends RunnableCommand

@gatorsmile
Copy link
Member Author

cc @cloud-fan

@cloud-fan
Copy link
Contributor

LGTM, if you have time, can you also include #15160? they are kind of related. thanks!

@gatorsmile
Copy link
Member Author

Sure, will do it.

@gatorsmile gatorsmile changed the title [SPARK-17502] [SQL] [Backport] [2.0] Fix Multiple Bugs in DDL Statements on Temporary Views [WIP] [SPARK-17502] [17609] [SQL] [Backport] [2.0] Fix Multiple Bugs in DDL Statements on Temporary Views [WIP] Sep 22, 2016
@gatorsmile
Copy link
Member Author

FYI, most code changes of #15160 in createDataSourceTables.scala are not applicable. Thus, I did not backport them. cc @cloud-fan

@gatorsmile gatorsmile changed the title [SPARK-17502] [17609] [SQL] [Backport] [2.0] Fix Multiple Bugs in DDL Statements on Temporary Views [WIP] [SPARK-17502] [17609] [SQL] [Backport] [2.0] Fix Multiple Bugs in DDL Statements on Temporary Views Sep 22, 2016
sessionState.catalog.lookupRelation(tableIdentWithDB)) match {
// Pass a table identifier with database part, so that `tableExists` won't check temp
// views unexpectedly.
EliminateSubqueryAliases(sessionState.catalog.lookupRelation(tableIdentWithDB)) match {
Copy link
Contributor

Choose a reason for hiding this comment

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

we don't need tableIdentWithDB in CreateDataSourceTableCommand right?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done. : )

""".stripMargin)

case InsertIntoTable(t, _, _, _, _)
if !t.isInstanceOf[LeafNode] ||
Copy link

Choose a reason for hiding this comment

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

I was wondering why not replacing these one-letter values with something more explicit (like table in the following case) ? I understand that this is not the purpose of the PR, but just interested if it is normal to highlight those "style" things in PR discussion or not.

Copy link
Member Author

Choose a reason for hiding this comment

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

This PR is to backport the fix from the master branch to Spark 2.0 branch. I think your comment is valid. You can submit a PR for improving the code style. Thanks!

@SparkQA
Copy link

SparkQA commented Sep 22, 2016

Test build #65763 has finished for PR 15174 at commit 4d67fb6.

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

@SparkQA
Copy link

SparkQA commented Sep 22, 2016

Test build #65777 has finished for PR 15174 at commit d6c3168.

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

@cloud-fan
Copy link
Contributor

thanks, merging to 2.0!

asfgit pushed a commit that referenced this pull request Sep 23, 2016
…tements on Temporary Views

### What changes were proposed in this pull request?
This PR is to backport #15054 and #15160 to Spark 2.0.

- When the permanent tables/views do not exist but the temporary view exists, the expected error should be `NoSuchTableException` for partition-related ALTER TABLE commands. However, it always reports a confusing error message. For example,
```
Partition spec is invalid. The spec (a, b) must match the partition spec () defined in table '`testview`';
```
- When the permanent tables/views do not exist but the temporary view exists, the expected error should be `NoSuchTableException` for `ALTER TABLE ... UNSET TBLPROPERTIES`. However, it reports a missing table property. For example,
```
Attempted to unset non-existent property 'p' in table '`testView`';
```
- When `ANALYZE TABLE` is called on a view or a temporary view, we should issue an error message. However, it reports a strange error:
```
ANALYZE TABLE is not supported for Project
```

- When inserting into a temporary view that is generated from `Range`, we will get the following error message:
```
assertion failed: No plan for 'InsertIntoTable Range (0, 10, step=1, splits=Some(1)), false, false
+- Project [1 AS 1#20]
   +- OneRowRelation$
```

This PR is to fix the above four issues.

There is no place in Spark SQL that need `SessionCatalog.tableExists` to check temp views, so this PR makes `SessionCatalog.tableExists` only check permanent table/view and removes some hacks.

### How was this patch tested?
Added multiple test cases

Author: gatorsmile <[email protected]>

Closes #15174 from gatorsmile/PR15054Backport.
@gatorsmile
Copy link
Member Author

Let me close it. Thanks!

@gatorsmile gatorsmile closed this Sep 23, 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.

4 participants