Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -988,7 +988,7 @@
"tableTypeDesc" : null,
"catalogDesc" : null,
"isInput" : false,
"setCurrentDatabaseIfMissing" : false
"setCurrentDatabaseIfMissing" : true
} ],
"opType" : "CREATETABLE_AS_SELECT",
"queryDescs" : [ {
Expand All @@ -1005,7 +1005,7 @@
"tableTypeDesc" : null,
"catalogDesc" : null,
"isInput" : false,
"setCurrentDatabaseIfMissing" : false
"setCurrentDatabaseIfMissing" : true
} ],
"opType" : "CREATETABLE",
"queryDescs" : [ ]
Expand All @@ -1019,7 +1019,7 @@
"tableTypeDesc" : null,
"catalogDesc" : null,
"isInput" : false,
"setCurrentDatabaseIfMissing" : false
"setCurrentDatabaseIfMissing" : true
} ],
"opType" : "CREATETABLE",
"queryDescs" : [ ]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,8 @@ object TableCommands {

val CreateDataSourceTable = {
val cmd = "org.apache.spark.sql.execution.command.CreateDataSourceTableCommand"
val tableDesc = TableDesc("table", classOf[CatalogTableTableExtractor])
val tableDesc =
TableDesc("table", classOf[CatalogTableTableExtractor], setCurrentDatabaseIfMissing = true)
TableCommandSpec(cmd, Seq(tableDesc), CREATETABLE)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import org.apache.kyuubi.plugin.spark.authz.RangerTestNamespace._
import org.apache.kyuubi.plugin.spark.authz.RangerTestUsers._
import org.apache.kyuubi.plugin.spark.authz.ranger.RuleAuthorization.KYUUBI_AUTHZ_TAG
import org.apache.kyuubi.plugin.spark.authz.util.AuthZUtils._
import org.apache.kyuubi.util.AssertionUtils._
import org.apache.kyuubi.util.reflect.ReflectUtils._
abstract class RangerSparkExtensionSuite extends AnyFunSuite
with SparkSessionProvider with BeforeAndAfterAll {
Expand Down Expand Up @@ -835,4 +836,18 @@ class HiveCatalogRangerSparkExtensionSuite extends RangerSparkExtensionSuite {
assert(e2.getMessage.contains(s"does not have [select] privilege on [$db1/$view1/new_id]"))
}
}

test("[KYUUBI #5492] saveAsTable create DataSource table miss db info") {
val table1 = "table1"
withSingleCallEnabled {
withCleanTmpResources(Seq.empty) {
val df = doAs(
admin,
sql(s"SELECT * FROM VALUES(1, 100),(2, 200),(3, 300) AS t(id, scope)")).persist()
interceptContains[AccessControlException](
doAs(someone, df.write.mode("overwrite").saveAsTable(table1)))(
s"does not have [create] privilege on [$defaultDb/$table1]")
}
}
}
}