cloud-fan commented on code in PR #38595:
URL: https://github.com/apache/spark/pull/38595#discussion_r1022520366
##########
sql/core/src/main/scala/org/apache/spark/sql/Dataset.scala:
##########
@@ -3799,13 +3798,21 @@ class Dataset[T] private[sql](
global: Boolean): CreateViewCommand = {
val viewType = if (global) GlobalTempView else LocalTempView
- val tableIdentifier = try {
- sparkSession.sessionState.sqlParser.parseTableIdentifier(viewName)
+ val identifier = try {
+ sparkSession.sessionState.sqlParser.parseMultipartIdentifier(viewName)
} catch {
case _: ParseException => throw
QueryCompilationErrors.invalidViewNameError(viewName)
}
+
+ if (!SQLConf.get.allowsTempViewCreationWithMultipleNameparts &&
identifier.size > 1) {
+ // Temporary view names should NOT contain database prefix like
"database.table"
+ throw new AnalysisException(
+ errorClass = "TEMP_VIEW_NAME_CONTAINS_UNSUPPORTED_NAME_PARTS",
+ messageParameters = Map("actualName" -> viewName))
+ }
+
CreateViewCommand(
- name = tableIdentifier,
+ name = TableIdentifier.apply(identifier.last),
Review Comment:
```suggestion
name = TableIdentifier(identifier.head),
```
##########
sql/core/src/main/scala/org/apache/spark/sql/Dataset.scala:
##########
@@ -3799,13 +3798,21 @@ class Dataset[T] private[sql](
global: Boolean): CreateViewCommand = {
val viewType = if (global) GlobalTempView else LocalTempView
- val tableIdentifier = try {
- sparkSession.sessionState.sqlParser.parseTableIdentifier(viewName)
+ val identifier = try {
+ sparkSession.sessionState.sqlParser.parseMultipartIdentifier(viewName)
} catch {
case _: ParseException => throw
QueryCompilationErrors.invalidViewNameError(viewName)
}
+
+ if (!SQLConf.get.allowsTempViewCreationWithMultipleNameparts &&
identifier.size > 1) {
+ // Temporary view names should NOT contain database prefix like
"database.table"
+ throw new AnalysisException(
+ errorClass = "TEMP_VIEW_NAME_CONTAINS_UNSUPPORTED_NAME_PARTS",
+ messageParameters = Map("actualName" -> viewName))
+ }
+
CreateViewCommand(
- name = tableIdentifier,
+ name = TableIdentifier.apply(identifier.last),
Review Comment:
```suggestion
name = TableIdentifier(identifier.last),
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]