Skip to content

Conversation

@imback82
Copy link
Contributor

@imback82 imback82 commented Feb 1, 2021

What changes were proposed in this pull request?

This PR proposes to add relationTypeMismatchHint to UnresolvedTable so that if a relation is resolved to a view when a table is expected, a hint message can be included as a part of the analysis exception message. Note that the same feature is already introduced to UnresolvedView in #30636.

This mostly affects ALTER TABLE commands where the analysis exception message will now contain Please use ALTER VIEW as instead.

Why are the changes needed?

To give a better error message. (The hint used to exist but got removed for commands that migrated to the new resolution framework)

Does this PR introduce any user-facing change?

Yes, now ALTER TABLE commands include a hint to use ALTER VIEW instead.

sql("ALTER TABLE v SET SERDE 'whatever'")

Before:

"v is a view. 'ALTER TABLE ... SET [SERDE|SERDEPROPERTIES]' expects a table.

After this PR:

"v is a view. 'ALTER TABLE ... SET [SERDE|SERDEPROPERTIES]' expects a table. Please use ALTER VIEW instead.

How was this patch tested?

Updated existing test cases to include the hint.

@github-actions github-actions bot added the SQL label Feb 1, 2021
@SparkQA
Copy link

SparkQA commented Feb 1, 2021

Kubernetes integration test starting
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/39331/

@SparkQA
Copy link

SparkQA commented Feb 1, 2021

Kubernetes integration test status failure
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/39331/

@imback82
Copy link
Contributor Author

imback82 commented Feb 2, 2021

cc @cloud-fan @MaxGekk

@SparkQA
Copy link

SparkQA commented Feb 2, 2021

Test build #134745 has finished for PR 31424 at commit 64bf918.

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

@cloud-fan
Copy link
Contributor

thanks, merging to master!

@cloud-fan cloud-fan closed this in f024d30 Feb 2, 2021
case u @ UnresolvedTable(identifier, cmd, relationTypeMismatchHint) =>
lookupTableOrView(identifier).map {
case v: ResolvedView => throw QueryCompilationErrors.expectTableNotViewError(v, cmd, u)
case v: ResolvedView =>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@cloud-fan looks like I missed handling this in ResolveTempViews. I will create a follow up PR. Sorry about that.

cloud-fan pushed a commit that referenced this pull request Feb 3, 2021
…olvedTable is resolved to a temp view

### What changes were proposed in this pull request?

This is a follow up to #31424, and proposes to use `UnresolvedTable.relationTypeMismatchHint` when `UnresolvedTable` is resolved to a temp view.

### Why are the changes needed?

This change utilizes the type mismatch hint when a relation is resolved to a temp view when a table is expected.

For example, `ALTER TABLE tmpView SET TBLPROPERTIES ('p' = 'an')` will now include `Please use ALTER VIEW instead.` in the exception message: `tmpView is a temp view. 'ALTER TABLE ... SET TBLPROPERTIES' expects a table. Please use ALTER VIEW instead.`

### Does this PR introduce _any_ user-facing change?

Yes, adds the hint in the exception message.

### How was this patch tested?

Update existing tests to include the hint.

Closes #31452 from imback82/followup_SPARK-34317.

Authored-by: Terry Kim <[email protected]>
Signed-off-by: Wenchen Fan <[email protected]>
skestle pushed a commit to skestle/spark that referenced this pull request Feb 3, 2021
…ble for a better error message

### What changes were proposed in this pull request?

This PR proposes to add `relationTypeMismatchHint` to `UnresolvedTable` so that if a relation is resolved to a view when a table is expected, a hint message can be included as a part of the analysis exception message. Note that the same feature is already introduced to `UnresolvedView` in apache#30636.

This mostly affects `ALTER TABLE` commands where the analysis exception message will now contain `Please use ALTER VIEW as instead`.

### Why are the changes needed?

To give a better error message. (The hint used to exist but got removed for commands that migrated to the new resolution framework)

### Does this PR introduce _any_ user-facing change?

Yes, now `ALTER TABLE` commands include a hint to use `ALTER VIEW` instead.
```
sql("ALTER TABLE v SET SERDE 'whatever'")
```
Before:
```
"v is a view. 'ALTER TABLE ... SET [SERDE|SERDEPROPERTIES]' expects a table.
```
After this PR:
```
"v is a view. 'ALTER TABLE ... SET [SERDE|SERDEPROPERTIES]' expects a table. Please use ALTER VIEW instead.
```

### How was this patch tested?

Updated existing test cases to include the hint.

Closes apache#31424 from imback82/better_error.

Authored-by: Terry Kim <[email protected]>
Signed-off-by: Wenchen Fan <[email protected]>
skestle pushed a commit to skestle/spark that referenced this pull request Feb 3, 2021
…olvedTable is resolved to a temp view

### What changes were proposed in this pull request?

This is a follow up to apache#31424, and proposes to use `UnresolvedTable.relationTypeMismatchHint` when `UnresolvedTable` is resolved to a temp view.

### Why are the changes needed?

This change utilizes the type mismatch hint when a relation is resolved to a temp view when a table is expected.

For example, `ALTER TABLE tmpView SET TBLPROPERTIES ('p' = 'an')` will now include `Please use ALTER VIEW instead.` in the exception message: `tmpView is a temp view. 'ALTER TABLE ... SET TBLPROPERTIES' expects a table. Please use ALTER VIEW instead.`

### Does this PR introduce _any_ user-facing change?

Yes, adds the hint in the exception message.

### How was this patch tested?

Update existing tests to include the hint.

Closes apache#31452 from imback82/followup_SPARK-34317.

Authored-by: Terry Kim <[email protected]>
Signed-off-by: Wenchen Fan <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants