snazy commented on code in PR #9905: URL: https://github.com/apache/iceberg/pull/9905#discussion_r1680492194
########## orc/src/test/java/org/apache/iceberg/orc/TestBuildOrcProjection.java: ########## @@ -23,7 +23,9 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; +import org.apache.hadoop.conf.Configuration; Review Comment: Please clean those up ########## orc/src/main/java/org/apache/iceberg/orc/ORCSchemaUtil.java: ########## @@ -296,24 +304,36 @@ private static TypeDescription buildOrcProjection( list.elementId(), list.elementType(), isRequired && list.isElementRequired(), - mapping); + mapping, + config); orcType = TypeDescription.createList(elementType); break; case MAP: Types.MapType map = (Types.MapType) type; TypeDescription keyType = - buildOrcProjection(map.keyId(), map.keyType(), isRequired, mapping); + buildOrcProjection(map.keyId(), map.keyType(), isRequired, mapping, config); TypeDescription valueType = buildOrcProjection( - map.valueId(), map.valueType(), isRequired && map.isValueRequired(), mapping); + map.valueId(), + map.valueType(), + isRequired && map.isValueRequired(), + mapping, + config); orcType = TypeDescription.createMap(keyType, valueType); break; default: if (mapping.containsKey(fieldId)) { TypeDescription originalType = mapping.get(fieldId).type(); Optional<TypeDescription> promotedType = getPromotedType(type, originalType); - if (promotedType.isPresent()) { + boolean convertTimestampTZ = + config.getBoolean(ConfigProperties.ORC_CONVERT_TIMESTAMPTZ, false); + + if (convertTimestampTZ + && type.typeId() == Type.TypeID.TIMESTAMP Review Comment: Fair enough ########## orc/src/main/java/org/apache/iceberg/orc/ORCSchemaUtil.java: ########## @@ -261,12 +261,30 @@ public static Schema convert(TypeDescription orcSchema) { */ public static TypeDescription buildOrcProjection( Schema schema, TypeDescription originalOrcSchema) { + return buildOrcProjection(schema, originalOrcSchema, false); + } + + /** + * Overload function `buildOrcProjection` + * + * @param schema an Iceberg schema + * @param originalOrcSchema an existing ORC file schema + * @param convertTimestampTZ should convert timestamptz as timestamp + * @return the resulting ORC schema + */ + public static TypeDescription buildOrcProjection( + Schema schema, TypeDescription originalOrcSchema, Boolean convertTimestampTZ) { final Map<Integer, OrcField> icebergToOrc = icebergToOrcMapping("root", originalOrcSchema); - return buildOrcProjection(Integer.MIN_VALUE, schema.asStruct(), true, icebergToOrc); + return buildOrcProjection( + Integer.MIN_VALUE, schema.asStruct(), true, icebergToOrc, convertTimestampTZ); } private static TypeDescription buildOrcProjection( - Integer fieldId, Type type, boolean isRequired, Map<Integer, OrcField> mapping) { + Integer fieldId, + Type type, + boolean isRequired, + Map<Integer, OrcField> mapping, + Boolean convertTimestampTZ) { Review Comment: This shouldn't be a boxed type -- 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: issues-unsubscr...@iceberg.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For additional commands, e-mail: issues-h...@iceberg.apache.org