Skip to content

Commit 388d1c2

Browse files
wakunGitHub Enterprise
authored andcommitted
[CARMEL-7521][CARMEL-4193][FOLLOWUP] Skip privilege check if authorization is disabled (apache#168)
1 parent bee046a commit 388d1c2

File tree

1 file changed

+9
-7
lines changed
  • sql/core/src/main/scala/org/apache/spark/sql/execution/command

1 file changed

+9
-7
lines changed

sql/core/src/main/scala/org/apache/spark/sql/execution/command/ddl.scala

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ import org.apache.spark.sql.errors.QueryExecutionErrors.hiveTableWithAnsiInterva
5050
import org.apache.spark.sql.execution.datasources.{DataSource, DataSourceUtils, FileFormat, HadoopFsRelation, LogicalRelation}
5151
import org.apache.spark.sql.execution.datasources.delta.DeltaUtils
5252
import org.apache.spark.sql.execution.datasources.v2.FileDataSourceV2
53-
import org.apache.spark.sql.internal.{HiveSerDe, SessionState, SQLConf}
53+
import org.apache.spark.sql.internal.{HiveSerDe, SessionState, SQLConf, StaticSQLConf}
5454
import org.apache.spark.sql.types._
5555
import org.apache.spark.sql.util.PartitioningUtils
5656
import org.apache.spark.util.{SerializableConfiguration, ThreadUtils}
@@ -1160,12 +1160,14 @@ object DDLUtils extends Logging {
11601160

11611161
def checkPrivilegeOfSpecifyTableLocation(
11621162
location: Option[_], state: SessionState): Unit = {
1163-
val catalog = state.catalog
1164-
val user = catalog.getCurrentUser
1165-
val authorizer = state.authorizer
1166-
if (location.isDefined
1167-
&& !authorizer.hasPrivilegeOfSpecifyTableLocation(user)) {
1168-
throw QueryCompilationErrors.createExternalTableUnsupported(catalog.getCurrentUser)
1163+
if (state.conf.getConf(StaticSQLConf.AUTHORIZATION_ENABLED)) {
1164+
val catalog = state.catalog
1165+
val user = catalog.getCurrentUser
1166+
val authorizer = state.authorizer
1167+
if (location.isDefined
1168+
&& !authorizer.hasPrivilegeOfSpecifyTableLocation(user)) {
1169+
throw QueryCompilationErrors.createExternalTableUnsupported(catalog.getCurrentUser)
1170+
}
11691171
}
11701172
}
11711173

0 commit comments

Comments
 (0)