Skip to content

Conversation

@ivoson
Copy link
Contributor

@ivoson ivoson commented Apr 12, 2022

What changes were proposed in this pull request?

Migrate the following errors in QueryCompilationErrors:

  • descPartitionNotAllowedOnTempView -> FORBIDDEN_OPERATION
  • descPartitionNotAllowedOnView -> FORBIDDEN_OPERATION
  • descPartitionNotAllowedOnViewError -> Removed due to never used.

Why are the changes needed?

Porting compilation errors of desc partition on views to new error framework.

Does this PR introduce any user-facing change?

No

How was this patch tested?

Add new UT.

@ivoson ivoson changed the title [SPARK-38689][SQL] Use error classes in the compilation errors of not allowed DESC PARTI… [SPARK-38689][SQL] Use error classes in the compilation errors of not allowed DESC PARTITION on views Apr 12, 2022
@ivoson
Copy link
Contributor Author

ivoson commented Apr 12, 2022

cc @MaxGekk . Please take a loot at this PR. Thanks.

@AmplabJenkins
Copy link

Can one of the admins verify this patch?

new AnalysisException(s"DESC PARTITION is not allowed on a view: $table")
new AnalysisException(
errorClass = "INVALID_OPERATION_ON_VIEW",
messageParameters = Array(toSQLValue("DESC PARTITION"), toSQLValue(table)))
Copy link
Member

Choose a reason for hiding this comment

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

Precisely speaking, DESC PARTITION is not a value. Actually, it is a part of sql statement. Could you add a method toSQLStmt and invoke it here. We will call it for quoting of sql statements in error messages.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. Thanks @MaxGekk

val e = intercept[AnalysisException](
sql(s"DESC TABLE $tempViewName PARTITION (c='Us', d=1)")
)
assert(e.errorClass === Some("INVALID_OPERATION_ON_TEMP_VIEW"))
Copy link
Member

Choose a reason for hiding this comment

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

nit: for consistency with other places

Suggested change
assert(e.errorClass === Some("INVALID_OPERATION_ON_TEMP_VIEW"))
assert(e.getErrorClass === "INVALID_OPERATION_ON_TEMP_VIEW")

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

Comment on lines 112 to 117
"INVALID_OPERATION_ON_TEMP_VIEW" : {
"message" : [ "Operation %s is not allowed on a temporary view: %s" ]
},
"INVALID_OPERATION_ON_VIEW" : {
"message" : [ "Operation %s is not allowed on a view: %s" ]
},
Copy link
Member

Choose a reason for hiding this comment

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

Don't think we should introduce two error classes for almost the same. Could you add only one but more generic:

  "FORBIDDEN_OPERATION" : {
    "message" : [ "The operation %s is not allowed on %s: %s" ]
  },

Don't think we should translate values of second arg to local languages: "the temporary view" and "the view:".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. Thanks for the suggestion.

new AnalysisException(
errorClass = "FORBIDDEN_OPERATION",
messageParameters = Array(
toSQLStmt("DESC PARTITION"), "the view", toSQLValue(table)))
Copy link
Member

Choose a reason for hiding this comment

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

table is not a value, please, use toSQLId instead of toSQLValue

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

new AnalysisException(
errorClass = "FORBIDDEN_OPERATION",
messageParameters =
Array(toSQLStmt("DESC PARTITION"), "the temporary view", toSQLValue(table)))
Copy link
Member

Choose a reason for hiding this comment

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

Please, use toSQLId instead of toSQLValue, see #36210

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@MaxGekk
Copy link
Member

MaxGekk commented Apr 18, 2022

+1, LGTM. All GAs passed: https://github.com/ivoson/spark/actions/runs/2181933167. Merging to master.
Thank you, @ivoson.

@MaxGekk MaxGekk closed this in de18ce6 Apr 18, 2022
@ivoson
Copy link
Contributor Author

ivoson commented Apr 18, 2022

Thanks for the review. @MaxGekk

@ivoson ivoson deleted the SPARK-38689 branch April 18, 2022 07:51
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