aokolnychyi commented on code in PR #56619:
URL: https://github.com/apache/spark/pull/56619#discussion_r3464886645
##########
sql/catalyst/src/main/java/org/apache/spark/sql/connector/catalog/Column.java:
##########
@@ -243,12 +208,97 @@ default GenerationExpression columnGenerationExpression()
{
* others.
* <p>
* This API covers top-level columns only. Nested struct fields, array
elements, and map
- * keys/values do not have separate IDs. Connectors that track nested field
IDs can encode
- * them into the returned top-level Column ID string to detect nested
changes, since Spark
- * only compares string equality.
+ * keys/values carry their own IDs in struct field metadata. Spark validates
both top-level and
+ * nested field IDs as part of schema compatibility checks. See {@link
StructField#id()}.
*/
@Nullable
default String id() {
return null;
}
+
+ /**
+ * A builder for {@link Column}.
+ *
+ * @since 4.2.0
+ */
+ class Builder {
+ private final String name;
+ private final DataType dataType;
+ private boolean nullable = true;
+ private String comment = null;
+ private ColumnDefaultValue defaultValue = null;
+ private GenerationExpression genExpr = null;
+ private IdentityColumnSpec identityColumnSpec = null;
+ private String metadataInJSON = null;
+ private String id = null;
+
+ private Builder(String name, DataType dataType) {
+ this.name = Objects.requireNonNull(name, "name must not be null");
+ this.dataType = Objects.requireNonNull(dataType, "dataType must not be
null");
+ }
+
+ public Builder nullable(boolean nullable) {
+ this.nullable = nullable;
+ return this;
+ }
+
+ public Builder comment(String comment) {
+ this.comment = comment;
+ return this;
+ }
+
+ public Builder defaultValue(ColumnDefaultValue defaultValue) {
+ this.defaultValue = defaultValue;
+ return this;
+ }
+
+ public Builder generationExpression(String sql) {
+ this.genExpr = sql != null ? new GenerationExpression(sql) : null;
+ return this;
+ }
+
+ public Builder generationExpression(GenerationExpression generationExpr) {
+ this.genExpr = generationExpr;
+ return this;
+ }
+
+ public Builder identityColumnSpec(IdentityColumnSpec identityColumnSpec) {
+ this.identityColumnSpec = identityColumnSpec;
+ return this;
+ }
+
+ public Builder metadataInJSON(String metadataInJSON) {
Review Comment:
Renamed.
--
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]