MetadataBuilder¶
MetadataBuilder is used to describe how to create a Metadata (using Fluent API).
Fluent API
Learn more about Fluent interface design pattern in Wikipedia, the free encyclopedia.
import org.apache.spark.sql.types.MetadataBuilder
val newMetadata = new MetadataBuilder()
.withMetadata(attr.metadata)
.putNull("__is_duplicate")
.build()
Creating Metadata¶
build(): Metadata
build creates a Metadata (for the internal map).
withMetadata¶
withMetadata(
metadata: Metadata): this.type
withMetadata adds the map of the given Metadata to the internal map.
In the end, withMetadata returns this MetadataBuilder.
withMetadata is used when:
FileSourceConstantMetadataStructFieldis requested formetadataFileSourceGeneratedMetadataStructFieldis requested formetadataFileSourceMetadataAttributeis requested formetadataandremoveInternalMetadataMetadataColumnHelperis requested to markAsAllowAnyAccess and markAsQualifiedAccessOnly- ResolveDefaultColumns logical resolution rule is executed (to constantFoldCurrentDefaultsToExistDefaults)
StructFieldis requested to remove or update the CURRENT_DEFAULT metadata attribute, and update EXISTS_DEFAULT metadata attribute- others