@@ -30,6 +30,7 @@ public actor SparkConnectClient {
3030 let port : Int
3131 let userContext : UserContext
3232 var sessionID : String ? = nil
33+ var tags = Set < String > ( )
3334
3435 /// Create a client to use GRPCClient.
3536 /// - Parameters:
@@ -229,6 +230,7 @@ public actor SparkConnectClient {
229230 request. userContext = userContext
230231 request. sessionID = self . sessionID!
231232 request. operationID = UUID ( ) . uuidString
233+ request. tags = Array ( tags)
232234 request. plan = plan
233235 return request
234236 }
@@ -409,4 +411,31 @@ public actor SparkConnectClient {
409411 }
410412 return result
411413 }
414+
415+ /// Add a tag to be assigned to all the operations started by this thread in this session.
416+ /// - Parameter tag: The tag to be added. Cannot contain ',' (comma) character or be an empty string.
417+ public func addTag( tag: String ) throws {
418+ try ProtoUtils . throwIfInvalidTag ( tag)
419+ tags. insert ( tag)
420+ }
421+
422+ /// Remove a tag previously added to be assigned to all the operations started by this thread in this session.
423+ /// Noop if such a tag was not added earlier.
424+ /// - Parameter tag: The tag to be removed. Cannot contain ',' (comma) character or be an empty string.
425+ public func removeTag( tag: String ) throws {
426+ try ProtoUtils . throwIfInvalidTag ( tag)
427+ tags. remove ( tag)
428+ }
429+
430+ /// Get the operation tags that are currently set to be assigned to all the operations started by
431+ /// this thread in this session.
432+ /// - Returns: A set of string.
433+ public func getTags( ) -> Set < String > {
434+ return tags
435+ }
436+
437+ /// Clear the current thread's operation tags.
438+ public func clearTags( ) {
439+ tags. removeAll ( )
440+ }
412441}
0 commit comments