-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-44507][SQL][CONNECT] Move AnalysisException to sql/api #42130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
cae7535
Split AnalysisException
hvanhovell c414f63
Move AnalysisException
hvanhovell 392bcbf
scala syntax
hvanhovell c74bc2f
MiMa & Migration Guide
hvanhovell d2d5e73
More MiMa
hvanhovell 0c8147f
Merge remote-tracking branch 'apache/master' into light-analysis-exce…
hvanhovell 31e2658
Merge remote-tracking branch 'apache/master' into light-analysis-exce…
hvanhovell feb30cd
Make it look like an AnalysisException
hvanhovell 5012175
Fix tests
hvanhovell a477dd2
Make it look like an AnalysisException
hvanhovell e8dbf44
Fix it.
hvanhovell 1fef2ef
Merge remote-tracking branch 'apache/master' into light-analysis-exce…
hvanhovell 751fc87
Fix verbatims
hvanhovell d6df8ab
Fix verbatim
hvanhovell 7ea8c63
Fix verbatim
hvanhovell 24b3cc7
Fix merge conflicts
hvanhovell f3ae96a
Fix verbatim
hvanhovell 1107b5c
Verbatims
hvanhovell File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
87 changes: 87 additions & 0 deletions
87
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/ExtendedAnalysisException.scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. | ||
| * The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| * (the "License"); you may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package org.apache.spark.sql.catalyst | ||
|
|
||
| import org.apache.spark.QueryContext | ||
| import org.apache.spark.sql.AnalysisException | ||
| import org.apache.spark.sql.catalyst.plans.logical.LogicalPlan | ||
|
|
||
| /** | ||
| * Internal [[AnalysisException]] that also captures a [[LogicalPlan]]. | ||
| */ | ||
| class ExtendedAnalysisException( | ||
| message: String, | ||
| line: Option[Int] = None, | ||
| startPosition: Option[Int] = None, | ||
| // Some plans fail to serialize due to bugs in scala collections. | ||
| @transient val plan: Option[LogicalPlan] = None, | ||
| cause: Option[Throwable] = None, | ||
| errorClass: Option[String] = None, | ||
| messageParameters: Map[String, String] = Map.empty, | ||
| context: Array[QueryContext] = Array.empty) | ||
| extends AnalysisException( | ||
| message, | ||
| line, | ||
| startPosition, | ||
| cause, | ||
| errorClass, | ||
| messageParameters, | ||
| context) { | ||
|
|
||
| def this(e: AnalysisException, plan: LogicalPlan) = { | ||
| this( | ||
| e.message, | ||
| e.line, | ||
| e.startPosition, | ||
| Option(plan), | ||
| e.cause, | ||
| e.errorClass, | ||
| e.messageParameters, | ||
| e.context) | ||
| setStackTrace(e.getStackTrace) | ||
| } | ||
|
|
||
| override def copy( | ||
| message: String, | ||
| line: Option[Int], | ||
| startPosition: Option[Int], | ||
| cause: Option[Throwable], | ||
| errorClass: Option[String], | ||
| messageParameters: Map[String, String], | ||
| context: Array[QueryContext]): ExtendedAnalysisException = { | ||
| new ExtendedAnalysisException(message, line, startPosition, plan, cause, errorClass, | ||
| messageParameters, context) | ||
| } | ||
|
|
||
| override def getMessage: String = { | ||
| val planAnnotation = Option(plan).flatten.map(p => s";\n$p").getOrElse("") | ||
| getSimpleMessage + planAnnotation | ||
| } | ||
|
|
||
| override def toString: String = { | ||
| val message = getLocalizedMessage | ||
| if (message != null) { | ||
| ExtendedAnalysisException.name + ": " + message | ||
| } else { | ||
| ExtendedAnalysisException.name | ||
| } | ||
| } | ||
| } | ||
|
|
||
| object ExtendedAnalysisException { | ||
| private val name = classOf[AnalysisException].getName | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This means users would see the new error class in stacktraces? e.g.
org.apache.spark.sql.catalyst.AnalysisException->org.apache.spark.sql.catalyst.ExtendedAnalysisExceptionShould we try to keep the original name by overriding
toStringmethod?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would be OK with that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current idea is there are a bit less place to use the plan field of the
AnalysisExceptionthus this switch cause less changes.