Skip to content

Conversation

@panbingkun
Copy link
Contributor

@panbingkun panbingkun commented Oct 16, 2022

What changes were proposed in this pull request?

This pr aims to use SparkIllegalArgumentException instead of IllegalArgumentException in CreateDatabaseCommand & AlterDatabaseSetLocationCommand.

Why are the changes needed?

When I work on https://issues.apache.org/jira/browse/SPARK-40790,
I found when location is empty, DDL command(CreateDatabaseCommand & AlterDatabaseSetLocationCommand) throw IllegalArgumentException, it seem not to fit into the new error framework.

Does this PR introduce any user-facing change?

No.

How was this patch tested?

Existed UT.

…alArgumentException in CreateDatabaseCommand & AlterDatabaseSetLocationCommand
…alArgumentException in CreateDatabaseCommand & AlterDatabaseSetLocationCommand
…alArgumentException in CreateDatabaseCommand & AlterDatabaseSetLocationCommand
…lArgumentException in CreateDatabaseCommand & AlterDatabaseSetLocationCommand
@panbingkun
Copy link
Contributor Author

cc @MaxGekk

Comment on lines 72 to 75
val e = intercept[SparkIllegalArgumentException] {
sql(s"CREATE NAMESPACE $ns LOCATION ''")
}
assert(e.getMessage.contains("Can not create a Path from an empty string"))
assert(e.getMessage.contains("Unsupported empty location"))
Copy link
Member

Choose a reason for hiding this comment

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

As you are here, could you use checkError().

Copy link
Contributor Author

@panbingkun panbingkun Oct 17, 2022

Choose a reason for hiding this comment

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

Done.

@AmplabJenkins
Copy link

Can one of the admins verify this patch?

…alArgumentException in CreateDatabaseCommand & AlterDatabaseSetLocationCommand
…alArgumentException in CreateDatabaseCommand & AlterDatabaseSetLocationCommand
…alArgumentException in CreateDatabaseCommand & AlterDatabaseSetLocationCommand
…alArgumentException in CreateDatabaseCommand & AlterDatabaseSetLocationCommand
…alArgumentException in CreateDatabaseCommand & AlterDatabaseSetLocationCommand
@panbingkun panbingkun requested a review from MaxGekk October 18, 2022 01:22
"Not enough memory to build and broadcast the table to all worker nodes. As a workaround, you can either disable broadcast by setting <autoBroadcastjoinThreshold> to -1 or increase the spark driver memory by setting <driverMemory> to a higher value<analyzeTblMsg>"
]
},
"_LEGACY_ERROR_TEMP_2251" : {
Copy link
Member

Choose a reason for hiding this comment

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

Could you assign a name to the error class like: UNSUPPORTED_EMPTY_LOCATION

Copy link
Contributor Author

@panbingkun panbingkun Oct 18, 2022

Choose a reason for hiding this comment

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

Done

…alArgumentException in CreateDatabaseCommand & AlterDatabaseSetLocationCommand
@panbingkun panbingkun requested a review from MaxGekk October 18, 2022 13:44
@MaxGekk
Copy link
Member

MaxGekk commented Oct 19, 2022

+1, LGTM. Merging to master.
Thank you, @panbingkun.

@MaxGekk MaxGekk closed this in 0110b1e Oct 19, 2022
},
"UNSUPPORTED_EMPTY_LOCATION" : {
"message" : [
"Unsupported empty location."
Copy link
Contributor

Choose a reason for hiding this comment

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

empty location is a bit misleading. This is not a location with no files/directories, it's empty string. How about

EMPTY_STRING_AS_LOCATION: Can not reference a location with an empty string.

Copy link
Member

Choose a reason for hiding this comment

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

@panbingkun Could you open a follow up PR and change this, and address below comment, please.

sql(s"ALTER NAMESPACE $ns SET LOCATION ''")
}.getMessage
assert(message.contains("Can not create a Path from an empty string"))
val sqlText = s"ALTER NAMESPACE $ns SET LOCATION ''"
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can move this test to the base suite now, as the behavior is consistent between v1 and v2 tables.

}
assert(e.getMessage.contains("Can not create a Path from an empty string"))

val sqlText = s"CREATE NAMESPACE $ns LOCATION ''"
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto

SandishKumarHN pushed a commit to SandishKumarHN/spark that referenced this pull request Dec 12, 2022
…alArgumentException in CreateDatabaseCommand & AlterDatabaseSetLocationCommand

### What changes were proposed in this pull request?
This pr aims to use SparkIllegalArgumentException instead of IllegalArgumentException in CreateDatabaseCommand & AlterDatabaseSetLocationCommand.

### Why are the changes needed?
When I work on https://issues.apache.org/jira/browse/SPARK-40790,
I found when `location` is empty, DDL command(CreateDatabaseCommand & AlterDatabaseSetLocationCommand) throw IllegalArgumentException, it seem not to fit into the new error framework.

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

### How was this patch tested?
Existed UT.

Closes apache#38274 from panbingkun/setNamespaceLocation_error.

Authored-by: panbingkun <[email protected]>
Signed-off-by: Max Gekk <[email protected]>
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.

4 participants