Mark unpartitioned table in HiveWrittenPartitions
We already use "<UNPARTITIONED>" for unpartitioned table input, and
this commit would unify the representation of unpartitioned table in
output as well.
@@ -135,6 +135,7 @@ import static com.facebook.presto.hive.HiveErrorCode.HIVE_TIMEZONE_MISMATCH;
import static com.facebook.presto.hive.HiveErrorCode.HIVE_UNKNOWN_ERROR;
import static com.facebook.presto.hive.HiveErrorCode.HIVE_UNSUPPORTED_FORMAT;
import static com.facebook.presto.hive.HiveErrorCode.HIVE_WRITER_CLOSE_ERROR;
+import static com.facebook.presto.hive.HivePartition.UNPARTITIONED_ID;
import static com.facebook.presto.hive.HivePartitionManager.extractPartitionValues;
import static com.facebook.presto.hive.HiveSessionProperties.getHiveStorageFormat;
import static com.facebook.presto.hive.HiveSessionProperties.getTemporaryTableSchema;
@@ -1191,7 +1192,10 @@ public class HiveMetadata
metastore.createTable(session, table, principalPrivileges, Optional.of(writeInfo.getWritePath()), false, tableStatistics);
- if (!handle.getPartitionedBy().isEmpty()) {
+ if (handle.getPartitionedBy().isEmpty()) {
+ return Optional.of(new HiveWrittenPartitions(ImmutableList.of(UNPARTITIONED_ID)));
+ }
+
if (isRespectTableFormat(session)) {
Verify.verify(handle.getPartitionStorageFormat() == handle.getTableStorageFormat());
}
@@ -1210,7 +1214,6 @@ public class HiveMetadata
update.getWritePath(),
partitionStatistics);
}
- }
return Optional.of(new HiveWrittenPartitions(
partitionUpdates.stream()
@@ -1489,6 +1492,7 @@ public class HiveMetadata
return Optional.of(new HiveWrittenPartitions(
partitionUpdates.stream()
.map(PartitionUpdate::getName)
+ .map(name -> name.isEmpty() ? UNPARTITIONED_ID : name)
.collect(Collectors.toList())));
}
