aokolnychyi commented on code in PR #56619:
URL: https://github.com/apache/spark/pull/56619#discussion_r3477112100
##########
sql/api/src/main/scala/org/apache/spark/sql/types/StructField.scala:
##########
@@ -243,6 +244,43 @@ case class StructField(
metadata.contains(EXISTS_DEFAULT_COLUMN_METADATA_KEY)
}
+ /**
+ * Updates the field with an ID for column identity tracking.
+ */
+ def withId(id: String): StructField = {
+ val newMetadata = new MetadataBuilder()
+ .withMetadata(metadata)
+ .putString(FIELD_ID_METADATA_KEY, id)
+ .build()
+ copy(metadata = newMetadata)
+ }
+
+ /**
+ * Returns the ID of this field, if set.
+ */
+ def id: Option[String] = {
+ if (metadata.contains(FIELD_ID_METADATA_KEY)) {
+ Some(metadata.getString(FIELD_ID_METADATA_KEY))
+ } else {
+ None
+ }
+ }
+
+ /**
+ * Returns a copy of this field with the field ID removed, or this field if
no ID is set.
+ */
+ def clearId(): StructField = {
Review Comment:
StructField is immutable by design and can't be modified.
--
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]