huaxingao commented on code in PR #14407:
URL: https://github.com/apache/iceberg/pull/14407#discussion_r2471070152
##########
spark/v4.0/spark/src/main/java/org/apache/iceberg/spark/TypeToSparkType.java:
##########
@@ -69,6 +70,19 @@ public DataType struct(Types.StructType struct,
List<DataType> fieldResults) {
if (field.doc() != null) {
sparkField = sparkField.withComment(field.doc());
}
+ // Convert both write and initial default values to Spark SQL string
literal representations
Review Comment:
nit: shall we put a blank line before this? We generally put an empty line
after control block.
##########
spark/v4.0/spark/src/main/java/org/apache/iceberg/spark/TypeToSparkType.java:
##########
@@ -69,6 +70,19 @@ public DataType struct(Types.StructType struct,
List<DataType> fieldResults) {
if (field.doc() != null) {
sparkField = sparkField.withComment(field.doc());
}
+ // Convert both write and initial default values to Spark SQL string
literal representations
+ // on the StructField metadata
+ if (field.writeDefault() != null) {
+ Object writeDefault = SparkUtil.internalToSpark(field.type(),
field.writeDefault());
+ sparkField =
+
sparkField.withCurrentDefaultValue(Literal$.MODULE$.create(writeDefault,
type).sql());
+ }
Review Comment:
nit: a blank line after this?
##########
spark/v4.0/spark/src/main/java/org/apache/iceberg/spark/TypeToSparkType.java:
##########
@@ -69,6 +70,19 @@ public DataType struct(Types.StructType struct,
List<DataType> fieldResults) {
if (field.doc() != null) {
sparkField = sparkField.withComment(field.doc());
}
+ // Convert both write and initial default values to Spark SQL string
literal representations
+ // on the StructField metadata
+ if (field.writeDefault() != null) {
+ Object writeDefault = SparkUtil.internalToSpark(field.type(),
field.writeDefault());
+ sparkField =
+
sparkField.withCurrentDefaultValue(Literal$.MODULE$.create(writeDefault,
type).sql());
+ }
+ if (field.initialDefault() != null) {
+ Object initialDefault = SparkUtil.internalToSpark(field.type(),
field.initialDefault());
+ sparkField =
+ sparkField.withExistenceDefaultValue(
+ Literal$.MODULE$.create(initialDefault, type).sql());
+ }
Review Comment:
nit? add a blank line?
--
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]