Skip to content

Conversation

@imback82
Copy link
Contributor

What changes were proposed in this pull request?

This is to address a concerned raised in #30862 (comment)

Currently, when relations/namespaces are not found, a general AnalysisException is thrown in CheckAnalysis. This can be improved by throwing more specific (already existing) exceptions such as NoSuchNamespaceException and NoSuchTableException.

Why are the changes needed?

To use more specific exceptions.

Does this PR introduce any user-facing change?

Yes, a more specific exception will be thrown. Since these specific exceptions derive the AnalysisException, no change is required if the client code already catching AnalysisException.

How was this patch tested?

Existing tests

@github-actions github-actions bot added the SQL label Dec 21, 2020
case write: V2WriteCommand if write.table.isInstanceOf[UnresolvedRelation] =>
val tblName = write.table.asInstanceOf[UnresolvedRelation].multipartIdentifier
write.table.failAnalysis(s"Table or view not found: ${tblName.quoted}")
throw new NoSuchTableException(s"Table or view not found: ${tblName.quoted}")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do we want to throw this exception at a specific node, or is it not needed?

    /** Fails the analysis at the point where a specific tree node was parsed. */
    def failAnalysis(msg: String): Nothing = {
      throw new AnalysisException(msg, t.origin.line, t.origin.startPosition)
    }

@imback82
Copy link
Contributor Author

@cloud-fan / @MaxGekk Do we also want to update the tests to catch more specific exceptions? There are many places, so I wanted to check with you first. Thanks!

@imback82 imback82 changed the title [WIP][SPARK-33872][SQL] Throw more specific exceptions when relations/namespaces are not found [SPARK-33872][SQL] Throw more specific exceptions when relations/namespaces are not found Dec 21, 2020
@SparkQA
Copy link

SparkQA commented Dec 21, 2020

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

@SparkQA
Copy link

SparkQA commented Dec 21, 2020

Test build #133182 has finished for PR 30878 at commit 6893510.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA
Copy link

SparkQA commented Dec 22, 2020

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


case u: UnresolvedNamespace =>
u.failAnalysis(s"Namespace not found: ${u.multipartIdentifier.quoted}")
throw new NoSuchNamespaceException(s"Namespace not found: ${u.multipartIdentifier.quoted}")
Copy link
Contributor

Choose a reason for hiding this comment

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

One benefit of u.failAnalysis is that it can report the error position in SQL string. If we can't keep this feature with the new exception, I'd suggest we don't change the exception type.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should we close this PR or update NoSuchNamespaceException and NoSuchTableException to handle positions?

Btw, it looks like there is a bug in keeping the position. I will fix it separately.

Copy link
Contributor

Choose a reason for hiding this comment

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

... update NoSuchNamespaceException and NoSuchTableException to handle positions?

If it's easy to do, let's go for it. Otherwise, we can close this PR as exception type seems not a big deal to me.

@cloud-fan
Copy link
Contributor

We don't need to update the tests. The concrete exception classes all extend AnalysisException.

@SparkQA
Copy link

SparkQA commented Jan 20, 2021

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

@SparkQA
Copy link

SparkQA commented Jan 20, 2021

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

@github-actions
Copy link

We're closing this PR because it hasn't been updated in a while. This isn't a judgement on the merit of the PR in any way. It's just a way of keeping the PR queue manageable.
If you'd like to revive this PR, please reopen it and ask a committer to remove the Stale tag!

@github-actions github-actions bot added the Stale label Jun 11, 2021
@github-actions github-actions bot closed this Jun 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants