cloud-fan commented on code in PR #47772:
URL: https://github.com/apache/spark/pull/47772#discussion_r1720590886
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/unresolved.scala:
##########
@@ -124,10 +125,36 @@ case class UnresolvedRelation(
override def name: String = tableName
+ def requireWritePrivileges(privileges: Seq[TableWritePrivilege]):
UnresolvedRelation = {
+ if (privileges.nonEmpty) {
+ val newOptions = new java.util.HashMap[String, String]
+ newOptions.putAll(options)
+ newOptions.put(UnresolvedRelation.REQUIRED_WRITE_PRIVILEGES,
privileges.mkString(","))
+ copy(options = new CaseInsensitiveStringMap(newOptions))
+ } else {
+ this
+ }
+ }
+
+ def clearWritePrivileges: UnresolvedRelation = {
+ if (options.containsKey(UnresolvedRelation.REQUIRED_WRITE_PRIVILEGES)) {
+ val newOptions = new java.util.HashMap[String, String]
+ newOptions.putAll(options)
+ newOptions.remove(UnresolvedRelation.REQUIRED_WRITE_PRIVILEGES)
+ copy(options = new CaseInsensitiveStringMap(newOptions))
+ } else {
+ this
+ }
+ }
+
final override val nodePatterns: Seq[TreePattern] = Seq(UNRESOLVED_RELATION)
}
object UnresolvedRelation {
+ // An internal option of `UnresolvedRelation` to specify the required write
privileges when
Review Comment:
We can add a new field to `UnresolvedRelation` but it may break third-party
catalyst rules.
--
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]