marton-bod commented on a change in pull request #2603:
URL: https://github.com/apache/hive/pull/2603#discussion_r697251253
##########
File path:
iceberg/iceberg-handler/src/main/java/org/apache/iceberg/mr/hive/HiveIcebergOutputCommitter.java
##########
@@ -328,13 +329,18 @@ private void commitTable(FileIO io, ExecutorService
executor, JobContext jobCont
boolean isOverwrite = conf.getBoolean(InputFormatConfig.IS_OVERWRITE,
false);
if (isOverwrite) {
- // Replacing affected partitions (or whole table) since it's an insert
overwrite
- // We do the replacement even for 0 data files (i.e. empty source)
- ReplacePartitions overwrite = table.newReplacePartitions();
- dataFiles.forEach(overwrite::addFile);
- overwrite.commit();
- LOG.info("Overwrite commit took {} ms for table: {} with {} file(s)",
System.currentTimeMillis() - startTime,
- table, dataFiles.size());
+ if (!dataFiles.isEmpty()) {
+ ReplacePartitions overwrite = table.newReplacePartitions();
+ dataFiles.forEach(overwrite::addFile);
+ overwrite.commit();
+ LOG.info("Overwrite commit took {} ms for table: {} with {} file(s)",
System.currentTimeMillis() - startTime,
+ table, dataFiles.size());
+ } else if (table.spec().isUnpartitioned()) {
+ // TODO: we won't get here if we have a formerly-partitioned table,
whose partition specs have been turned void
+
table.newDelete().deleteFromRowFilter(Expressions.alwaysTrue()).commit();
Review comment:
to keep the original Hive behaviour (for unpartitioned table, empty IOW
clears the table), I've put a truncate-style logic here for deleting data from
the table when overwriting with an empty input. Do you see any concerns?
--
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]