[ 
https://issues.apache.org/jira/browse/HIVE-25975?focusedWorklogId=734500&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-734500
 ]

ASF GitHub Bot logged work on HIVE-25975:
-----------------------------------------

                Author: ASF GitHub Bot
            Created on: 01/Mar/22 10:50
            Start Date: 01/Mar/22 10:50
    Worklog Time Spent: 10m 
      Work Description: pvary commented on a change in pull request #3060:
URL: https://github.com/apache/hive/pull/3060#discussion_r816657904



##########
File path: 
ql/src/java/org/apache/hadoop/hive/ql/optimizer/SortedDynPartitionOptimizer.java
##########
@@ -521,34 +570,45 @@ private void inferSortPositions(Operator<? extends 
OperatorDesc> fsParent,
       }
     }
 
-    public ReduceSinkOperator getReduceSinkOp(List<Integer> partitionPositions,
-        List<Integer> sortPositions, List<Integer> sortOrder, List<Integer> 
sortNullOrder,
-        ArrayList<ExprNodeDesc> allCols, ArrayList<ExprNodeDesc> 
bucketColumns, int numBuckets,
-        Operator<? extends OperatorDesc> parent, AcidUtils.Operation 
writeType) throws SemanticException {
+    public ReduceSinkOperator getReduceSinkOp(List<Integer> 
partitionPositions, List<Integer> sortPositions,
+        List<Function<List<ExprNodeDesc>, ExprNodeDesc>> customSortExprs, 
List<Integer> sortOrder,
+        List<Integer> sortNullOrder, ArrayList<ExprNodeDesc> allCols, 
ArrayList<ExprNodeDesc> bucketColumns,
+        int numBuckets, Operator<? extends OperatorDesc> parent, 
AcidUtils.Operation writeType) {
+
+      // Order of KEY columns, if custom sort is present partition and bucket 
columns are disregarded:
+      // 0) Custom sort expressions
+      //                              1) Partition columns
+      //                              2) Bucket number column
+      //                 3) Sort columns
+
+      boolean customSortExprPresent = customSortExprs != null && 
!customSortExprs.isEmpty();
 
-      // Order of KEY columns
-      // 1) Partition columns
-      // 2) Bucket number column
-      // 3) Sort columns
       Set<Integer> keyColsPosInVal = Sets.newLinkedHashSet();
       ArrayList<ExprNodeDesc> keyCols = Lists.newArrayList();
       List<Integer> newSortOrder = Lists.newArrayList();
       List<Integer> newSortNullOrder = Lists.newArrayList();
 
+      if (customSortExprPresent) {
+        partitionPositions = new ArrayList<>();
+        bucketColumns = new ArrayList<>();
+        numBuckets = -1;
+      }
+
       keyColsPosInVal.addAll(partitionPositions);
       if (bucketColumns != null && !bucketColumns.isEmpty()) {
         keyColsPosInVal.add(-1);
       }
       keyColsPosInVal.addAll(sortPositions);
 
+

Review comment:
       nit: not needed




-- 
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-unsubscr...@hive.apache.org

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


Issue Time Tracking
-------------------

    Worklog Id:     (was: 734500)
    Time Spent: 2.5h  (was: 2h 20m)

> Optimize ClusteredWriter for bucketed Iceberg tables
> ----------------------------------------------------
>
>                 Key: HIVE-25975
>                 URL: https://issues.apache.org/jira/browse/HIVE-25975
>             Project: Hive
>          Issue Type: Improvement
>            Reporter: Ádám Szita
>            Assignee: Ádám Szita
>            Priority: Major
>              Labels: pull-request-available
>          Time Spent: 2.5h
>  Remaining Estimate: 0h
>
> The first version of the ClusteredWriter in Hive-Iceberg will be lenient for 
> bucketed tables: i.e. the records do not need to be ordered by the bucket 
> values, the writer will just close its current file and open a new one for 
> out-of-order records. 
> This is suboptimal for the long-term due to creating many small files. Spark 
> uses a UDF to compute the bucket value for each record and therefore it is 
> able to order the records by bucket values, achieving optimal clustering.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to