ayushtkn commented on code in PR #4453:
URL: https://github.com/apache/hive/pull/4453#discussion_r1245202305
##########
iceberg/iceberg-handler/src/main/java/org/apache/iceberg/mr/hive/HiveTableUtil.java:
##########
@@ -182,24 +183,41 @@ private static List<DataFile>
getDataFiles(RemoteIterator<LocatedFileStatus> fil
return dataFiles;
}
- public static void appendFiles(URI fromURI, String format, Table icebergTbl,
boolean isOverwrite, Configuration conf)
- throws SemanticException {
+ public static void appendFiles(URI fromURI, String format, Table icebergTbl,
boolean isOverwrite,
+ Map<String, String> partitionSpec, Configuration conf) throws
SemanticException {
try {
Transaction transaction = icebergTbl.newTransaction();
if (isOverwrite) {
DeleteFiles delete = transaction.newDelete();
- delete.deleteFromRowFilter(Expressions.alwaysTrue());
+ if (partitionSpec != null) {
+ for (Map.Entry<String, String> part : partitionSpec.entrySet()) {
+ delete.deleteFromRowFilter(Expressions.equal(part.getKey(),
+
Conversions.fromPartitionString(icebergTbl.schema().findType(part.getKey()),
part.getValue())));
+ }
+ } else {
+ delete.deleteFromRowFilter(Expressions.alwaysTrue());
+ }
delete.commit();
}
- AppendFiles append = transaction.newAppend();
- PartitionSpec spec = icebergTbl.spec();
+
MetricsConfig metricsConfig =
MetricsConfig.fromProperties(icebergTbl.properties());
+ PartitionSpec spec = icebergTbl.spec();
String nameMappingString =
icebergTbl.properties().get(TableProperties.DEFAULT_NAME_MAPPING);
NameMapping nameMapping = nameMappingString != null ?
NameMappingParser.fromJson(nameMappingString) : null;
- RemoteIterator<LocatedFileStatus> filesIterator =
HiveTableUtil.getFilesIterator(new Path(fromURI), conf);
- List<DataFile> dataFiles = HiveTableUtil.getDataFiles(filesIterator,
Collections.emptyMap(),
- format == null ? IOConstants.PARQUET : format, spec, metricsConfig,
nameMapping, conf);
- dataFiles.forEach(append::appendFile);
+ AppendFiles append = transaction.newAppend();
+ String actualFormat = format == null ? IOConstants.PARQUET.toLowerCase()
: format.toLowerCase();
+ if (partitionSpec != null && !partitionSpec.isEmpty()) {
Review Comment:
had to introduce another variable, spotless cries, if you assign to a
parameter
--
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]