You are viewing a plain text version of this content. The canonical link for it is here.
Posted to gitbox@hive.apache.org by "difin (via GitHub)" <gi...@apache.org> on 2023/07/11 14:15:14 UTC

[GitHub] [hive] difin opened a new pull request, #4477: HIVE-27050: Restrict reducer extrapolation to contain number of small…

difin opened a new pull request, #4477:
URL: https://github.com/apache/hive/pull/4477

   … files being created for Iceberg tables.
   
   <!--
   Thanks for sending a pull request!  Here are some tips for you:
     1. If this is your first time, please read our contributor guidelines: https://cwiki.apache.org/confluence/display/Hive/HowToContribute
     2. Ensure that you have created an issue on the Hive project JIRA: https://issues.apache.org/jira/projects/HIVE/summary
     3. Ensure you have added or run the appropriate tests for your PR: 
     4. If the PR is unfinished, add '[WIP]' in your PR title, e.g., '[WIP]HIVE-XXXXX:  Your PR title ...'.
     5. Be sure to keep the PR description updated to reflect all changes.
     6. Please write your PR title to summarize what this PR proposes.
     7. If possible, provide a concise example to reproduce the issue for a faster review.
   
   -->
   
   ### What changes were proposed in this pull request?
   <!--
   Please clarify what changes you are proposing. The purpose of this section is to outline the changes and how this PR fixes the issue. 
   If possible, please consider writing useful notes for better and faster reviews in your PR. See the examples below.
     1. If you refactor some codes with changing classes, showing the class hierarchy will help reviewers.
     2. If you fix some SQL features, you can provide some references of other DBMSes.
     3. If there is design documentation, please add the link.
     4. If there is a discussion in the mailing list, please add the link.
   -->
   Setting "hive.tez.max.partition.factor" to "1.0" for Iceberg tables. 
   
   ### Why are the changes needed?
   <!--
   Please clarify why the changes are needed. For instance,
     1. If you propose a new API, clarify the use case for a new API.
     2. If you fix a bug, you can clarify why it is a bug.
   -->
   When Iceberg MOR tables are involved in update/delete/merges, Hive estimates the number of reducers as "1". But due to "hive.tez.max.partition.factor" which defaults to "2.0", it will double the number of reducers.
   It creates very small positional delete files spreading across different reducers. This will cause problems during reading, as all files should be opened for reading.
   
   ### Does this PR introduce _any_ user-facing change?
   <!--
   Note that it means *any* user-facing change including all aspects such as the documentation fix.
   If yes, please clarify the previous behavior and the change this PR proposes - provide the console output, description, screenshot and/or a reproducable example to show the behavior difference if possible.
   If possible, please also clarify if this is a user-facing change compared to the released Hive versions or within the unreleased branches such as master.
   If no, write 'No'.
   -->
   No
   
   ### Is the change a dependency upgrade?
   <!--
   If yes, please attach a file with output from mvn dependency:tree to validate a complete upgrade of dependency.
   If no, write 'No'.
   -->
   No
   
   ### How was this patch tested?
   <!--
   If tests were added, say they were added here. Please make sure to add some test cases that check the changes thoroughly including negative and positive cases if possible.
   If it was tested in a way different from regular unit tests, please clarify how you tested step by step, ideally copy and paste-able, so that other reviewers can test and check, and descendants can verify in the future.
   If tests were not added, please describe why they were not added and/or why it was difficult to add.
   -->
   Passing pre-commit tests.


-- 
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: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] sonarcloud[bot] commented on pull request #4477: HIVE-27050: Restrict reducer extrapolation to contain number of small…

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #4477:
URL: https://github.com/apache/hive/pull/4477#issuecomment-1631489705

   Kudos, SonarCloud Quality Gate passed!&nbsp; &nbsp; [![Quality Gate passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/passed-16px.png 'Quality Gate passed')](https://sonarcloud.io/dashboard?id=apache_hive&pullRequest=4477)
   
   [![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png 'Bug')](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=4477&resolved=false&types=BUG) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=4477&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=4477&resolved=false&types=BUG)  
   [![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png 'Vulnerability')](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=4477&resolved=false&types=VULNERABILITY) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=4477&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=4477&resolved=false&types=VULNERABILITY)  
   [![Security Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png 'Security Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache_hive&pullRequest=4477&resolved=false&types=SECURITY_HOTSPOT) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/security_hotspots?id=apache_hive&pullRequest=4477&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_hive&pullRequest=4477&resolved=false&types=SECURITY_HOTSPOT)  
   [![Code Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png 'Code Smell')](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=4477&resolved=false&types=CODE_SMELL) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=4477&resolved=false&types=CODE_SMELL) [0 Code Smells](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=4477&resolved=false&types=CODE_SMELL)
   
   [![No Coverage information](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/NoCoverageInfo-16px.png 'No Coverage information')](https://sonarcloud.io/component_measures?id=apache_hive&pullRequest=4477&metric=coverage&view=list) No Coverage information  
   [![No Duplication information](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/NoDuplicationInfo-16px.png 'No Duplication information')](https://sonarcloud.io/component_measures?id=apache_hive&pullRequest=4477&metric=duplicated_lines_density&view=list) No Duplication information
   
   


-- 
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: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] aturoczy commented on a diff in pull request #4477: HIVE-27050: Restrict reducer extrapolation to contain number of small…

Posted by "aturoczy (via GitHub)" <gi...@apache.org>.
aturoczy commented on code in PR #4477:
URL: https://github.com/apache/hive/pull/4477#discussion_r1263143875


##########
iceberg/iceberg-handler/src/main/java/org/apache/iceberg/mr/hive/HiveIcebergSerDe.java:
##########
@@ -148,6 +148,7 @@ public void initialize(@Nullable Configuration configuration, Properties serDePr
     // TODO: remove once we have both Fanout and ClusteredWriter available: HIVE-25948
     HiveConf.setIntVar(configuration, HiveConf.ConfVars.HIVEOPTSORTDYNAMICPARTITIONTHRESHOLD, 1);
     HiveConf.setVar(configuration, HiveConf.ConfVars.DYNAMICPARTITIONINGMODE, "nonstrict");
+    HiveConf.setFloatVar(configuration, HiveConf.ConfVars.TEZ_MAX_PARTITION_FACTOR, 1f);

Review Comment:
   @okumin Nice catch!



-- 
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: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] okumin commented on a diff in pull request #4477: HIVE-27050: Restrict reducer extrapolation to contain number of small…

Posted by "okumin (via GitHub)" <gi...@apache.org>.
okumin commented on code in PR #4477:
URL: https://github.com/apache/hive/pull/4477#discussion_r1266998178


##########
iceberg/iceberg-handler/src/main/java/org/apache/iceberg/mr/hive/HiveIcebergSerDe.java:
##########
@@ -148,6 +148,14 @@ public void initialize(@Nullable Configuration configuration, Properties serDePr
     // TODO: remove once we have both Fanout and ClusteredWriter available: HIVE-25948
     HiveConf.setIntVar(configuration, HiveConf.ConfVars.HIVEOPTSORTDYNAMICPARTITIONTHRESHOLD, 1);
     HiveConf.setVar(configuration, HiveConf.ConfVars.DYNAMICPARTITIONINGMODE, "nonstrict");
+
+    Context.Operation operation = HiveCustomStorageHandlerUtils.getWriteOperation(configuration,
+            serDeProperties.getProperty(Catalogs.NAME));
+
+    if (operation != null) {
+      HiveConf.setFloatVar(configuration, HiveConf.ConfVars.TEZ_MAX_PARTITION_FACTOR, 1f);

Review Comment:
   I personally think it is reasonable to explicitly inject the logic into GenTezUtils or somewhere. One request is I'd like to make it pluggable because other formats would hit the same issue. As far as I checked on my machine, Hive ACID shares the problem. Note that these are my opinions and committers could have different ideas, or they might think it is an expected behavior.
   
   As for the parameter, I guess you tested it with 4.0.0-alpha-2 since the param was merged recently. It enforces auto reduce parallelism.
   
   ```
   $ beeline -e "
   > DROP TABLE IF EXISTS test;
   > CREATE TABLE test (id INT) STORED BY ICEBERG TBLPROPERTIES('format-version'='2');
   > INSERT INTO test VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10);
   > "
   ```
   
   ```
   $ beeline -e 'DELETE FROM test WHERE id = 5' --hiveconf hive.server2.in.place.progress=false --hiveconf hive.tez.auto.reducer.parallelism=true
   ...
   INFO  : 2023-07-18 14:19:45,200	Map 1: 0(+1)/1	Reducer 2: 0/2	
   INFO  : 2023-07-18 14:19:48,227	Map 1: 1/1	Reducer 2: 0(+1)/2
   ...
   $ beeline -e 'DELETE FROM test WHERE id = 5' --hiveconf hive.server2.in.place.progress=false --hiveconf hive.tez.auto.reducer.parallelism=true --hiveconf hive.tez.auto.reducer.parallelism.min.threshold=0.0
   ...
   INFO  : 2023-07-18 14:20:23,730	Map 1: 0(+1)/1	Reducer 2: 0/2	
   INFO  : 2023-07-18 14:20:27,271	Map 1: 1/1	Reducer 2: 0(+1)/1
   ```



-- 
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: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] deniskuzZ commented on a diff in pull request #4477: HIVE-27050: Restrict reducer extrapolation to contain number of small…

Posted by "deniskuzZ (via GitHub)" <gi...@apache.org>.
deniskuzZ commented on code in PR #4477:
URL: https://github.com/apache/hive/pull/4477#discussion_r1277480953


##########
ql/src/java/org/apache/hadoop/hive/ql/parse/GenTezUtils.java:
##########
@@ -76,6 +79,20 @@ public static UnionWork createUnionWork(
     tezWork.add(unionWork);
     return unionWork;
   }
+  
+  private static boolean isRestrictReducerExtrapolation(GenTezProcContext context) {

Review Comment:
   could we refactor to
   ````
     private static boolean isRestrictReducerExtrapolation(Context context) {
       return context.getOperation() == Context.Operation.DELETE && context.getLoadTableOutputMap().values()
         .stream().map(WriteEntity::getTable).anyMatch(DDLUtils::isIcebergTable);
     }
   -> isRestrictReducerExtrapolation(context.parseContext.getContext())
   ````



-- 
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: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] difin commented on a diff in pull request #4477: HIVE-27050: Restrict reducer extrapolation to contain number of small…

Posted by "difin (via GitHub)" <gi...@apache.org>.
difin commented on code in PR #4477:
URL: https://github.com/apache/hive/pull/4477#discussion_r1275341631


##########
ql/src/java/org/apache/hadoop/hive/ql/parse/GenTezUtils.java:
##########
@@ -76,6 +80,24 @@ public static UnionWork createUnionWork(
     tezWork.add(unionWork);
     return unionWork;
   }
+  
+  private static boolean isRestrictReducerExtrapolation(GenTezProcContext context) {
+
+    Table table = context.parseContext.getContext().getLoadTableOutputMap().values()
+            .stream().findFirst().get().getTable();
+
+    // Iceberg table
+    if (DDLUtils.isIcebergTable(table)) {

Review Comment:
   Yes, the properties of `reduceSink.getConf().getKeySerializeInfo().properties` don't include info that can help determining table type:
   
   ```
   serialization.sort.order.null=zzzz, 
   columns=reducesinkkey0,reducesinkkey1,reducesinkkey2,reducesinkkey3, serialization.lib=org.apache.hadoop.hive.serde2.binarysortable.BinarySortableSerDe, 
   serialization.sort.order=++++, 
   columns.types=int,bigint,string,bigint, 
   column.name.delimiter=,
   ```



-- 
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: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] sonarcloud[bot] commented on pull request #4477: HIVE-27050: Restrict reducer extrapolation to contain number of small…

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #4477:
URL: https://github.com/apache/hive/pull/4477#issuecomment-1650118823

   Kudos, SonarCloud Quality Gate passed!&nbsp; &nbsp; [![Quality Gate passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/passed-16px.png 'Quality Gate passed')](https://sonarcloud.io/dashboard?id=apache_hive&pullRequest=4477)
   
   [![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png 'Bug')](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=4477&resolved=false&types=BUG) [![C](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/C-16px.png 'C')](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=4477&resolved=false&types=BUG) [1 Bug](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=4477&resolved=false&types=BUG)  
   [![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png 'Vulnerability')](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=4477&resolved=false&types=VULNERABILITY) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=4477&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=4477&resolved=false&types=VULNERABILITY)  
   [![Security Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png 'Security Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache_hive&pullRequest=4477&resolved=false&types=SECURITY_HOTSPOT) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/security_hotspots?id=apache_hive&pullRequest=4477&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_hive&pullRequest=4477&resolved=false&types=SECURITY_HOTSPOT)  
   [![Code Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png 'Code Smell')](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=4477&resolved=false&types=CODE_SMELL) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=4477&resolved=false&types=CODE_SMELL) [1 Code Smell](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=4477&resolved=false&types=CODE_SMELL)
   
   [![No Coverage information](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/NoCoverageInfo-16px.png 'No Coverage information')](https://sonarcloud.io/component_measures?id=apache_hive&pullRequest=4477&metric=coverage&view=list) No Coverage information  
   [![No Duplication information](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/NoDuplicationInfo-16px.png 'No Duplication information')](https://sonarcloud.io/component_measures?id=apache_hive&pullRequest=4477&metric=duplicated_lines_density&view=list) No Duplication information
   
   


-- 
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: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] difin commented on a diff in pull request #4477: HIVE-27050: Restrict reducer extrapolation to contain number of small…

Posted by "difin (via GitHub)" <gi...@apache.org>.
difin commented on code in PR #4477:
URL: https://github.com/apache/hive/pull/4477#discussion_r1270977357


##########
ql/src/java/org/apache/hadoop/hive/ql/ddl/DDLUtils.java:
##########
@@ -231,10 +231,17 @@ public static void validateTableIsIceberg(org.apache.hadoop.hive.ql.metadata.Tab
   }
 
   public static boolean isIcebergTable(Table table) {
-    return table.isNonNative() && 
-            table.getStorageHandler().getType() == StorageHandlerTypes.ICEBERG;
+    return table.isNonNative() &&
+            ((table.getStorageHandler() != null && table.getStorageHandler().getType() == StorageHandlerTypes.ICEBERG) || 
+                    isIcebergTableType(table.getTTable().getParameters()));

Review Comment:
   Fixed @ retested using MiniHS2Cluster for Iceberg and Hive ACID tables.



-- 
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: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] sonarcloud[bot] commented on pull request #4477: HIVE-27050: Restrict reducer extrapolation to contain number of small…

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #4477:
URL: https://github.com/apache/hive/pull/4477#issuecomment-1656134972

   Kudos, SonarCloud Quality Gate passed!&nbsp; &nbsp; [![Quality Gate passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/passed-16px.png 'Quality Gate passed')](https://sonarcloud.io/dashboard?id=apache_hive&pullRequest=4477)
   
   [![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png 'Bug')](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=4477&resolved=false&types=BUG) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=4477&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=4477&resolved=false&types=BUG)  
   [![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png 'Vulnerability')](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=4477&resolved=false&types=VULNERABILITY) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=4477&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=4477&resolved=false&types=VULNERABILITY)  
   [![Security Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png 'Security Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache_hive&pullRequest=4477&resolved=false&types=SECURITY_HOTSPOT) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/security_hotspots?id=apache_hive&pullRequest=4477&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_hive&pullRequest=4477&resolved=false&types=SECURITY_HOTSPOT)  
   [![Code Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png 'Code Smell')](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=4477&resolved=false&types=CODE_SMELL) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=4477&resolved=false&types=CODE_SMELL) [2 Code Smells](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=4477&resolved=false&types=CODE_SMELL)
   
   [![No Coverage information](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/NoCoverageInfo-16px.png 'No Coverage information')](https://sonarcloud.io/component_measures?id=apache_hive&pullRequest=4477&metric=coverage&view=list) No Coverage information  
   [![No Duplication information](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/NoDuplicationInfo-16px.png 'No Duplication information')](https://sonarcloud.io/component_measures?id=apache_hive&pullRequest=4477&metric=duplicated_lines_density&view=list) No Duplication information
   
   


-- 
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: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] sonarcloud[bot] commented on pull request #4477: HIVE-27050: Restrict reducer extrapolation to contain number of small…

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #4477:
URL: https://github.com/apache/hive/pull/4477#issuecomment-1648572225

   Kudos, SonarCloud Quality Gate passed!&nbsp; &nbsp; [![Quality Gate passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/passed-16px.png 'Quality Gate passed')](https://sonarcloud.io/dashboard?id=apache_hive&pullRequest=4477)
   
   [![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png 'Bug')](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=4477&resolved=false&types=BUG) [![C](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/C-16px.png 'C')](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=4477&resolved=false&types=BUG) [1 Bug](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=4477&resolved=false&types=BUG)  
   [![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png 'Vulnerability')](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=4477&resolved=false&types=VULNERABILITY) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=4477&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=4477&resolved=false&types=VULNERABILITY)  
   [![Security Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png 'Security Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache_hive&pullRequest=4477&resolved=false&types=SECURITY_HOTSPOT) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/security_hotspots?id=apache_hive&pullRequest=4477&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_hive&pullRequest=4477&resolved=false&types=SECURITY_HOTSPOT)  
   [![Code Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png 'Code Smell')](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=4477&resolved=false&types=CODE_SMELL) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=4477&resolved=false&types=CODE_SMELL) [1 Code Smell](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=4477&resolved=false&types=CODE_SMELL)
   
   [![No Coverage information](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/NoCoverageInfo-16px.png 'No Coverage information')](https://sonarcloud.io/component_measures?id=apache_hive&pullRequest=4477&metric=coverage&view=list) No Coverage information  
   [![No Duplication information](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/NoDuplicationInfo-16px.png 'No Duplication information')](https://sonarcloud.io/component_measures?id=apache_hive&pullRequest=4477&metric=duplicated_lines_density&view=list) No Duplication information
   
   


-- 
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: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] deniskuzZ commented on a diff in pull request #4477: HIVE-27050: Restrict reducer extrapolation to contain number of small…

Posted by "deniskuzZ (via GitHub)" <gi...@apache.org>.
deniskuzZ commented on code in PR #4477:
URL: https://github.com/apache/hive/pull/4477#discussion_r1272015311


##########
ql/src/java/org/apache/hadoop/hive/ql/parse/GenTezUtils.java:
##########
@@ -86,6 +108,13 @@ public static ReduceWork createReduceWork(
 
     float maxPartitionFactor =
         context.conf.getFloatVar(HiveConf.ConfVars.TEZ_MAX_PARTITION_FACTOR);
+    
+    if (context.parseContext.getContext().getOperation() == Context.Operation.DELETE &&
+            isRestrictReducerExtrapolation(context)) {
+      LOG.debug("Overriding maxPartitionFactor to 1.0 to prevent creation of small files after delete operation");
+      maxPartitionFactor = 1f;

Review Comment:
   I am not sure it's required for ACID tables as we have built-in compaction support



-- 
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: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] okumin commented on a diff in pull request #4477: HIVE-27050: Restrict reducer extrapolation to contain number of small…

Posted by "okumin (via GitHub)" <gi...@apache.org>.
okumin commented on code in PR #4477:
URL: https://github.com/apache/hive/pull/4477#discussion_r1261136066


##########
iceberg/iceberg-handler/src/main/java/org/apache/iceberg/mr/hive/HiveIcebergSerDe.java:
##########
@@ -148,6 +148,7 @@ public void initialize(@Nullable Configuration configuration, Properties serDePr
     // TODO: remove once we have both Fanout and ClusteredWriter available: HIVE-25948
     HiveConf.setIntVar(configuration, HiveConf.ConfVars.HIVEOPTSORTDYNAMICPARTITIONTHRESHOLD, 1);
     HiveConf.setVar(configuration, HiveConf.ConfVars.DYNAMICPARTITIONINGMODE, "nonstrict");
+    HiveConf.setFloatVar(configuration, HiveConf.ConfVars.TEZ_MAX_PARTITION_FACTOR, 1f);

Review Comment:
   Is it OK to apply this one to all vertices including non insert reducers?



-- 
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: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] difin commented on a diff in pull request #4477: HIVE-27050: Restrict reducer extrapolation to contain number of small…

Posted by "difin (via GitHub)" <gi...@apache.org>.
difin commented on code in PR #4477:
URL: https://github.com/apache/hive/pull/4477#discussion_r1272676510


##########
ql/src/java/org/apache/hadoop/hive/ql/parse/GenTezUtils.java:
##########
@@ -76,6 +80,24 @@ public static UnionWork createUnionWork(
     tezWork.add(unionWork);
     return unionWork;
   }
+  
+  private static boolean isRestrictReducerExtrapolation(GenTezProcContext context) {
+
+    Table table = context.parseContext.getContext().getLoadTableOutputMap().values()
+            .stream().findFirst().get().getTable();
+
+    // Iceberg table
+    if (DDLUtils.isIcebergTable(table)) {
+      return true;
+    }
+
+    // Hive ACID table
+    if (!table.isNonNative() && AcidUtils.isTransactionalTable(table)) {

Review Comment:
   Done, removed.



##########
ql/src/java/org/apache/hadoop/hive/ql/parse/GenTezUtils.java:
##########
@@ -86,6 +108,13 @@ public static ReduceWork createReduceWork(
 
     float maxPartitionFactor =
         context.conf.getFloatVar(HiveConf.ConfVars.TEZ_MAX_PARTITION_FACTOR);
+    
+    if (context.parseContext.getContext().getOperation() == Context.Operation.DELETE &&
+            isRestrictReducerExtrapolation(context)) {

Review Comment:
   Done



-- 
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: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] difin commented on a diff in pull request #4477: HIVE-27050: Restrict reducer extrapolation to contain number of small…

Posted by "difin (via GitHub)" <gi...@apache.org>.
difin commented on code in PR #4477:
URL: https://github.com/apache/hive/pull/4477#discussion_r1272672272


##########
ql/src/java/org/apache/hadoop/hive/ql/parse/GenTezUtils.java:
##########
@@ -76,6 +80,24 @@ public static UnionWork createUnionWork(
     tezWork.add(unionWork);
     return unionWork;
   }
+  
+  private static boolean isRestrictReducerExtrapolation(GenTezProcContext context) {
+
+    Table table = context.parseContext.getContext().getLoadTableOutputMap().values()
+            .stream().findFirst().get().getTable();
+
+    // Iceberg table
+    if (DDLUtils.isIcebergTable(table)) {

Review Comment:
   I tried this with a deletion query from Iceberg table on my local using MiniHS2Cluster. 
   It didn't work because reduceWork.getKeyDesc() was null.



-- 
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: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] difin commented on a diff in pull request #4477: HIVE-27050: Restrict reducer extrapolation to contain number of small…

Posted by "difin (via GitHub)" <gi...@apache.org>.
difin commented on code in PR #4477:
URL: https://github.com/apache/hive/pull/4477#discussion_r1277779886


##########
ql/src/java/org/apache/hadoop/hive/ql/parse/GenTezUtils.java:
##########
@@ -76,6 +79,20 @@ public static UnionWork createUnionWork(
     tezWork.add(unionWork);
     return unionWork;
   }
+  
+  private static boolean isRestrictReducerExtrapolation(GenTezProcContext context) {

Review Comment:
   Done



-- 
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: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] deniskuzZ commented on a diff in pull request #4477: HIVE-27050: Restrict reducer extrapolation to contain number of small…

Posted by "deniskuzZ (via GitHub)" <gi...@apache.org>.
deniskuzZ commented on code in PR #4477:
URL: https://github.com/apache/hive/pull/4477#discussion_r1272045077


##########
ql/src/java/org/apache/hadoop/hive/ql/parse/GenTezUtils.java:
##########
@@ -76,6 +80,24 @@ public static UnionWork createUnionWork(
     tezWork.add(unionWork);
     return unionWork;
   }
+  
+  private static boolean isRestrictReducerExtrapolation(GenTezProcContext context) {
+
+    Table table = context.parseContext.getContext().getLoadTableOutputMap().values()
+            .stream().findFirst().get().getTable();
+
+    // Iceberg table
+    if (DDLUtils.isIcebergTable(table)) {

Review Comment:
   would that work `isIcebergTable(reduceWork.getKeyDesc().getProperties())` or `isIcebergTable(reduceSink.getConf().getKeySerializeInfo().getProperties())`?



-- 
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: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] okumin commented on a diff in pull request #4477: HIVE-27050: Restrict reducer extrapolation to contain number of small…

Posted by "okumin (via GitHub)" <gi...@apache.org>.
okumin commented on code in PR #4477:
URL: https://github.com/apache/hive/pull/4477#discussion_r1264613366


##########
iceberg/iceberg-handler/src/main/java/org/apache/iceberg/mr/hive/HiveIcebergSerDe.java:
##########
@@ -148,6 +148,14 @@ public void initialize(@Nullable Configuration configuration, Properties serDePr
     // TODO: remove once we have both Fanout and ClusteredWriter available: HIVE-25948
     HiveConf.setIntVar(configuration, HiveConf.ConfVars.HIVEOPTSORTDYNAMICPARTITIONTHRESHOLD, 1);
     HiveConf.setVar(configuration, HiveConf.ConfVars.DYNAMICPARTITIONINGMODE, "nonstrict");
+
+    Context.Operation operation = HiveCustomStorageHandlerUtils.getWriteOperation(configuration,
+            serDeProperties.getProperty(Catalogs.NAME));
+
+    if (operation != null) {
+      HiveConf.setFloatVar(configuration, HiveConf.ConfVars.TEZ_MAX_PARTITION_FACTOR, 1f);

Review Comment:
   I tested how this works as I am not confident. Please not that I am still a beginner of Iceberg and something could be wrong with my test.
   
   ## Test queries
   
   ### Prep
   
   ```
   beeline -e "
   DROP TABLE IF EXISTS test;
   CREATE TABLE test (id INT) STORED BY ICEBERG TBLPROPERTIES('format-version'='2');
   INSERT INTO test VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10);
   "
   ```
   
   ### DELETE
   
   ```
   beeline -e 'DELETE FROM test WHERE id = 5' --hiveconf hive.server2.in.place.progress=false --hiveconf hive.tez.auto.reducer.parallelism=true
   ```
   
   ## Test result
   
   ### The original version
   
   [This](https://github.com/okumin/hive/commit/59b84b9d7835f97b5e9df872ef00986678498976) is the tested revision. Two reducers are set up and launched as reported.
   
   ```
   $ beeline -e 'DELETE FROM test WHERE id = 5' --hiveconf hive.server2.in.place.progress=false --hiveconf hive.tez.auto.reducer.parallelism=true
   ...
   INFO  : 2023-07-16 04:55:39,740	Map 1: 0(+1)/1	Reducer 2: 0/2	
   INFO  : 2023-07-16 04:55:42,259	Map 1: 1/1	Reducer 2: 0(+1)/2
   ```
   
   ```
   $ ./bin/logs hive-hiveserver2-655b558bb-gzwh8 | grep HIVE-27050 | tail -n 1
   hive-hiveserver2-655b558bb-gzwh8: 2023-07-16T04:55:31,760  INFO [f3ecdcb4-f45b-405f-986e-0dbf525c7c87 HiveServer2-Handler-Pool: Thread-61] parse.GenTezUtils: HIVE-27050: max partition factor=2.0, max partition=2
   ```
   
   ### The first patch
   
   [This](https://github.com/okumin/hive/commit/a19ee2b5536539d066ecf77c369bc0f7bc85a2ca) is the tested revision. One reducer is set up and launched.
   
   ```
   $ beeline -e 'DELETE FROM test WHERE id = 5' --hiveconf hive.server2.in.place.progress=false --hiveconf hive.tez.auto.reducer.parallelism=true
   ...
   INFO  : 2023-07-16 05:22:30,905	Map 1: 0/1	Reducer 2: 0/1	
   INFO  : 2023-07-16 05:22:35,454	Map 1: 0(+1)/1	Reducer 2: 0/1
   ```
   
   ```
   $ ./bin/logs hive-hiveserver2-75bc6bc94c-bhxxc | grep HIVE-27050 | tail -n 1
   hive-hiveserver2-75bc6bc94c-bhxxc: 2023-07-16T05:22:23,324  INFO [18f9ace5-2016-4430-8155-ae95c254148b HiveServer2-Handler-Pool: Thread-61] parse.GenTezUtils: HIVE-27050: max partition factor=1.0, max partition=1
   ```
   
   ### The second(current) path
   
   [This](https://github.com/okumin/hive/commit/0e149323aa07b661a0c8eb259fa514bcb72c02a9) is the tested revision. It is unlikely to be working as expected.
   
   ```
   $ beeline -e 'DELETE FROM test WHERE id = 5' --hiveconf hive.server2.in.place.progress=false --hiveconf hive.tez.auto.reducer.parallelism=true
   ...
   INFO  : 2023-07-16 05:58:27,235	Map 1: 1/1	Reducer 2: 0/2	
   INFO  : 2023-07-16 05:58:27,741	Map 1: 1/1	Reducer 2: 0(+1)/2
   ```
   
   ```
   $ ./bin/logs hive-hiveserver2-5876b658cd-8zxwp | grep HIVE-27050 | tail -n 3
   hive-hiveserver2-5876b658cd-8zxwp: 2023-07-16T05:58:13,110  INFO [62373162-813c-409b-834d-335f2f72efc1 HiveServer2-Handler-Pool: Thread-61] parse.GenTezUtils: HIVE-27050: max partition factor=2.0, max partition=2
   hive-hiveserver2-5876b658cd-8zxwp: 2023-07-16T05:58:13,112  INFO [62373162-813c-409b-834d-335f2f72efc1 HiveServer2-Handler-Pool: Thread-61] hive.HiveIcebergSerDe: HIVE-27050: operation: null
   hive-hiveserver2-5876b658cd-8zxwp: 2023-07-16T05:58:28,411  INFO [HiveServer2-Background-Pool: Thread-111] hive.HiveIcebergSerDe: HIVE-27050: operation: null
   ```



-- 
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: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] difin commented on a diff in pull request #4477: HIVE-27050: Restrict reducer extrapolation to contain number of small…

Posted by "difin (via GitHub)" <gi...@apache.org>.
difin commented on code in PR #4477:
URL: https://github.com/apache/hive/pull/4477#discussion_r1265838628


##########
iceberg/iceberg-handler/src/main/java/org/apache/iceberg/mr/hive/HiveIcebergSerDe.java:
##########
@@ -148,6 +148,14 @@ public void initialize(@Nullable Configuration configuration, Properties serDePr
     // TODO: remove once we have both Fanout and ClusteredWriter available: HIVE-25948
     HiveConf.setIntVar(configuration, HiveConf.ConfVars.HIVEOPTSORTDYNAMICPARTITIONTHRESHOLD, 1);
     HiveConf.setVar(configuration, HiveConf.ConfVars.DYNAMICPARTITIONINGMODE, "nonstrict");
+
+    Context.Operation operation = HiveCustomStorageHandlerUtils.getWriteOperation(configuration,
+            serDeProperties.getProperty(Catalogs.NAME));
+
+    if (operation != null) {
+      HiveConf.setFloatVar(configuration, HiveConf.ConfVars.TEZ_MAX_PARTITION_FACTOR, 1f);

Review Comment:
   Hi @okumin, 
   Thank you for all the info!
   I tried a DELETE query with your test table with `hive.tez.auto.reducer.parallelism.min.threshold=0.0 ` and it still gave 2 reducers.
   I also noticed in debug that `GenTezUtils.createReduceWork()` which sets max partition factor is called before `HiveIcebergSerDe.initialize()` with a write operation where I tried to set max partition factor to 1 which probably explains why my change doesn't work.
   What do you think, can I set max partition factor to 1.0 in `GenTezUtils.createReduceWork()` if the operation is a write operation for Iceberg table?



-- 
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: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] okumin commented on a diff in pull request #4477: HIVE-27050: Restrict reducer extrapolation to contain number of small…

Posted by "okumin (via GitHub)" <gi...@apache.org>.
okumin commented on code in PR #4477:
URL: https://github.com/apache/hive/pull/4477#discussion_r1265275497


##########
iceberg/iceberg-handler/src/main/java/org/apache/iceberg/mr/hive/HiveIcebergSerDe.java:
##########
@@ -148,6 +148,14 @@ public void initialize(@Nullable Configuration configuration, Properties serDePr
     // TODO: remove once we have both Fanout and ClusteredWriter available: HIVE-25948
     HiveConf.setIntVar(configuration, HiveConf.ConfVars.HIVEOPTSORTDYNAMICPARTITIONTHRESHOLD, 1);
     HiveConf.setVar(configuration, HiveConf.ConfVars.DYNAMICPARTITIONINGMODE, "nonstrict");
+
+    Context.Operation operation = HiveCustomStorageHandlerUtils.getWriteOperation(configuration,
+            serDeProperties.getProperty(Catalogs.NAME));
+
+    if (operation != null) {
+      HiveConf.setFloatVar(configuration, HiveConf.ConfVars.TEZ_MAX_PARTITION_FACTOR, 1f);

Review Comment:
   Some random thoughts. I would say these are minor.
   - Is it best to disable over-provisioning only for DELETE reducers using a Hive hook or something?
       - Over-provisioning might work for INSERT or UPDATE
       - It could work also for DELETE if rows are filtered
       - Maybe, the optimization should be applied to only the last reducer in the case like Map -> Reduce -> Reduce?
   - `hive.tez.auto.reducer.parallelism.min.threshold=0.0` can be an option?



-- 
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: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] deniskuzZ commented on a diff in pull request #4477: HIVE-27050: Restrict reducer extrapolation to contain number of small…

Posted by "deniskuzZ (via GitHub)" <gi...@apache.org>.
deniskuzZ commented on code in PR #4477:
URL: https://github.com/apache/hive/pull/4477#discussion_r1272045077


##########
ql/src/java/org/apache/hadoop/hive/ql/parse/GenTezUtils.java:
##########
@@ -76,6 +80,24 @@ public static UnionWork createUnionWork(
     tezWork.add(unionWork);
     return unionWork;
   }
+  
+  private static boolean isRestrictReducerExtrapolation(GenTezProcContext context) {
+
+    Table table = context.parseContext.getContext().getLoadTableOutputMap().values()
+            .stream().findFirst().get().getTable();
+
+    // Iceberg table
+    if (DDLUtils.isIcebergTable(table)) {

Review Comment:
   would that work `isIcebergTable(reduceWork.getKeyDesc().getProperties())`?



-- 
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: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] deniskuzZ commented on a diff in pull request #4477: HIVE-27050: Restrict reducer extrapolation to contain number of small…

Posted by "deniskuzZ (via GitHub)" <gi...@apache.org>.
deniskuzZ commented on code in PR #4477:
URL: https://github.com/apache/hive/pull/4477#discussion_r1272045077


##########
ql/src/java/org/apache/hadoop/hive/ql/parse/GenTezUtils.java:
##########
@@ -76,6 +80,24 @@ public static UnionWork createUnionWork(
     tezWork.add(unionWork);
     return unionWork;
   }
+  
+  private static boolean isRestrictReducerExtrapolation(GenTezProcContext context) {
+
+    Table table = context.parseContext.getContext().getLoadTableOutputMap().values()
+            .stream().findFirst().get().getTable();
+
+    // Iceberg table
+    if (DDLUtils.isIcebergTable(table)) {

Review Comment:
   would the below work 
   ````
   TableDesc tblDesc = reduceWork.getKeyDesc(); 
   // tblDesc = reduceSink.getConf().getKeySerializeInfo()
   isIcebergTable(tblDesc.getProperties())
   ````



-- 
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: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] sonarcloud[bot] commented on pull request #4477: HIVE-27050: Restrict reducer extrapolation to contain number of small…

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #4477:
URL: https://github.com/apache/hive/pull/4477#issuecomment-1646446983

   Kudos, SonarCloud Quality Gate passed!&nbsp; &nbsp; [![Quality Gate passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/passed-16px.png 'Quality Gate passed')](https://sonarcloud.io/dashboard?id=apache_hive&pullRequest=4477)
   
   [![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png 'Bug')](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=4477&resolved=false&types=BUG) [![C](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/C-16px.png 'C')](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=4477&resolved=false&types=BUG) [1 Bug](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=4477&resolved=false&types=BUG)  
   [![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png 'Vulnerability')](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=4477&resolved=false&types=VULNERABILITY) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=4477&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=4477&resolved=false&types=VULNERABILITY)  
   [![Security Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png 'Security Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache_hive&pullRequest=4477&resolved=false&types=SECURITY_HOTSPOT) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/security_hotspots?id=apache_hive&pullRequest=4477&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_hive&pullRequest=4477&resolved=false&types=SECURITY_HOTSPOT)  
   [![Code Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png 'Code Smell')](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=4477&resolved=false&types=CODE_SMELL) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=4477&resolved=false&types=CODE_SMELL) [2 Code Smells](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=4477&resolved=false&types=CODE_SMELL)
   
   [![No Coverage information](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/NoCoverageInfo-16px.png 'No Coverage information')](https://sonarcloud.io/component_measures?id=apache_hive&pullRequest=4477&metric=coverage&view=list) No Coverage information  
   [![No Duplication information](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/NoDuplicationInfo-16px.png 'No Duplication information')](https://sonarcloud.io/component_measures?id=apache_hive&pullRequest=4477&metric=duplicated_lines_density&view=list) No Duplication information
   
   


-- 
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: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] deniskuzZ commented on a diff in pull request #4477: HIVE-27050: Restrict reducer extrapolation to contain number of small…

Posted by "deniskuzZ (via GitHub)" <gi...@apache.org>.
deniskuzZ commented on code in PR #4477:
URL: https://github.com/apache/hive/pull/4477#discussion_r1270679500


##########
ql/src/java/org/apache/hadoop/hive/ql/ddl/DDLUtils.java:
##########
@@ -231,10 +231,17 @@ public static void validateTableIsIceberg(org.apache.hadoop.hive.ql.metadata.Tab
   }
 
   public static boolean isIcebergTable(Table table) {
-    return table.isNonNative() && 
-            table.getStorageHandler().getType() == StorageHandlerTypes.ICEBERG;
+    return table.isNonNative() &&
+            ((table.getStorageHandler() != null && table.getStorageHandler().getType() == StorageHandlerTypes.ICEBERG) || 
+                    isIcebergTableType(table.getTTable().getParameters()));

Review Comment:
   no, shouldn't be



-- 
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: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] okumin commented on a diff in pull request #4477: HIVE-27050: Restrict reducer extrapolation to contain number of small…

Posted by "okumin (via GitHub)" <gi...@apache.org>.
okumin commented on code in PR #4477:
URL: https://github.com/apache/hive/pull/4477#discussion_r1269422641


##########
ql/src/java/org/apache/hadoop/hive/ql/parse/GenTezUtils.java:
##########
@@ -86,6 +108,13 @@ public static ReduceWork createReduceWork(
 
     float maxPartitionFactor =
         context.conf.getFloatVar(HiveConf.ConfVars.TEZ_MAX_PARTITION_FACTOR);
+    
+    if (context.parseContext.getContext().getOperation() == Context.Operation.DELETE &&
+            isRestrictReducerExtrapolation(context)) {
+      LOG.debug("Overriding maxPartitionFactor to 1.0 to prevent creation of small files after delete operation");
+      maxPartitionFactor = 1f;

Review Comment:
   I quickly double-checked it works as expected. Let's wait for the comment of committers about this approach.
   
   ACID
   
   ```
   $ beeline -e "
   > DROP TABLE IF EXISTS test;
   > CREATE TABLE test (id INT) STORED AS ORC TBLPROPERTIES ('transactional'='true');
   > INSERT INTO test VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10);
   > "
   ...
   $ beeline -e 'DELETE FROM test WHERE id = 5' --hiveconf hive.server2.in.place.progress=false --hiveconf hive.tez.auto.reducer.parallelism=true
   ...
   INFO  : 2023-07-20 12:52:55,637	Map 1: -/-	Reducer 2: 0/1	
   INFO  : 2023-07-20 12:52:57,161	Map 1: 0/1	Reducer 2: 0/1
   ```
   
   Iceberg
   ```
   $ beeline -e "
   > DROP TABLE IF EXISTS test;
   > CREATE TABLE test (id INT) STORED BY ICEBERG TBLPROPERTIES('format-version'='2');
   > INSERT INTO test VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10);
   > "
   ...
   $ beeline -e 'DELETE FROM test WHERE id = 5' --hiveconf hive.server2.in.place.progress=false --hiveconf hive.tez.auto.reducer.parallelism=true
   ...
   INFO  : 2023-07-20 12:55:56,104	Map 1: -/-	Reducer 2: 0/1	
   INFO  : 2023-07-20 12:55:58,337	Map 1: 0/1	Reducer 2: 0/1
   ```



-- 
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: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] deniskuzZ commented on a diff in pull request #4477: HIVE-27050: Restrict reducer extrapolation to contain number of small…

Posted by "deniskuzZ (via GitHub)" <gi...@apache.org>.
deniskuzZ commented on code in PR #4477:
URL: https://github.com/apache/hive/pull/4477#discussion_r1273538793


##########
ql/src/java/org/apache/hadoop/hive/ql/parse/GenTezUtils.java:
##########
@@ -76,6 +80,24 @@ public static UnionWork createUnionWork(
     tezWork.add(unionWork);
     return unionWork;
   }
+  
+  private static boolean isRestrictReducerExtrapolation(GenTezProcContext context) {
+
+    Table table = context.parseContext.getContext().getLoadTableOutputMap().values()
+            .stream().findFirst().get().getTable();
+
+    // Iceberg table
+    if (DDLUtils.isIcebergTable(table)) {

Review Comment:
   same for `reduceSink.getConf().getKeySerializeInfo()`?



-- 
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: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] deniskuzZ commented on a diff in pull request #4477: HIVE-27050: Restrict reducer extrapolation to contain number of small…

Posted by "deniskuzZ (via GitHub)" <gi...@apache.org>.
deniskuzZ commented on code in PR #4477:
URL: https://github.com/apache/hive/pull/4477#discussion_r1277473130


##########
ql/src/java/org/apache/hadoop/hive/ql/parse/GenTezUtils.java:
##########
@@ -76,6 +80,24 @@ public static UnionWork createUnionWork(
     tezWork.add(unionWork);
     return unionWork;
   }
+  
+  private static boolean isRestrictReducerExtrapolation(GenTezProcContext context) {
+
+    Table table = context.parseContext.getContext().getLoadTableOutputMap().values()
+            .stream().findFirst().get().getTable();
+
+    // Iceberg table
+    if (DDLUtils.isIcebergTable(table)) {

Review Comment:
   thanks for checking!



-- 
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: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] difin commented on a diff in pull request #4477: HIVE-27050: Restrict reducer extrapolation to contain number of small…

Posted by "difin (via GitHub)" <gi...@apache.org>.
difin commented on code in PR #4477:
URL: https://github.com/apache/hive/pull/4477#discussion_r1262955148


##########
iceberg/iceberg-handler/src/main/java/org/apache/iceberg/mr/hive/HiveIcebergSerDe.java:
##########
@@ -148,6 +148,7 @@ public void initialize(@Nullable Configuration configuration, Properties serDePr
     // TODO: remove once we have both Fanout and ClusteredWriter available: HIVE-25948
     HiveConf.setIntVar(configuration, HiveConf.ConfVars.HIVEOPTSORTDYNAMICPARTITIONTHRESHOLD, 1);
     HiveConf.setVar(configuration, HiveConf.ConfVars.DYNAMICPARTITIONINGMODE, "nonstrict");
+    HiveConf.setFloatVar(configuration, HiveConf.ConfVars.TEZ_MAX_PARTITION_FACTOR, 1f);

Review Comment:
   I updated the solution to apply this only for write operations.



-- 
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: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] deniskuzZ commented on a diff in pull request #4477: HIVE-27050: Restrict reducer extrapolation to contain number of small…

Posted by "deniskuzZ (via GitHub)" <gi...@apache.org>.
deniskuzZ commented on code in PR #4477:
URL: https://github.com/apache/hive/pull/4477#discussion_r1272015821


##########
ql/src/java/org/apache/hadoop/hive/ql/parse/GenTezUtils.java:
##########
@@ -76,6 +80,24 @@ public static UnionWork createUnionWork(
     tezWork.add(unionWork);
     return unionWork;
   }
+  
+  private static boolean isRestrictReducerExtrapolation(GenTezProcContext context) {
+
+    Table table = context.parseContext.getContext().getLoadTableOutputMap().values()
+            .stream().findFirst().get().getTable();
+
+    // Iceberg table
+    if (DDLUtils.isIcebergTable(table)) {
+      return true;
+    }
+
+    // Hive ACID table
+    if (!table.isNonNative() && AcidUtils.isTransactionalTable(table)) {

Review Comment:
   I am not sure it's required for ACID tables as we have built-in compaction support



-- 
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: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] deniskuzZ commented on a diff in pull request #4477: HIVE-27050: Restrict reducer extrapolation to contain number of small…

Posted by "deniskuzZ (via GitHub)" <gi...@apache.org>.
deniskuzZ commented on code in PR #4477:
URL: https://github.com/apache/hive/pull/4477#discussion_r1272017064


##########
ql/src/java/org/apache/hadoop/hive/ql/parse/GenTezUtils.java:
##########
@@ -86,6 +108,13 @@ public static ReduceWork createReduceWork(
 
     float maxPartitionFactor =
         context.conf.getFloatVar(HiveConf.ConfVars.TEZ_MAX_PARTITION_FACTOR);
+    
+    if (context.parseContext.getContext().getOperation() == Context.Operation.DELETE &&
+            isRestrictReducerExtrapolation(context)) {

Review Comment:
   why don't we move the operation type check inside of `isRestrictReducerExtrapolation` function?



-- 
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: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] sonarcloud[bot] commented on pull request #4477: HIVE-27050: Restrict reducer extrapolation to contain number of small…

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #4477:
URL: https://github.com/apache/hive/pull/4477#issuecomment-1656428035

   Kudos, SonarCloud Quality Gate passed!&nbsp; &nbsp; [![Quality Gate passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/passed-16px.png 'Quality Gate passed')](https://sonarcloud.io/dashboard?id=apache_hive&pullRequest=4477)
   
   [![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png 'Bug')](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=4477&resolved=false&types=BUG) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=4477&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=4477&resolved=false&types=BUG)  
   [![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png 'Vulnerability')](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=4477&resolved=false&types=VULNERABILITY) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=4477&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=4477&resolved=false&types=VULNERABILITY)  
   [![Security Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png 'Security Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache_hive&pullRequest=4477&resolved=false&types=SECURITY_HOTSPOT) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/security_hotspots?id=apache_hive&pullRequest=4477&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_hive&pullRequest=4477&resolved=false&types=SECURITY_HOTSPOT)  
   [![Code Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png 'Code Smell')](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=4477&resolved=false&types=CODE_SMELL) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=4477&resolved=false&types=CODE_SMELL) [2 Code Smells](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=4477&resolved=false&types=CODE_SMELL)
   
   [![No Coverage information](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/NoCoverageInfo-16px.png 'No Coverage information')](https://sonarcloud.io/component_measures?id=apache_hive&pullRequest=4477&metric=coverage&view=list) No Coverage information  
   [![No Duplication information](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/NoDuplicationInfo-16px.png 'No Duplication information')](https://sonarcloud.io/component_measures?id=apache_hive&pullRequest=4477&metric=duplicated_lines_density&view=list) No Duplication information
   
   


-- 
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: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] sonarcloud[bot] commented on pull request #4477: HIVE-27050: Restrict reducer extrapolation to contain number of small…

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #4477:
URL: https://github.com/apache/hive/pull/4477#issuecomment-1641292797

   Kudos, SonarCloud Quality Gate passed!&nbsp; &nbsp; [![Quality Gate passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/passed-16px.png 'Quality Gate passed')](https://sonarcloud.io/dashboard?id=apache_hive&pullRequest=4477)
   
   [![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png 'Bug')](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=4477&resolved=false&types=BUG) [![C](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/C-16px.png 'C')](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=4477&resolved=false&types=BUG) [1 Bug](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=4477&resolved=false&types=BUG)  
   [![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png 'Vulnerability')](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=4477&resolved=false&types=VULNERABILITY) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=4477&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=4477&resolved=false&types=VULNERABILITY)  
   [![Security Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png 'Security Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache_hive&pullRequest=4477&resolved=false&types=SECURITY_HOTSPOT) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/security_hotspots?id=apache_hive&pullRequest=4477&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_hive&pullRequest=4477&resolved=false&types=SECURITY_HOTSPOT)  
   [![Code Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png 'Code Smell')](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=4477&resolved=false&types=CODE_SMELL) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=4477&resolved=false&types=CODE_SMELL) [2 Code Smells](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=4477&resolved=false&types=CODE_SMELL)
   
   [![No Coverage information](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/NoCoverageInfo-16px.png 'No Coverage information')](https://sonarcloud.io/component_measures?id=apache_hive&pullRequest=4477&metric=coverage&view=list) No Coverage information  
   [![No Duplication information](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/NoDuplicationInfo-16px.png 'No Duplication information')](https://sonarcloud.io/component_measures?id=apache_hive&pullRequest=4477&metric=duplicated_lines_density&view=list) No Duplication information
   
   


-- 
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: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] difin commented on a diff in pull request #4477: HIVE-27050: Restrict reducer extrapolation to contain number of small…

Posted by "difin (via GitHub)" <gi...@apache.org>.
difin commented on code in PR #4477:
URL: https://github.com/apache/hive/pull/4477#discussion_r1270977357


##########
ql/src/java/org/apache/hadoop/hive/ql/ddl/DDLUtils.java:
##########
@@ -231,10 +231,17 @@ public static void validateTableIsIceberg(org.apache.hadoop.hive.ql.metadata.Tab
   }
 
   public static boolean isIcebergTable(Table table) {
-    return table.isNonNative() && 
-            table.getStorageHandler().getType() == StorageHandlerTypes.ICEBERG;
+    return table.isNonNative() &&
+            ((table.getStorageHandler() != null && table.getStorageHandler().getType() == StorageHandlerTypes.ICEBERG) || 
+                    isIcebergTableType(table.getTTable().getParameters()));

Review Comment:
   Fixed @ rested on using MiniHS2Cluster for Iceberg and Hive ACID tables.



##########
ql/src/java/org/apache/hadoop/hive/ql/ddl/DDLUtils.java:
##########
@@ -231,10 +231,17 @@ public static void validateTableIsIceberg(org.apache.hadoop.hive.ql.metadata.Tab
   }
 
   public static boolean isIcebergTable(Table table) {
-    return table.isNonNative() && 
-            table.getStorageHandler().getType() == StorageHandlerTypes.ICEBERG;
+    return table.isNonNative() &&
+            ((table.getStorageHandler() != null && table.getStorageHandler().getType() == StorageHandlerTypes.ICEBERG) || 
+                    isIcebergTableType(table.getTTable().getParameters()));

Review Comment:
   Fixed @ retested on using MiniHS2Cluster for Iceberg and Hive ACID tables.



-- 
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: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] sonarcloud[bot] commented on pull request #4477: HIVE-27050: Restrict reducer extrapolation to contain number of small…

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #4477:
URL: https://github.com/apache/hive/pull/4477#issuecomment-1631012933

   Kudos, SonarCloud Quality Gate passed!&nbsp; &nbsp; [![Quality Gate passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/passed-16px.png 'Quality Gate passed')](https://sonarcloud.io/dashboard?id=apache_hive&pullRequest=4477)
   
   [![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png 'Bug')](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=4477&resolved=false&types=BUG) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=4477&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=4477&resolved=false&types=BUG)  
   [![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png 'Vulnerability')](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=4477&resolved=false&types=VULNERABILITY) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=4477&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=4477&resolved=false&types=VULNERABILITY)  
   [![Security Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png 'Security Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache_hive&pullRequest=4477&resolved=false&types=SECURITY_HOTSPOT) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/security_hotspots?id=apache_hive&pullRequest=4477&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_hive&pullRequest=4477&resolved=false&types=SECURITY_HOTSPOT)  
   [![Code Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png 'Code Smell')](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=4477&resolved=false&types=CODE_SMELL) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=4477&resolved=false&types=CODE_SMELL) [0 Code Smells](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=4477&resolved=false&types=CODE_SMELL)
   
   [![No Coverage information](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/NoCoverageInfo-16px.png 'No Coverage information')](https://sonarcloud.io/component_measures?id=apache_hive&pullRequest=4477&metric=coverage&view=list) No Coverage information  
   [![No Duplication information](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/NoDuplicationInfo-16px.png 'No Duplication information')](https://sonarcloud.io/component_measures?id=apache_hive&pullRequest=4477&metric=duplicated_lines_density&view=list) No Duplication information
   
   


-- 
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: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] okumin commented on a diff in pull request #4477: HIVE-27050: Restrict reducer extrapolation to contain number of small…

Posted by "okumin (via GitHub)" <gi...@apache.org>.
okumin commented on code in PR #4477:
URL: https://github.com/apache/hive/pull/4477#discussion_r1269422641


##########
ql/src/java/org/apache/hadoop/hive/ql/parse/GenTezUtils.java:
##########
@@ -86,6 +108,13 @@ public static ReduceWork createReduceWork(
 
     float maxPartitionFactor =
         context.conf.getFloatVar(HiveConf.ConfVars.TEZ_MAX_PARTITION_FACTOR);
+    
+    if (context.parseContext.getContext().getOperation() == Context.Operation.DELETE &&
+            isRestrictReducerExtrapolation(context)) {
+      LOG.debug("Overriding maxPartitionFactor to 1.0 to prevent creation of small files after delete operation");
+      maxPartitionFactor = 1f;

Review Comment:
   I quickly double-checked it works as expected.
   
   ACID
   
   ```
   $ beeline -e "
   > DROP TABLE IF EXISTS test;
   > CREATE TABLE test (id INT) STORED AS ORC TBLPROPERTIES ('transactional'='true');
   > INSERT INTO test VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10);
   > "
   ...
   $ beeline -e 'DELETE FROM test WHERE id = 5' --hiveconf hive.server2.in.place.progress=false --hiveconf hive.tez.auto.reducer.parallelism=true
   ...
   INFO  : 2023-07-20 12:52:55,637	Map 1: -/-	Reducer 2: 0/1	
   INFO  : 2023-07-20 12:52:57,161	Map 1: 0/1	Reducer 2: 0/1
   ```
   
   Iceberg
   ```
   $ beeline -e "
   > DROP TABLE IF EXISTS test;
   > CREATE TABLE test (id INT) STORED BY ICEBERG TBLPROPERTIES('format-version'='2');
   > INSERT INTO test VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10);
   > "
   ...
   $ beeline -e 'DELETE FROM test WHERE id = 5' --hiveconf hive.server2.in.place.progress=false --hiveconf hive.tez.auto.reducer.parallelism=true
   ...
   INFO  : 2023-07-20 12:55:56,104	Map 1: -/-	Reducer 2: 0/1	
   INFO  : 2023-07-20 12:55:58,337	Map 1: 0/1	Reducer 2: 0/1
   ```



##########
ql/src/java/org/apache/hadoop/hive/ql/ddl/DDLUtils.java:
##########
@@ -231,10 +231,17 @@ public static void validateTableIsIceberg(org.apache.hadoop.hive.ql.metadata.Tab
   }
 
   public static boolean isIcebergTable(Table table) {
-    return table.isNonNative() && 
-            table.getStorageHandler().getType() == StorageHandlerTypes.ICEBERG;
+    return table.isNonNative() &&
+            ((table.getStorageHandler() != null && table.getStorageHandler().getType() == StorageHandlerTypes.ICEBERG) || 
+                    isIcebergTableType(table.getTTable().getParameters()));

Review Comment:
   Is there any case where StorageHandler#getType != ICEBERG but isIcebergTableType = true?



##########
ql/src/java/org/apache/hadoop/hive/ql/ddl/DDLUtils.java:
##########
@@ -231,10 +231,17 @@ public static void validateTableIsIceberg(org.apache.hadoop.hive.ql.metadata.Tab
   }
 
   public static boolean isIcebergTable(Table table) {

Review Comment:
   Wow, I originally thought the change be available also for Delta Lake, Hudi, etc, but looks like we hardcode many for Iceberg...
   I will create a ticket to push this kind of logic to StorageHandler...



-- 
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: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] sonarcloud[bot] commented on pull request #4477: HIVE-27050: Restrict reducer extrapolation to contain number of small…

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #4477:
URL: https://github.com/apache/hive/pull/4477#issuecomment-1635048205

   Kudos, SonarCloud Quality Gate passed!&nbsp; &nbsp; [![Quality Gate passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/passed-16px.png 'Quality Gate passed')](https://sonarcloud.io/dashboard?id=apache_hive&pullRequest=4477)
   
   [![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png 'Bug')](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=4477&resolved=false&types=BUG) [![C](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/C-16px.png 'C')](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=4477&resolved=false&types=BUG) [1 Bug](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=4477&resolved=false&types=BUG)  
   [![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png 'Vulnerability')](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=4477&resolved=false&types=VULNERABILITY) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=4477&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=4477&resolved=false&types=VULNERABILITY)  
   [![Security Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png 'Security Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache_hive&pullRequest=4477&resolved=false&types=SECURITY_HOTSPOT) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/security_hotspots?id=apache_hive&pullRequest=4477&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_hive&pullRequest=4477&resolved=false&types=SECURITY_HOTSPOT)  
   [![Code Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png 'Code Smell')](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=4477&resolved=false&types=CODE_SMELL) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=4477&resolved=false&types=CODE_SMELL) [10 Code Smells](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=4477&resolved=false&types=CODE_SMELL)
   
   [![No Coverage information](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/NoCoverageInfo-16px.png 'No Coverage information')](https://sonarcloud.io/component_measures?id=apache_hive&pullRequest=4477&metric=coverage&view=list) No Coverage information  
   [![No Duplication information](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/NoDuplicationInfo-16px.png 'No Duplication information')](https://sonarcloud.io/component_measures?id=apache_hive&pullRequest=4477&metric=duplicated_lines_density&view=list) No Duplication information
   
   


-- 
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: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] difin commented on a diff in pull request #4477: HIVE-27050: Restrict reducer extrapolation to contain number of small…

Posted by "difin (via GitHub)" <gi...@apache.org>.
difin commented on code in PR #4477:
URL: https://github.com/apache/hive/pull/4477#discussion_r1265838628


##########
iceberg/iceberg-handler/src/main/java/org/apache/iceberg/mr/hive/HiveIcebergSerDe.java:
##########
@@ -148,6 +148,14 @@ public void initialize(@Nullable Configuration configuration, Properties serDePr
     // TODO: remove once we have both Fanout and ClusteredWriter available: HIVE-25948
     HiveConf.setIntVar(configuration, HiveConf.ConfVars.HIVEOPTSORTDYNAMICPARTITIONTHRESHOLD, 1);
     HiveConf.setVar(configuration, HiveConf.ConfVars.DYNAMICPARTITIONINGMODE, "nonstrict");
+
+    Context.Operation operation = HiveCustomStorageHandlerUtils.getWriteOperation(configuration,
+            serDeProperties.getProperty(Catalogs.NAME));
+
+    if (operation != null) {
+      HiveConf.setFloatVar(configuration, HiveConf.ConfVars.TEZ_MAX_PARTITION_FACTOR, 1f);

Review Comment:
   Hi @okumin, 
   Thank you for all the info!
   I tried a DELETE query with your test table with `hive.tez.auto.reducer.parallelism.min.threshold=0.0 ` and it still gave 2 reducers.
   I also noticed in debug that `GenTezUtils.createReduceWork()` is called before `HiveIcebergSerDe.initialize()` with a write operation where I tried to set max partition factor to 1 which probably explains why my change doesn't work.
   What do you think, can I set max partition factor to 1.0 in `GenTezUtils.createReduceWork()` if the operation is a write operation for Iceberg table?



-- 
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: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] sonarcloud[bot] commented on pull request #4477: HIVE-27050: Restrict reducer extrapolation to contain number of small…

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #4477:
URL: https://github.com/apache/hive/pull/4477#issuecomment-1656542254

   Kudos, SonarCloud Quality Gate passed!&nbsp; &nbsp; [![Quality Gate passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/passed-16px.png 'Quality Gate passed')](https://sonarcloud.io/dashboard?id=apache_hive&pullRequest=4477)
   
   [![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png 'Bug')](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=4477&resolved=false&types=BUG) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=4477&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=4477&resolved=false&types=BUG)  
   [![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png 'Vulnerability')](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=4477&resolved=false&types=VULNERABILITY) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=4477&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=4477&resolved=false&types=VULNERABILITY)  
   [![Security Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png 'Security Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache_hive&pullRequest=4477&resolved=false&types=SECURITY_HOTSPOT) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/security_hotspots?id=apache_hive&pullRequest=4477&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_hive&pullRequest=4477&resolved=false&types=SECURITY_HOTSPOT)  
   [![Code Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png 'Code Smell')](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=4477&resolved=false&types=CODE_SMELL) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=4477&resolved=false&types=CODE_SMELL) [2 Code Smells](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=4477&resolved=false&types=CODE_SMELL)
   
   [![No Coverage information](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/NoCoverageInfo-16px.png 'No Coverage information')](https://sonarcloud.io/component_measures?id=apache_hive&pullRequest=4477&metric=coverage&view=list) No Coverage information  
   [![No Duplication information](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/NoDuplicationInfo-16px.png 'No Duplication information')](https://sonarcloud.io/component_measures?id=apache_hive&pullRequest=4477&metric=duplicated_lines_density&view=list) No Duplication information
   
   


-- 
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: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] okumin commented on a diff in pull request #4477: HIVE-27050: Restrict reducer extrapolation to contain number of small…

Posted by "okumin (via GitHub)" <gi...@apache.org>.
okumin commented on code in PR #4477:
URL: https://github.com/apache/hive/pull/4477#discussion_r1264613366


##########
iceberg/iceberg-handler/src/main/java/org/apache/iceberg/mr/hive/HiveIcebergSerDe.java:
##########
@@ -148,6 +148,14 @@ public void initialize(@Nullable Configuration configuration, Properties serDePr
     // TODO: remove once we have both Fanout and ClusteredWriter available: HIVE-25948
     HiveConf.setIntVar(configuration, HiveConf.ConfVars.HIVEOPTSORTDYNAMICPARTITIONTHRESHOLD, 1);
     HiveConf.setVar(configuration, HiveConf.ConfVars.DYNAMICPARTITIONINGMODE, "nonstrict");
+
+    Context.Operation operation = HiveCustomStorageHandlerUtils.getWriteOperation(configuration,
+            serDeProperties.getProperty(Catalogs.NAME));
+
+    if (operation != null) {
+      HiveConf.setFloatVar(configuration, HiveConf.ConfVars.TEZ_MAX_PARTITION_FACTOR, 1f);

Review Comment:
   I tested how this works as I am not confident.
   
   ## Test queries
   
   ### Prep
   
   ```
   beeline -e "
   DROP TABLE IF EXISTS test;
   CREATE TABLE test (id INT) STORED BY ICEBERG TBLPROPERTIES('format-version'='2');
   INSERT INTO test VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10);
   "
   ```
   
   ### DELETE
   
   ```
   beeline -e 'DELETE FROM test WHERE id = 5' --hiveconf hive.server2.in.place.progress=false --hiveconf hive.tez.auto.reducer.parallelism=true
   ```
   
   ## Test result
   
   ### The original version
   
   [This](https://github.com/okumin/hive/commit/59b84b9d7835f97b5e9df872ef00986678498976) is the tested revision. Two reducers are set up and launched as reported.
   
   ```
   $ beeline -e 'DELETE FROM test WHERE id = 5' --hiveconf hive.server2.in.place.progress=false --hiveconf hive.tez.auto.reducer.parallelism=true
   ...
   INFO  : 2023-07-16 04:55:39,740	Map 1: 0(+1)/1	Reducer 2: 0/2	
   INFO  : 2023-07-16 04:55:42,259	Map 1: 1/1	Reducer 2: 0(+1)/2
   ```
   
   ```
   $ ./bin/logs hive-hiveserver2-655b558bb-gzwh8 | grep HIVE-27050 | tail -n 1
   hive-hiveserver2-655b558bb-gzwh8: 2023-07-16T04:55:31,760  INFO [f3ecdcb4-f45b-405f-986e-0dbf525c7c87 HiveServer2-Handler-Pool: Thread-61] parse.GenTezUtils: HIVE-27050: max partition factor=2.0, max partition=2
   ```
   
   ### The first patch
   
   [This](https://github.com/okumin/hive/commit/a19ee2b5536539d066ecf77c369bc0f7bc85a2ca) is the tested revision. One reducer is set up and launched.
   
   ```
   $ beeline -e 'DELETE FROM test WHERE id = 5' --hiveconf hive.server2.in.place.progress=false --hiveconf hive.tez.auto.reducer.parallelism=true
   ...
   INFO  : 2023-07-16 05:22:30,905	Map 1: 0/1	Reducer 2: 0/1	
   INFO  : 2023-07-16 05:22:35,454	Map 1: 0(+1)/1	Reducer 2: 0/1
   ```
   
   ```
   $ ./bin/logs hive-hiveserver2-75bc6bc94c-bhxxc | grep HIVE-27050 | tail -n 1
   hive-hiveserver2-75bc6bc94c-bhxxc: 2023-07-16T05:22:23,324  INFO [18f9ace5-2016-4430-8155-ae95c254148b HiveServer2-Handler-Pool: Thread-61] parse.GenTezUtils: HIVE-27050: max partition factor=1.0, max partition=1
   ```
   
   ### The second(current) path
   
   [This](https://github.com/okumin/hive/commit/0e149323aa07b661a0c8eb259fa514bcb72c02a9) is the tested revision. It is unlikely to be working as expected.
   
   ```
   $ beeline -e 'DELETE FROM test WHERE id = 5' --hiveconf hive.server2.in.place.progress=false --hiveconf hive.tez.auto.reducer.parallelism=true
   ...
   INFO  : 2023-07-16 05:58:27,235	Map 1: 1/1	Reducer 2: 0/2	
   INFO  : 2023-07-16 05:58:27,741	Map 1: 1/1	Reducer 2: 0(+1)/2
   ```
   
   ```
   $ ./bin/logs hive-hiveserver2-5876b658cd-8zxwp | grep HIVE-27050 | tail -n 3
   hive-hiveserver2-5876b658cd-8zxwp: 2023-07-16T05:58:13,110  INFO [62373162-813c-409b-834d-335f2f72efc1 HiveServer2-Handler-Pool: Thread-61] parse.GenTezUtils: HIVE-27050: max partition factor=2.0, max partition=2
   hive-hiveserver2-5876b658cd-8zxwp: 2023-07-16T05:58:13,112  INFO [62373162-813c-409b-834d-335f2f72efc1 HiveServer2-Handler-Pool: Thread-61] hive.HiveIcebergSerDe: HIVE-27050: operation: null
   hive-hiveserver2-5876b658cd-8zxwp: 2023-07-16T05:58:28,411  INFO [HiveServer2-Background-Pool: Thread-111] hive.HiveIcebergSerDe: HIVE-27050: operation: null
   ```



-- 
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: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] difin commented on a diff in pull request #4477: HIVE-27050: Restrict reducer extrapolation to contain number of small…

Posted by "difin (via GitHub)" <gi...@apache.org>.
difin commented on code in PR #4477:
URL: https://github.com/apache/hive/pull/4477#discussion_r1267247956


##########
iceberg/iceberg-handler/src/main/java/org/apache/iceberg/mr/hive/HiveIcebergSerDe.java:
##########
@@ -148,6 +148,14 @@ public void initialize(@Nullable Configuration configuration, Properties serDePr
     // TODO: remove once we have both Fanout and ClusteredWriter available: HIVE-25948
     HiveConf.setIntVar(configuration, HiveConf.ConfVars.HIVEOPTSORTDYNAMICPARTITIONTHRESHOLD, 1);
     HiveConf.setVar(configuration, HiveConf.ConfVars.DYNAMICPARTITIONINGMODE, "nonstrict");
+
+    Context.Operation operation = HiveCustomStorageHandlerUtils.getWriteOperation(configuration,
+            serDeProperties.getProperty(Catalogs.NAME));
+
+    if (operation != null) {
+      HiveConf.setFloatVar(configuration, HiveConf.ConfVars.TEZ_MAX_PARTITION_FACTOR, 1f);

Review Comment:
   I updated the solution and placed it in GenTezUtils and made it for Iceberg and Hive ACID.



-- 
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: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] deniskuzZ merged pull request #4477: HIVE-27050: Restrict reducer extrapolation to contain number of small…

Posted by "deniskuzZ (via GitHub)" <gi...@apache.org>.
deniskuzZ merged PR #4477:
URL: https://github.com/apache/hive/pull/4477


-- 
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: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] deniskuzZ commented on a diff in pull request #4477: HIVE-27050: Restrict reducer extrapolation to contain number of small…

Posted by "deniskuzZ (via GitHub)" <gi...@apache.org>.
deniskuzZ commented on code in PR #4477:
URL: https://github.com/apache/hive/pull/4477#discussion_r1272017064


##########
ql/src/java/org/apache/hadoop/hive/ql/parse/GenTezUtils.java:
##########
@@ -86,6 +108,13 @@ public static ReduceWork createReduceWork(
 
     float maxPartitionFactor =
         context.conf.getFloatVar(HiveConf.ConfVars.TEZ_MAX_PARTITION_FACTOR);
+    
+    if (context.parseContext.getContext().getOperation() == Context.Operation.DELETE &&
+            isRestrictReducerExtrapolation(context)) {

Review Comment:
   why don't we move the operation type check inside of i`sRestrictReducerExtrapolation` function?



-- 
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: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] deniskuzZ commented on a diff in pull request #4477: HIVE-27050: Restrict reducer extrapolation to contain number of small…

Posted by "deniskuzZ (via GitHub)" <gi...@apache.org>.
deniskuzZ commented on code in PR #4477:
URL: https://github.com/apache/hive/pull/4477#discussion_r1272015311


##########
ql/src/java/org/apache/hadoop/hive/ql/parse/GenTezUtils.java:
##########
@@ -86,6 +108,13 @@ public static ReduceWork createReduceWork(
 
     float maxPartitionFactor =
         context.conf.getFloatVar(HiveConf.ConfVars.TEZ_MAX_PARTITION_FACTOR);
+    
+    if (context.parseContext.getContext().getOperation() == Context.Operation.DELETE &&
+            isRestrictReducerExtrapolation(context)) {
+      LOG.debug("Overriding maxPartitionFactor to 1.0 to prevent creation of small files after delete operation");
+      maxPartitionFactor = 1f;

Review Comment:
   I am not sure it's required for ACID tables as we have built-in compaction support



-- 
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: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org