Copilot commented on code in PR #6834:
URL: https://github.com/apache/hive/pull/6834#discussion_r4236630592


##########
iceberg/iceberg-handler/src/main/java/org/apache/iceberg/mr/hive/HiveIcebergStorageHandler.java:
##########
@@ -1881,17 +1889,28 @@ private String 
collectColumnAndReplaceDummyValues(ExprNodeDesc node, String foun
    * </ul>
    * @param tableProps table properties, must be not null
    */
-  private void fallbackToNonVectorizedModeBasedOnProperties(Properties 
tableProps) {
+  private boolean vectorizationUnsupported(Properties tableProps) {
     Schema tableSchema = 
SchemaParser.fromJson(tableProps.getProperty(InputFormatConfig.TABLE_SCHEMA));
 
-    if (FileFormat.AVRO == 
IcebergTableUtil.defaultFileFormat(tableProps::getProperty) ||
+    return FileFormat.AVRO == 
IcebergTableUtil.defaultFileFormat(tableProps::getProperty) ||
         
isValidMetadataTable(tableProps.getProperty(IcebergAcidUtil.META_TABLE_PROPERTY))
 ||
         hasOrcTimeInSchema(tableProps, tableSchema) ||
-        !hasParquetNestedTypeWithinListOrMap(tableProps, tableSchema)) {
-      // disable vectorization
-      SessionStateUtil.getQueryState(conf).ifPresent(qs ->
-          qs.getConf().setBoolVar(ConfVars.HIVE_VECTORIZATION_ENABLED, false));
-    }
+        !hasParquetNestedTypeWithinListOrMap(tableProps, tableSchema);
+  }
+
+  /**
+   * Whether the scanned snapshot has equality deletes, which the vectorized 
reader cannot apply
+   * (HiveVectorizedReader): the current one, or the head of the branch or tag 
scanned.
+   */
+  private boolean hasEqualityDeletes(Properties tableProps) {
+    Snapshot snapshot = IcebergTableUtil.getTableSnapshot(
+        IcebergTableUtil.getTable(conf, tableProps), 
tableProps.getProperty(Catalogs.SNAPSHOT_REF));
+    return snapshot != null && PropertyUtil.propertyAsLong(snapshot.summary(), 
TOTAL_EQ_DELETES_PROP, 0) > 0;

Review Comment:
   This checks only `Catalogs.SNAPSHOT_REF`, so `FOR SYSTEM_VERSION AS OF ...` 
and `FOR SYSTEM_TIME AS OF ...` are evaluated against the current snapshot. The 
input format later switches snapshots via the `TableScanDesc` as-of settings; 
if that historical snapshot has equality deletes but the current snapshot does 
not, vectorization remains enabled and `HiveVectorizedReader` throws 
`UnsupportedOperationException`. Propagate the complete as-of selection into 
this check (including numeric IDs, named refs, and timestamps), and cover those 
time-travel forms in the equality-delete test.



##########
iceberg/iceberg-handler/src/main/java/org/apache/iceberg/mr/mapred/MapredIcebergInputFormat.java:
##########
@@ -116,9 +113,13 @@ public Container<T> createValue() {
       return new Container<>();
     }
 
+    /**
+     * A split is a group of file scan tasks, so no position within it maps to 
a file offset. -1 keeps
+     * HiveContextAwareRecordReader from taking every row for the start of a 
file.
+     */
     @Override
     public long getPos() throws IOException {
-      return (long) (splitLength * getProgress());
+      return -1;

Review Comment:
   `getPos()` feeds the SQL-visible `BLOCK__OFFSET__INSIDE__FILE` virtual 
column through `HiveContextAwareRecordReader` and `MapOperator`. Returning `-1` 
therefore changes row-mode Iceberg query results from estimated offsets to 
`-1`, so the PR's “No” user-facing change declaration is inaccurate; please 
document this behavior change in the PR description.



-- 
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