deniskuzZ commented on code in PR #5254:
URL: https://github.com/apache/hive/pull/5254#discussion_r1671779610


##########
iceberg/iceberg-handler/src/main/java/org/apache/iceberg/mr/hive/vector/HiveBatchIterator.java:
##########
@@ -144,4 +115,53 @@ public HiveBatchContext next() {
     advanced = false;
     return new HiveBatchContext(batch, vrbCtx, rowOffset);
   }
+
+  public void fillVirtualColumns() {
+    for (VirtualColumn vc : vrbCtx.getNeededVirtualColumns()) {
+      Object value;
+      int idx = vrbCtx.findVirtualColumnNum(vc);
+      switch (vc) {
+        case PARTITION_SPEC_ID:
+          value = idToConstant.get(MetadataColumns.SPEC_ID.fieldId());
+          vrbCtx.addPartitionColsToBatch(batch.cols[idx], value, idx);
+          break;
+        case PARTITION_HASH:
+          value = IcebergAcidUtil.computeHash(
+                  (StructProjection) 
idToConstant.get(MetadataColumns.PARTITION_COLUMN_ID));
+          vrbCtx.addPartitionColsToBatch(batch.cols[idx], value, idx);
+          break;
+        case FILE_PATH:
+          value = idToConstant.get(MetadataColumns.FILE_PATH.fieldId());
+          BytesColumnVector bcv = (BytesColumnVector) batch.cols[idx];
+          if (value == null) {
+            bcv.noNulls = false;
+            bcv.isNull[0] = true;
+            bcv.isRepeating = true;
+          } else {
+            bcv.fill(((String) value).getBytes());
+          }
+          break;
+        case ROW_POSITION:
+          value = LongStream.range(rowOffset, rowOffset + 
batch.size).toArray();
+          LongColumnVector lcv = (LongColumnVector) batch.cols[idx];
+          lcv.noNulls = true;
+          Arrays.fill(lcv.isNull, false);
+          lcv.isRepeating = false;
+          System.arraycopy(value, 0, lcv.vector, 0, batch.size);
+          break;
+        case PARTITION_PROJECTION:
+          value = IcebergAcidUtil.getSerializedPartitionKey(
+                  (StructProjection) 
idToConstant.get(MetadataColumns.PARTITION_COLUMN_ID), partitionSpec);

Review Comment:
   can't we store PARTITION_PROJECTION in `idToConstant` map same as `SPEC_ID`?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to