zhangbutao commented on code in PR #4573:
URL: https://github.com/apache/hive/pull/4573#discussion_r1384392286
##########
iceberg/iceberg-handler/src/main/java/org/apache/iceberg/mr/hive/HiveIcebergMetaHook.java:
##########
@@ -966,14 +970,31 @@ private boolean
isOrcOnlyFiles(org.apache.hadoop.hive.metastore.api.Table hmsTab
}
// TODO: remove this if copy-on-write mode gets implemented in Hive
- private static void setDeleteModeOnTableProperties(Table icebergTable,
Map<String, String> newProps) {
+ private void setDeleteModeOnTableProperties(Table icebergTbl, Map<String,
String> newProps,
+ EnvironmentContext context) {
// Hive only supports merge-on-read delete mode, it will actually throw an
error if DML operations are attempted on
// tables that don't have this (the default is copy-on-write). We set this
at table creation and v1->v2 conversion.
- if ((icebergTable == null || ((BaseTable)
icebergTable).operations().current().formatVersion() == 1) &&
+ if ((icebergTbl == null || ((BaseTable)
icebergTbl).operations().current().formatVersion() == 1) &&
IcebergTableUtil.isV2Table(newProps)) {
- newProps.put(TableProperties.DELETE_MODE,
HiveIcebergStorageHandler.MERGE_ON_READ);
- newProps.put(TableProperties.UPDATE_MODE,
HiveIcebergStorageHandler.MERGE_ON_READ);
- newProps.put(TableProperties.MERGE_MODE,
HiveIcebergStorageHandler.MERGE_ON_READ);
+ List<String> writeModeList = Arrays.asList(DELETE_MODE, UPDATE_MODE,
MERGE_MODE);
+ writeModeList.stream()
+ .filter(writeMode -> catalogProperties.get(writeMode) == null)
+ .forEach(writeMode -> {
+ catalogProperties.put(writeMode,
HiveIcebergStorageHandler.MERGE_ON_READ);
+ newProps.put(writeMode, HiveIcebergStorageHandler.MERGE_ON_READ);
+ });
+
+ if (context != null) {
+ Splitter splitter = Splitter.on(PROPERTIES_SEPARATOR);
+ Map<String, String> contextProperties = context.getProperties();
+ if (contextProperties.containsKey(SET_PROPERTIES)) {
+ final String[] propValue =
{context.getProperties().get(SET_PROPERTIES)};
+ writeModeList.stream()
+ .filter(writeMode ->
!splitter.splitToList(propValue[0]).contains(writeMode))
+ .map(writeMode -> propValue[0] += "'" + writeMode)
Review Comment:
My bad, in fact, we only need to update the `SET_PROPERTIES` once at the
end.
Refine this code snippet in
https://github.com/apache/hive/pull/4573/commits/0580d1a1227d04108c54a1247159c6b3c00c6535
--
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]