aokolnychyi commented on code in PR #56619:
URL: https://github.com/apache/spark/pull/56619#discussion_r3445141610
##########
sql/catalyst/src/main/java/org/apache/spark/sql/connector/catalog/Column.java:
##########
@@ -72,88 +71,54 @@ static Column create(
String comment,
ColumnDefaultValue defaultValue,
String metadataInJSON) {
- return new ColumnImpl(
- name,
- dataType,
- nullable,
- comment,
- defaultValue,
- /* generationExpression = */ null,
- /* identityColumnSpec = */ null,
- metadataInJSON,
- /* id = */ null);
+ return newBuilder(name, dataType)
+ .nullable(nullable)
+ .comment(comment)
+ .defaultValue(defaultValue)
+ .metadataInJSON(metadataInJSON)
+ .build();
}
- /**
- * Creates a column with a generation expression in SQL string form.
- *
- * @since 4.3.0
- * @deprecated Use
- * {@link #create(String, DataType, boolean, String, GenerationExpression,
String)} instead.
- */
- @Deprecated
static Column create(
String name,
DataType dataType,
boolean nullable,
String comment,
String generationExpression,
String metadataInJSON) {
- GenerationExpression genExpr = generationExpression != null
- ? new GenerationExpression(generationExpression) : null;
- return new ColumnImpl(
- name,
- dataType,
- nullable,
- comment,
- /* defaultValue = */ null,
- genExpr,
- /* identityColumnSpec = */ null,
- metadataInJSON,
- /* id = */ null);
+ return newBuilder(name, dataType)
+ .nullable(nullable)
+ .comment(comment)
+ .generationExpression(generationExpression)
+ .metadataInJSON(metadataInJSON)
+ .build();
}
- /**
- * Creates a column with a generation expression object.
- *
- * @since 4.3.0
- */
static Column create(
String name,
DataType dataType,
boolean nullable,
String comment,
- GenerationExpression generationExpression,
+ IdentityColumnSpec identityColumnSpec,
String metadataInJSON) {
- return new ColumnImpl(
- name,
- dataType,
- nullable,
- comment,
- /* defaultValue = */ null,
- generationExpression,
- /* identityColumnSpec = */ null,
- metadataInJSON,
- /* id = */ null);
+ return newBuilder(name, dataType)
+ .nullable(nullable)
+ .comment(comment)
+ .identityColumnSpec(identityColumnSpec)
+ .metadataInJSON(metadataInJSON)
+ .build();
}
- static Column create(
- String name,
- DataType dataType,
- boolean nullable,
- String comment,
- IdentityColumnSpec identityColumnSpec,
- String metadataInJSON) {
- return new ColumnImpl(
- name,
- dataType,
- nullable,
- comment,
- /* defaultValue = */ null,
- /* generationExpression = */ null,
- identityColumnSpec,
- metadataInJSON,
- /* id = */ null);
+ /**
+ * Creates a builder for a column.
+ *
+ * @param name the name of the column
+ * @param dataType the data type of the column
+ * @return a new builder
+ * @since 4.2.0
Review Comment:
Intentional to be cherry-picked into 4.2.
--
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]