Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -96,8 +96,10 @@ class CatalogTableTableExtractor extends TableExtractor {
} else {
val catalogTable = v1.asInstanceOf[CatalogTable]
val identifier = catalogTable.identifier
val db = identifier.database.getOrElse(spark.sessionState.catalog.getCurrentDatabase)
val tableIdentWithDB = identifier.copy(database = Some(db))
val owner = Option(catalogTable.owner).filter(_.nonEmpty)
Some(Table(None, identifier.database, identifier.table, owner))
Some(Table(None, tableIdentWithDB.database, tableIdentWithDB.table, owner))
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -835,4 +835,19 @@ 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()
val e = intercept[AccessControlException] {
doAs(someone, df.write.mode("overwrite").saveAsTable(table1))
}
assert(e.getMessage.contains(s"does not have [create] privilege on [$defaultDb/$table1]"))
Copy link
Contributor

Choose a reason for hiding this comment

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

Hi, you may use the interceptContains method to simplify the assertions. Very handy and clear.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi, you may use the interceptContains method to simplify the assertions. Very handy and clear.

Done. I will refine these test's UT by interceptContains later

}
}
}
}