Skip to content
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

[SPARK-46393][SQL][FOLLOWUP] Classify exceptions in JDBCTableCatalog.loadTable and Fix UT #46912

Closed
wants to merge 4 commits into from

Conversation

panbingkun
Copy link
Contributor

@panbingkun panbingkun commented Jun 7, 2024

What changes were proposed in this pull request?

This is a followup of #46905, to fix some UT on GA.

Why are the changes needed?

Fix UT.

Does this PR introduce any user-facing change?

No.,

How was this patch tested?

Manually test.
Pass GA

Was this patch authored or co-authored using generative AI tooling?

No.

@panbingkun
Copy link
Contributor Author

cc @cloud-fan @yaooqinn @HyukjinKwon

@yaooqinn
Copy link
Member

yaooqinn commented Jun 7, 2024

Could you cherry-pick 82b4ad2 here to test the CI?

@panbingkun
Copy link
Contributor Author

Could you cherry-pick 82b4ad2 here to test the CI?

Okay.

panbingkun and others added 2 commits June 7, 2024 16:37
…loadTable

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

This is a followup of apache#44335 , which missed to handle `loadTable`

### Why are the changes needed?

better error message

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

no

### How was this patch tested?

existing test

### Was this patch authored or co-authored using generative AI tooling?

no

Closes apache#46905 from cloud-fan/jdbc.

Authored-by: Wenchen Fan <wenchen@databricks.com>
Signed-off-by: Kent Yao <yao@apache.org>
@panbingkun
Copy link
Contributor Author

Could you cherry-pick 82b4ad2 here to test the CI?

Done.

Copy link
Member

@yaooqinn yaooqinn left a comment

Choose a reason for hiding this comment

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

+1, LGTM. Pending CIs

@yaooqinn yaooqinn changed the title [SPARK-46393][SQL][TESTS] Fix UT [SPARK-46393][SQL][FOLLOWUP] Classify exceptions in JDBCTableCatalog.loadTable and Fix UT Jun 7, 2024
"url" -> options.getRedactUrl(),
"tableName" -> toSQLId(ident)),
dialect,
description = s"Failed to load table: $ident"
Copy link
Contributor Author

@panbingkun panbingkun Jun 7, 2024

Choose a reason for hiding this comment

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

@cloud-fan @yaooqinn
Also, do we need catalogname as the prefix for the table here?
Although I found this class JDBCTableCatalog.scala, similar ones do not have this prefix attached.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm fine to add catalog info. Let's do it in a separated PR, as not only loadTable needs to be updated.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, Let me to do it in a separated PR.

def checkErrorFailedLoadTable(e: AnalysisException, tbl: String): Unit = {
checkError(
exception = e,
errorClass = "FAILED_JDBC.UNCLASSIFIED",
Copy link
Contributor

Choose a reason for hiding this comment

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

shouldn't this be LOAD_TABLE?

Copy link
Contributor Author

@panbingkun panbingkun Jun 7, 2024

Choose a reason for hiding this comment

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

def classifyException(
e: Throwable,
errorClass: String,
messageParameters: Map[String, String],
description: String): AnalysisException = {
classifyException(description, e)
}
/**
* Gets a dialect exception, classifies it and wraps it by `AnalysisException`.
* @param message The error message to be placed to the returned exception.
* @param e The dialect specific exception.
* @return `AnalysisException` or its sub-class.
*/
@deprecated("Please override the classifyException method with an error class", "4.0.0")
def classifyException(message: String, e: Throwable): AnalysisException = {
new AnalysisException(
errorClass = "FAILED_JDBC.UNCLASSIFIED",
messageParameters = Map(
"url" -> "jdbc:",
"message" -> message),
cause = Some(e))
}

image
It lost the upstream errorClass in this place

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It seems that we should correct 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.

If necessary, I handle it together with the prefix logic above?

Copy link
Contributor

Choose a reason for hiding this comment

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

SGTM

@cloud-fan
Copy link
Contributor

thanks, merging to master!

@cloud-fan cloud-fan closed this in 8911d59 Jun 7, 2024
LuciferYang pushed a commit that referenced this pull request Jun 18, 2024
…ption` throw out the `original` exception

### What changes were proposed in this pull request?
The pr aims to make `built-in` JdbcDialect's method classifyException throw out the `original` exception.

### Why are the changes needed?
As discussed in #46912 (comment), the following code:
https://github.com/apache/spark/blob/df4156aa3217cf0f58b4c6cbf33c967bb43f7155/sql/core/src/main/scala/org/apache/spark/sql/jdbc/JdbcDialects.scala#L746-L751
have lost the original cause of the error, let's correct it.

### Does this PR introduce _any_ user-facing change?
Yes, more accurate error conditions for end users.

### How was this patch tested?
- Manually test.
- Update existed UT & Pass GA.

### Was this patch authored or co-authored using generative AI tooling?
No.

Closes #46937 from panbingkun/improve_JDBCTableCatalog.

Authored-by: panbingkun <panbingkun@baidu.com>
Signed-off-by: yangjie01 <yangjie01@baidu.com>
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