You are viewing a plain text version of this content. The canonical link for it is here.
Posted to gitbox@hive.apache.org by "deniskuzZ (via GitHub)" <gi...@apache.org> on 2025/12/02 15:42:20 UTC

[PR] HIVE-29354: Shredded Variant PPD [hive]

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

   <!--
   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.
   -->
   
   
   ### 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.
   -->
   
   
   ### 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'.
   -->
   
   ### 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.
   -->
   


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


Re: [PR] HIVE-29354: Iceberg: [V3] Projection and Filter Pushdown for Shredded VARIANT Columns [hive]

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


##########
iceberg/iceberg-handler/src/main/java/org/apache/iceberg/mr/hive/variant/VariantPathUtil.java:
##########
@@ -0,0 +1,116 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iceberg.mr.hive.variant;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Objects;
+import org.apache.iceberg.expressions.UnboundExtract;
+import org.apache.iceberg.expressions.UnboundPredicate;
+
+public final class VariantPathUtil {
+
+  // Variant field names (matching ParquetVariantVisitor package-protected constants)
+  public static final String METADATA = "metadata";
+  public static final String VALUE = "value";
+  public static final String TYPED_VALUE = "typed_value";
+

Review Comment:
   nit: unneeded empty line



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


Re: [PR] HIVE-29354: Iceberg: [V3] Shredded Variant PPD support [hive]

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

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_hive&pullRequest=6224) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [35 New issues](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=6224&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=6224&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_hive&pullRequest=6224&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_hive&pullRequest=6224&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_hive&pullRequest=6224&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_hive&pullRequest=6224)
   
   


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


Re: [PR] HIVE-29354: Iceberg: [V3] Shredded Variant PPD support [hive]

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

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_hive&pullRequest=6224) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [39 New issues](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=6224&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=6224&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_hive&pullRequest=6224&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_hive&pullRequest=6224&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_hive&pullRequest=6224&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_hive&pullRequest=6224)
   
   


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


Re: [PR] HIVE-29354: Iceberg: [V3] Projection and Filter Pushdown for Shredded VARIANT Columns [hive]

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


##########
iceberg/iceberg-handler/src/main/java/org/apache/iceberg/mr/hive/variant/VariantProjectionUtil.java:
##########
@@ -0,0 +1,497 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iceberg.mr.hive.variant;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hive.ql.io.IOConstants;
+import org.apache.hadoop.hive.ql.io.parquet.read.DataWritableReadSupport;
+import org.apache.hadoop.hive.serde2.ColumnProjectionUtils;
+import org.apache.iceberg.Schema;
+import org.apache.iceberg.relocated.com.google.common.collect.Lists;
+import org.apache.iceberg.relocated.com.google.common.collect.Maps;
+import org.apache.iceberg.relocated.com.google.common.collect.Sets;
+import org.apache.iceberg.types.Types;
+import org.apache.parquet.column.ColumnDescriptor;
+import org.apache.parquet.schema.GroupType;
+import org.apache.parquet.schema.MessageType;
+import org.apache.parquet.schema.OriginalType;
+import org.apache.parquet.schema.Type;
+
+/**
+ * Utility class for handling Variant Projection Pushdown (Column Pruning).
+ */
+public final class VariantProjectionUtil {
+
+  private VariantProjectionUtil() {
+  }
+
+  public record VariantColumnDescriptor(
+      int rootColumnIndex,
+      int[] fieldPath,
+      String[] physicalPath,
+      Type prunedSchema) {
+  }
+
+  public record VariantProjection(
+      List<VariantColumnDescriptor> variantColumns,
+      List<ColumnDescriptor> requestedColumns) {
+
+    public static VariantProjection create(
+        MessageType fileSchema, Configuration conf, Schema icebergSchema) {
+      String columns = conf.get(IOConstants.COLUMNS);
+      if (columns == null || columns.isEmpty()) {
+        return null;
+      }
+
+      List<String> columnNames = DataWritableReadSupport.getColumnNames(columns);
+      if (columnNames == null || columnNames.isEmpty()) {
+        return null;
+      }
+
+      boolean readAll = ColumnProjectionUtils.isReadAllColumns(conf);
+      List<Integer> readColumnIds = ColumnProjectionUtils.getReadColumnIDs(conf);
+      Set<String> nestedPaths = ColumnProjectionUtils.getNestedColumnPaths(conf);
+
+      List<VariantColumnDescriptor> variantColumns =
+          discoverVariantColumns(fileSchema, icebergSchema, columnNames, readAll, readColumnIds, nestedPaths);
+      if (variantColumns.isEmpty()) {
+        return null;
+      }
+
+      List<ColumnDescriptor> requestedColumns = computeRequestedColumns(fileSchema, variantColumns);
+      if (requestedColumns.isEmpty()) {
+        return null;
+      }
+
+      return new VariantProjection(variantColumns, requestedColumns);
+    }
+  }
+
+  private static List<VariantColumnDescriptor> discoverVariantColumns(
+      MessageType fileSchema,
+      Schema icebergSchema,
+      List<String> columnNames,
+      boolean readAll,
+      List<Integer> readColumnIds,
+      Set<String> nestedPaths) {
+
+    boolean[] projected = projectedTopLevelColumns(readAll, readColumnIds, columnNames.size());
+
+    List<VariantColumnDescriptor> result = Lists.newArrayList();
+    for (int colIndex = 0; colIndex < columnNames.size(); colIndex++) {
+      if (!projected[colIndex]) {
+        continue;
+      }
+
+      String columnName = columnNames.get(colIndex);
+      // Resolve the logical Iceberg field (handling potential name mismatches from Hive)
+      Types.NestedField field = findIcebergField(icebergSchema, columnName, colIndex);
+      if (field == null || field.type() == null) {
+        continue;
+      }
+
+      // Resolve the physical Parquet type (handling schema evolution/IDs)
+      Type parquetType = findParquetType(fileSchema, field);
+      if (parquetType == null) {
+        continue;
+      }
+
+      collectVariantColumns(
+          colIndex,
+          field.type(),
+          parquetType,
+          new int[0],
+          new String[] { columnName },
+          new String[] { parquetType.getName() },
+          result,
+          nestedPaths);
+    }

Review Comment:
   should the arguments be on the same line?



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


Re: [PR] HIVE-29354: Iceberg: [V3] Projection and Filter Pushdown for Shredded VARIANT Columns [hive]

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

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_hive&pullRequest=6224) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [44 New issues](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=6224&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=6224&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_hive&pullRequest=6224&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_hive&pullRequest=6224&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_hive&pullRequest=6224&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_hive&pullRequest=6224)
   
   


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


Re: [PR] HIVE-29354: Iceberg: [V3] Projection and Filter Pushdown for Shredded VARIANT Columns [hive]

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


##########
iceberg/iceberg-handler/src/main/java/org/apache/iceberg/mr/hive/variant/VariantProjectionUtil.java:
##########
@@ -0,0 +1,497 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iceberg.mr.hive.variant;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hive.ql.io.IOConstants;
+import org.apache.hadoop.hive.ql.io.parquet.read.DataWritableReadSupport;
+import org.apache.hadoop.hive.serde2.ColumnProjectionUtils;
+import org.apache.iceberg.Schema;
+import org.apache.iceberg.relocated.com.google.common.collect.Lists;
+import org.apache.iceberg.relocated.com.google.common.collect.Maps;
+import org.apache.iceberg.relocated.com.google.common.collect.Sets;
+import org.apache.iceberg.types.Types;
+import org.apache.parquet.column.ColumnDescriptor;
+import org.apache.parquet.schema.GroupType;
+import org.apache.parquet.schema.MessageType;
+import org.apache.parquet.schema.OriginalType;
+import org.apache.parquet.schema.Type;
+
+/**
+ * Utility class for handling Variant Projection Pushdown (Column Pruning).
+ */
+public final class VariantProjectionUtil {
+
+  private VariantProjectionUtil() {
+  }
+
+  public record VariantColumnDescriptor(
+      int rootColumnIndex,
+      int[] fieldPath,
+      String[] physicalPath,
+      Type prunedSchema) {
+  }
+
+  public record VariantProjection(
+      List<VariantColumnDescriptor> variantColumns,
+      List<ColumnDescriptor> requestedColumns) {
+
+    public static VariantProjection create(
+        MessageType fileSchema, Configuration conf, Schema icebergSchema) {
+      String columns = conf.get(IOConstants.COLUMNS);
+      if (columns == null || columns.isEmpty()) {
+        return null;
+      }
+
+      List<String> columnNames = DataWritableReadSupport.getColumnNames(columns);
+      if (columnNames == null || columnNames.isEmpty()) {
+        return null;
+      }
+
+      boolean readAll = ColumnProjectionUtils.isReadAllColumns(conf);
+      List<Integer> readColumnIds = ColumnProjectionUtils.getReadColumnIDs(conf);
+      Set<String> nestedPaths = ColumnProjectionUtils.getNestedColumnPaths(conf);
+
+      List<VariantColumnDescriptor> variantColumns =
+          discoverVariantColumns(fileSchema, icebergSchema, columnNames, readAll, readColumnIds, nestedPaths);
+      if (variantColumns.isEmpty()) {
+        return null;
+      }
+
+      List<ColumnDescriptor> requestedColumns = computeRequestedColumns(fileSchema, variantColumns);
+      if (requestedColumns.isEmpty()) {
+        return null;
+      }
+
+      return new VariantProjection(variantColumns, requestedColumns);
+    }
+  }
+
+  private static List<VariantColumnDescriptor> discoverVariantColumns(
+      MessageType fileSchema,
+      Schema icebergSchema,
+      List<String> columnNames,
+      boolean readAll,
+      List<Integer> readColumnIds,
+      Set<String> nestedPaths) {
+
+    boolean[] projected = projectedTopLevelColumns(readAll, readColumnIds, columnNames.size());
+
+    List<VariantColumnDescriptor> result = Lists.newArrayList();
+    for (int colIndex = 0; colIndex < columnNames.size(); colIndex++) {
+      if (!projected[colIndex]) {
+        continue;
+      }
+
+      String columnName = columnNames.get(colIndex);
+      // Resolve the logical Iceberg field (handling potential name mismatches from Hive)
+      Types.NestedField field = findIcebergField(icebergSchema, columnName, colIndex);
+      if (field == null || field.type() == null) {
+        continue;
+      }
+
+      // Resolve the physical Parquet type (handling schema evolution/IDs)
+      Type parquetType = findParquetType(fileSchema, field);
+      if (parquetType == null) {
+        continue;
+      }
+
+      collectVariantColumns(
+          colIndex,
+          field.type(),
+          parquetType,
+          new int[0],
+          new String[] { columnName },
+          new String[] { parquetType.getName() },
+          result,
+          nestedPaths);
+    }
+
+    return result;
+  }
+
+  /**
+   * Resolves the Iceberg field for the given Hive column.
+   * Prioritizes lookup by name, falling back to positional index if not found (e.g. rename).
+   */
+  private static Types.NestedField findIcebergField(Schema schema, String name, int index) {
+    Types.NestedField field = schema.findField(name);
+    if (field != null) {
+      return field;
+    }
+
+    // Fallback: If Hive's column configuration uses an old name (e.g. "payload") but the Iceberg schema
+    // uses the new name (e.g. "data"), try to match by position if the index is valid.
+    List<Types.NestedField> columns = schema.columns();
+    if (index >= 0 && index < columns.size()) {
+      return columns.get(index);
+    }
+
+    return null;
+  }
+
+  /**
+   * Resolves the Parquet Type for the given Iceberg field.
+   * Prioritizes lookup by Field ID (for schema evolution), falling back to name.
+   */
+  private static Type findParquetType(GroupType parent, Types.NestedField child) {
+    int id = child.fieldId();
+    for (Type candidate : parent.getFields()) {
+      if (candidate.getId() != null && candidate.getId().intValue() == id) {
+        return candidate;
+      }
+    }
+
+    String name = child.name();
+    if (name != null && !name.isEmpty() && parent.containsField(name)) {
+      return parent.getType(name);
+    }
+
+    return null;
+  }
+
+  private static boolean[] projectedTopLevelColumns(
+      boolean readAll, List<Integer> readColumnIds, int fieldCount) {
+    boolean[] projected = new boolean[fieldCount];
+    if (readAll) {
+      Arrays.fill(projected, true);
+      return projected;
+    }
+
+    if (readColumnIds == null || readColumnIds.isEmpty()) {
+      return projected;
+    }
+
+    for (Integer id : readColumnIds) {
+      if (id != null && id >= 0 && id < fieldCount) {
+        projected[id] = true;
+      }
+    }
+
+    return projected;
+  }
+
+  private static void collectVariantColumns(
+      int rootColumnIndex,
+      org.apache.iceberg.types.Type icebergType,
+      Type parquetType,
+      int[] fieldPath,
+      String[] logicalPath,
+      String[] physicalPath,
+      List<VariantColumnDescriptor> results,
+      Set<String> nestedPaths) {

Review Comment:
   spotless



##########
iceberg/iceberg-handler/src/main/java/org/apache/iceberg/mr/hive/variant/VariantPathUtil.java:
##########
@@ -0,0 +1,116 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iceberg.mr.hive.variant;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Objects;
+import org.apache.iceberg.expressions.UnboundExtract;
+import org.apache.iceberg.expressions.UnboundPredicate;
+
+public final class VariantPathUtil {
+
+  // Variant field names (matching ParquetVariantVisitor package-protected constants)
+  public static final String METADATA = "metadata";
+  public static final String VALUE = "value";
+  public static final String TYPED_VALUE = "typed_value";
+

Review Comment:
   fixed



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


Re: [PR] HIVE-29354: Shredded Variant PPD [hive]

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

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_hive&pullRequest=6224) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [36 New issues](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=6224&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=6224&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_hive&pullRequest=6224&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_hive&pullRequest=6224&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_hive&pullRequest=6224&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_hive&pullRequest=6224)
   
   


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


Re: [PR] HIVE-29354: Iceberg: [V3] Projection and Filter Pushdown for Shredded VARIANT Columns [hive]

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


##########
iceberg/iceberg-handler/src/main/java/org/apache/iceberg/mr/hive/variant/VariantProjectionUtil.java:
##########
@@ -0,0 +1,497 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iceberg.mr.hive.variant;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hive.ql.io.IOConstants;
+import org.apache.hadoop.hive.ql.io.parquet.read.DataWritableReadSupport;
+import org.apache.hadoop.hive.serde2.ColumnProjectionUtils;
+import org.apache.iceberg.Schema;
+import org.apache.iceberg.relocated.com.google.common.collect.Lists;
+import org.apache.iceberg.relocated.com.google.common.collect.Maps;
+import org.apache.iceberg.relocated.com.google.common.collect.Sets;
+import org.apache.iceberg.types.Types;
+import org.apache.parquet.column.ColumnDescriptor;
+import org.apache.parquet.schema.GroupType;
+import org.apache.parquet.schema.MessageType;
+import org.apache.parquet.schema.OriginalType;
+import org.apache.parquet.schema.Type;
+
+/**
+ * Utility class for handling Variant Projection Pushdown (Column Pruning).
+ */
+public final class VariantProjectionUtil {
+
+  private VariantProjectionUtil() {
+  }
+
+  public record VariantColumnDescriptor(
+      int rootColumnIndex,
+      int[] fieldPath,
+      String[] physicalPath,
+      Type prunedSchema) {
+  }
+
+  public record VariantProjection(
+      List<VariantColumnDescriptor> variantColumns,
+      List<ColumnDescriptor> requestedColumns) {
+
+    public static VariantProjection create(
+        MessageType fileSchema, Configuration conf, Schema icebergSchema) {
+      String columns = conf.get(IOConstants.COLUMNS);
+      if (columns == null || columns.isEmpty()) {
+        return null;
+      }
+
+      List<String> columnNames = DataWritableReadSupport.getColumnNames(columns);
+      if (columnNames == null || columnNames.isEmpty()) {
+        return null;
+      }
+
+      boolean readAll = ColumnProjectionUtils.isReadAllColumns(conf);
+      List<Integer> readColumnIds = ColumnProjectionUtils.getReadColumnIDs(conf);
+      Set<String> nestedPaths = ColumnProjectionUtils.getNestedColumnPaths(conf);
+
+      List<VariantColumnDescriptor> variantColumns =
+          discoverVariantColumns(fileSchema, icebergSchema, columnNames, readAll, readColumnIds, nestedPaths);
+      if (variantColumns.isEmpty()) {
+        return null;
+      }
+
+      List<ColumnDescriptor> requestedColumns = computeRequestedColumns(fileSchema, variantColumns);
+      if (requestedColumns.isEmpty()) {
+        return null;
+      }
+
+      return new VariantProjection(variantColumns, requestedColumns);
+    }
+  }
+
+  private static List<VariantColumnDescriptor> discoverVariantColumns(
+      MessageType fileSchema,
+      Schema icebergSchema,
+      List<String> columnNames,
+      boolean readAll,
+      List<Integer> readColumnIds,
+      Set<String> nestedPaths) {
+
+    boolean[] projected = projectedTopLevelColumns(readAll, readColumnIds, columnNames.size());
+
+    List<VariantColumnDescriptor> result = Lists.newArrayList();
+    for (int colIndex = 0; colIndex < columnNames.size(); colIndex++) {
+      if (!projected[colIndex]) {
+        continue;
+      }
+
+      String columnName = columnNames.get(colIndex);
+      // Resolve the logical Iceberg field (handling potential name mismatches from Hive)
+      Types.NestedField field = findIcebergField(icebergSchema, columnName, colIndex);
+      if (field == null || field.type() == null) {
+        continue;
+      }
+
+      // Resolve the physical Parquet type (handling schema evolution/IDs)
+      Type parquetType = findParquetType(fileSchema, field);
+      if (parquetType == null) {
+        continue;
+      }
+
+      collectVariantColumns(
+          colIndex,
+          field.type(),
+          parquetType,
+          new int[0],
+          new String[] { columnName },
+          new String[] { parquetType.getName() },
+          result,
+          nestedPaths);
+    }

Review Comment:
   it's spotless



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


Re: [PR] HIVE-29354: Iceberg: [V3] Projection and Filter Pushdown for Shredded VARIANT Columns [hive]

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

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_hive&pullRequest=6224) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [37 New issues](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=6224&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=6224&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_hive&pullRequest=6224&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_hive&pullRequest=6224&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_hive&pullRequest=6224&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_hive&pullRequest=6224)
   
   


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


Re: [PR] HIVE-29354: Iceberg: [V3] Shredded Variant PPD support [hive]

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

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_hive&pullRequest=6224) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [35 New issues](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=6224&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=6224&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_hive&pullRequest=6224&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_hive&pullRequest=6224&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_hive&pullRequest=6224&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_hive&pullRequest=6224)
   
   


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


Re: [PR] HIVE-29354: Iceberg: [V3] Shredded Variant PPD support [hive]

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

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_hive&pullRequest=6224) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [41 New issues](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=6224&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=6224&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_hive&pullRequest=6224&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_hive&pullRequest=6224&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_hive&pullRequest=6224&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_hive&pullRequest=6224)
   
   


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


Re: [PR] HIVE-29354: Iceberg: [V3] Projection and Filter Pushdown for Shredded VARIANT Columns [hive]

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


##########
iceberg/iceberg-handler/src/main/java/org/apache/iceberg/mr/hive/variant/VariantProjectionUtil.java:
##########
@@ -0,0 +1,497 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iceberg.mr.hive.variant;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hive.ql.io.IOConstants;
+import org.apache.hadoop.hive.ql.io.parquet.read.DataWritableReadSupport;
+import org.apache.hadoop.hive.serde2.ColumnProjectionUtils;
+import org.apache.iceberg.Schema;
+import org.apache.iceberg.relocated.com.google.common.collect.Lists;
+import org.apache.iceberg.relocated.com.google.common.collect.Maps;
+import org.apache.iceberg.relocated.com.google.common.collect.Sets;
+import org.apache.iceberg.types.Types;
+import org.apache.parquet.column.ColumnDescriptor;
+import org.apache.parquet.schema.GroupType;
+import org.apache.parquet.schema.MessageType;
+import org.apache.parquet.schema.OriginalType;
+import org.apache.parquet.schema.Type;
+
+/**
+ * Utility class for handling Variant Projection Pushdown (Column Pruning).
+ */
+public final class VariantProjectionUtil {
+
+  private VariantProjectionUtil() {
+  }
+
+  public record VariantColumnDescriptor(
+      int rootColumnIndex,
+      int[] fieldPath,
+      String[] physicalPath,
+      Type prunedSchema) {
+  }
+
+  public record VariantProjection(
+      List<VariantColumnDescriptor> variantColumns,
+      List<ColumnDescriptor> requestedColumns) {
+
+    public static VariantProjection create(
+        MessageType fileSchema, Configuration conf, Schema icebergSchema) {
+      String columns = conf.get(IOConstants.COLUMNS);
+      if (columns == null || columns.isEmpty()) {
+        return null;
+      }
+
+      List<String> columnNames = DataWritableReadSupport.getColumnNames(columns);
+      if (columnNames == null || columnNames.isEmpty()) {
+        return null;
+      }
+
+      boolean readAll = ColumnProjectionUtils.isReadAllColumns(conf);
+      List<Integer> readColumnIds = ColumnProjectionUtils.getReadColumnIDs(conf);
+      Set<String> nestedPaths = ColumnProjectionUtils.getNestedColumnPaths(conf);
+
+      List<VariantColumnDescriptor> variantColumns =
+          discoverVariantColumns(fileSchema, icebergSchema, columnNames, readAll, readColumnIds, nestedPaths);
+      if (variantColumns.isEmpty()) {
+        return null;
+      }
+
+      List<ColumnDescriptor> requestedColumns = computeRequestedColumns(fileSchema, variantColumns);
+      if (requestedColumns.isEmpty()) {
+        return null;
+      }
+
+      return new VariantProjection(variantColumns, requestedColumns);
+    }
+  }
+
+  private static List<VariantColumnDescriptor> discoverVariantColumns(
+      MessageType fileSchema,
+      Schema icebergSchema,
+      List<String> columnNames,
+      boolean readAll,
+      List<Integer> readColumnIds,
+      Set<String> nestedPaths) {
+
+    boolean[] projected = projectedTopLevelColumns(readAll, readColumnIds, columnNames.size());
+
+    List<VariantColumnDescriptor> result = Lists.newArrayList();
+    for (int colIndex = 0; colIndex < columnNames.size(); colIndex++) {
+      if (!projected[colIndex]) {
+        continue;
+      }
+
+      String columnName = columnNames.get(colIndex);
+      // Resolve the logical Iceberg field (handling potential name mismatches from Hive)
+      Types.NestedField field = findIcebergField(icebergSchema, columnName, colIndex);
+      if (field == null || field.type() == null) {
+        continue;
+      }
+
+      // Resolve the physical Parquet type (handling schema evolution/IDs)
+      Type parquetType = findParquetType(fileSchema, field);
+      if (parquetType == null) {
+        continue;
+      }
+
+      collectVariantColumns(
+          colIndex,
+          field.type(),
+          parquetType,
+          new int[0],
+          new String[] { columnName },
+          new String[] { parquetType.getName() },
+          result,
+          nestedPaths);
+    }
+
+    return result;
+  }
+
+  /**
+   * Resolves the Iceberg field for the given Hive column.
+   * Prioritizes lookup by name, falling back to positional index if not found (e.g. rename).
+   */
+  private static Types.NestedField findIcebergField(Schema schema, String name, int index) {
+    Types.NestedField field = schema.findField(name);
+    if (field != null) {
+      return field;
+    }
+
+    // Fallback: If Hive's column configuration uses an old name (e.g. "payload") but the Iceberg schema
+    // uses the new name (e.g. "data"), try to match by position if the index is valid.
+    List<Types.NestedField> columns = schema.columns();
+    if (index >= 0 && index < columns.size()) {
+      return columns.get(index);
+    }
+
+    return null;
+  }
+
+  /**
+   * Resolves the Parquet Type for the given Iceberg field.
+   * Prioritizes lookup by Field ID (for schema evolution), falling back to name.
+   */
+  private static Type findParquetType(GroupType parent, Types.NestedField child) {
+    int id = child.fieldId();
+    for (Type candidate : parent.getFields()) {
+      if (candidate.getId() != null && candidate.getId().intValue() == id) {
+        return candidate;
+      }
+    }
+
+    String name = child.name();
+    if (name != null && !name.isEmpty() && parent.containsField(name)) {
+      return parent.getType(name);
+    }
+
+    return null;
+  }
+
+  private static boolean[] projectedTopLevelColumns(
+      boolean readAll, List<Integer> readColumnIds, int fieldCount) {
+    boolean[] projected = new boolean[fieldCount];
+    if (readAll) {
+      Arrays.fill(projected, true);
+      return projected;
+    }
+
+    if (readColumnIds == null || readColumnIds.isEmpty()) {
+      return projected;
+    }
+
+    for (Integer id : readColumnIds) {
+      if (id != null && id >= 0 && id < fieldCount) {
+        projected[id] = true;
+      }
+    }
+
+    return projected;
+  }
+
+  private static void collectVariantColumns(
+      int rootColumnIndex,
+      org.apache.iceberg.types.Type icebergType,
+      Type parquetType,
+      int[] fieldPath,
+      String[] logicalPath,
+      String[] physicalPath,
+      List<VariantColumnDescriptor> results,
+      Set<String> nestedPaths) {

Review Comment:
   same



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


Re: [PR] HIVE-29354: Iceberg: [V3] Projection and Filter Pushdown for Shredded VARIANT Columns [hive]

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

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_hive&pullRequest=6224) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [44 New issues](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=6224&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=6224&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_hive&pullRequest=6224&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_hive&pullRequest=6224&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_hive&pullRequest=6224&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_hive&pullRequest=6224)
   
   


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


Re: [PR] HIVE-29354: Shredded Variant PPD [hive]

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

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_hive&pullRequest=6224) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [35 New issues](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=6224&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=6224&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_hive&pullRequest=6224&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_hive&pullRequest=6224&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_hive&pullRequest=6224&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_hive&pullRequest=6224)
   
   


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


Re: [PR] HIVE-29354: Iceberg: [V3] Shredded Variant PPD support [hive]

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

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_hive&pullRequest=6224) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [46 New issues](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=6224&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=6224&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_hive&pullRequest=6224&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_hive&pullRequest=6224&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_hive&pullRequest=6224&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_hive&pullRequest=6224)
   
   


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


Re: [PR] HIVE-29354: Iceberg: [V3] Shredded Variant PPD support [hive]

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

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_hive&pullRequest=6224) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [34 New issues](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=6224&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=6224&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_hive&pullRequest=6224&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_hive&pullRequest=6224&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_hive&pullRequest=6224&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_hive&pullRequest=6224)
   
   


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


Re: [PR] HIVE-29354: Iceberg: [V3] Projection and Filter Pushdown for Shredded VARIANT Columns [hive]

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

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_hive&pullRequest=6224) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [44 New issues](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=6224&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=6224&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_hive&pullRequest=6224&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_hive&pullRequest=6224&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_hive&pullRequest=6224&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_hive&pullRequest=6224)
   
   


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


Re: [PR] HIVE-29354: Iceberg: [V3] Projection and Filter Pushdown for Shredded VARIANT Columns [hive]

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

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_hive&pullRequest=6224) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [44 New issues](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=6224&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=6224&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_hive&pullRequest=6224&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_hive&pullRequest=6224&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_hive&pullRequest=6224&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_hive&pullRequest=6224)
   
   


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


Re: [PR] HIVE-29354: Iceberg: [V3] Projection and Filter Pushdown for Shredded VARIANT Columns [hive]

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


##########
iceberg/iceberg-handler/src/main/java/org/apache/iceberg/mr/hive/vector/ParquetVariantRecordReader.java:
##########
@@ -0,0 +1,388 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iceberg.mr.hive.vector;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Optional;
+import java.util.function.ToIntFunction;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.hive.ql.exec.vector.BytesColumnVector;
+import org.apache.hadoop.hive.ql.exec.vector.ColumnVector;
+import org.apache.hadoop.hive.ql.exec.vector.StructColumnVector;
+import org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch;
+import org.apache.hadoop.hive.ql.io.parquet.ParquetRecordReaderBase;
+import org.apache.hadoop.io.NullWritable;
+import org.apache.hadoop.mapred.JobConf;
+import org.apache.hadoop.mapred.RecordReader;
+import org.apache.iceberg.FileScanTask;
+import org.apache.iceberg.mr.hive.variant.VariantProjectionUtil.VariantColumnDescriptor;
+import org.apache.iceberg.mr.hive.variant.VariantProjectionUtil.VariantProjection;
+import org.apache.iceberg.parquet.ParquetValueReader;
+import org.apache.iceberg.parquet.ParquetVariantVisitor;
+import org.apache.iceberg.parquet.VariantReaderBuilder;
+import org.apache.iceberg.relocated.com.google.common.collect.Lists;
+import org.apache.iceberg.variants.Variant;
+import org.apache.iceberg.variants.VariantMetadata;
+import org.apache.iceberg.variants.VariantValue;
+import org.apache.parquet.column.page.PageReadStore;
+import org.apache.parquet.hadoop.ParquetFileReader;
+import org.apache.parquet.hadoop.metadata.BlockMetaData;
+import org.apache.parquet.hadoop.metadata.ParquetMetadata;
+import org.apache.parquet.schema.MessageType;
+import org.apache.parquet.schema.Type;
+
+final class ParquetVariantRecordReader implements RecordReader<NullWritable, VectorizedRowBatch> {
+
+  private final RecordReader<NullWritable, VectorizedRowBatch> delegate;
+  private final ParquetFileReader parquetReader;
+
+  private final List<VariantColumnDescriptor> variantColumns;
+  private final ParquetValueReader<Variant>[] readers;
+  private final StructColumnVector[] structCvb;
+
+  private long remainingInRowGroup;
+
+  @SuppressWarnings("unchecked")
+  private ParquetVariantRecordReader(
+      RecordReader<NullWritable, VectorizedRowBatch> delegate,
+      JobConf job,
+      Path path,
+      ParquetMetadata parquetMetadata,
+      List<BlockMetaData> blocks,
+      VariantProjection projection) throws IOException {
+    this.delegate = delegate;
+    this.variantColumns = projection.variantColumns();
+    this.structCvb = new StructColumnVector[variantColumns.size()];
+    this.readers = new ParquetValueReader[variantColumns.size()];
+
+    MessageType fileSchema = parquetMetadata.getFileMetaData().getSchema();
+    for (int i = 0; i < variantColumns.size(); i++) {
+      readers[i] = createReader(fileSchema, variantColumns.get(i));
+    }
+
+    this.parquetReader = new ParquetFileReader(
+        job, parquetMetadata.getFileMetaData(), path, blocks, projection.requestedColumns());
+
+    advanceRowGroup();
+  }
+
+  /**
+   * Wrapper to read Iceberg shredded VARIANT data and populate Hive's VARIANT struct (metadata/value).
+   * <p>
+   * Ensures correct reconstruction from shredded fields which standard Hive readers might miss.
+   */
+  static Optional<RecordReader<NullWritable, VectorizedRowBatch>> tryWrap(
+      RecordReader<NullWritable, VectorizedRowBatch> delegate,
+      JobConf job,
+      FileScanTask task,
+      Path path,
+      long start,
+      long length,
+      ParquetMetadata parquetMetadata) throws IOException {
+
+    if (delegate == null || parquetMetadata == null || parquetMetadata.getFileMetaData() == null) {
+      return Optional.empty();
+    }
+
+    MessageType fileSchema = parquetMetadata.getFileMetaData().getSchema();
+    if (fileSchema == null) {
+      return Optional.empty();
+    }
+
+    VariantProjection projection = VariantProjection.create(fileSchema, job, task.spec().schema());
+    if (projection == null) {
+      return Optional.empty();
+    }
+
+    List<BlockMetaData> blocks = blocksForSplit(delegate, start, length, parquetMetadata);
+    if (blocks.isEmpty()) {
+      // Delegate reader will handle empty split; don't wrap.
+      return Optional.empty();
+    }
+
+    return Optional.of(
+        new ParquetVariantRecordReader(
+            delegate, job, path, parquetMetadata, blocks, projection));
+  }
+
+  private static List<BlockMetaData> blocksForSplit(
+      RecordReader<NullWritable, VectorizedRowBatch> delegate,
+      long start,
+      long length,
+      ParquetMetadata parquetMetadata) {
+
+    // If the underlying Hive Parquet reader already computed row-group filtering (e.g. from SARG),
+    // we must use the exact same blocks to keep this reader aligned with the delegate.
+    if (delegate instanceof ParquetRecordReaderBase parquetDelegate) {
+      List<BlockMetaData> filteredBlocks = parquetDelegate.getFilteredBlocks();
+      // Treat an empty list as authoritative (delegate filtered out all row groups).
+      if (filteredBlocks != null) {
+        return filteredBlocks;
+      }
+    }
+    // Fallback: compute blocks from split boundaries
+    List<BlockMetaData> splitBlocks = Lists.newArrayList();
+    for (BlockMetaData block : parquetMetadata.getBlocks()) {
+      long firstDataPage = block.getColumns().getFirst().getFirstDataPageOffset();
+      if (firstDataPage >= start && firstDataPage < start + length) {
+        splitBlocks.add(block);
+      }
+    }
+    return splitBlocks;
+  }
+
+  @Override
+  public boolean next(NullWritable key, VectorizedRowBatch value) throws IOException {
+    boolean hasNext = delegate.next(key, value);
+    if (!hasNext || value == null || value.size <= 0) {
+      return hasNext;
+    }
+    populateVariantStructColumns(value);
+    return true;
+  }
+
+  private void populateVariantStructColumns(VectorizedRowBatch batch) throws IOException {
+    for (int i = 0; i < variantColumns.size(); i++) {
+      structCvb[i] = variantStructVector(batch, variantColumns.get(i));
+    }
+
+    int offset = 0;
+    while (offset < batch.size) {
+      ensureRowAvailable();
+      if (remainingInRowGroup == 0) {
+        break;
+      }
+      int length = (int) Math.min(batch.size - offset, remainingInRowGroup);
+      processChunk(batch, offset, length);
+
+      remainingInRowGroup -= length;
+      offset += length;
+    }
+  }
+
+  private void processChunk(VectorizedRowBatch batch, int offset, int length) {
+    boolean selectedInUse = batch.selectedInUse;
+    int[] selected = batch.selected;
+
+    for (int i = 0; i < variantColumns.size(); i++) {
+      StructColumnVector structVector = structCvb[i];
+      ParquetValueReader<Variant> reader = readers[i];
+
+      // variantStructVector guarantees fields != null and fields.length >= 2 when non-null
+      // and that metadata/value vectors are present.
+      BytesColumnVector metadataVector = (BytesColumnVector) structVector.fields[0];
+      BytesColumnVector valueVector = (BytesColumnVector) structVector.fields[1];
+
+      ByteBuffer metadataBuffer = null;
+      byte[] lastMetadataArray = null;
+
+      ByteBuffer valueBuffer = null;
+      byte[] lastValueArray = null;
+
+      for (int pos = 0; pos < length; pos++) {
+        int batchIndex = offset + pos;
+        int row = selectedInUse ? selected[batchIndex] : batchIndex;
+
+        Variant variant = reader.read(null);
+
+        if (variant != null) {
+          structVector.isNull[row] = false;
+          metadataVector.isNull[row] = false;
+          valueVector.isNull[row] = false;
+
+          metadataBuffer = writeMetadata(
+              metadataVector, row, variant.metadata(), metadataBuffer, lastMetadataArray);
+          lastMetadataArray = metadataVector.getValPreallocatedBytes();
+
+          valueBuffer = writeValue(
+              valueVector, row, variant.value(), valueBuffer, lastValueArray);
+          lastValueArray = valueVector.getValPreallocatedBytes();
+        } else {
+          structVector.noNulls = false;
+          structVector.isNull[row] = true;
+          metadataVector.noNulls = false;
+          metadataVector.isNull[row] = true;
+          valueVector.noNulls = false;
+          valueVector.isNull[row] = true;
+        }
+      }
+    }
+  }
+
+  @SuppressWarnings("checkstyle:CyclomaticComplexity")
+  private static StructColumnVector variantStructVector(
+      VectorizedRowBatch batch, VariantColumnDescriptor vc) throws IOException {
+    if (batch == null || vc == null || batch.cols == null) {
+      throw new IOException("Invalid batch or descriptor: batch=" + batch + ", vc=" + vc);
+    }
+
+    int rootIndex = vc.rootColumnIndex();
+    if (rootIndex < 0 || rootIndex >= batch.cols.length) {
+      throw new IOException("Root column index " + rootIndex + " out of bounds (cols=" + batch.cols.length + ")");
+    }
+
+    ColumnVector current = batch.cols[rootIndex];
+
+    for (int fieldIndex : vc.fieldPath()) {
+      if (!(current instanceof StructColumnVector struct)) {
+        throw new IOException("Expected nested StructColumnVector at field index " + fieldIndex +
+            " for column " + Arrays.toString(vc.physicalPath()) + ", found " +
+            (current == null ? "null" : current.getClass().getSimpleName()));
+      }
+      struct.isRepeating = false;
+
+      if (struct.fields == null || fieldIndex < 0 || fieldIndex >= struct.fields.length) {
+        throw new IOException("Invalid field path index " + fieldIndex + " for struct with " +
+            (struct.fields == null ? "null" : struct.fields.length) + " fields");
+      }
+      current = struct.fields[fieldIndex];
+    }
+
+    if (!(current instanceof StructColumnVector variantStruct)) {
+      throw new IOException("Expected Variant StructColumnVector at " + Arrays.toString(vc.physicalPath()) +
+          ", found " + (current == null ? "null" : current.getClass().getSimpleName()));
+    }
+
+    if (variantStruct.fields == null || variantStruct.fields.length != 2) {
+      throw new IOException("Invalid Variant struct fields at " + Arrays.toString(vc.physicalPath()) +
+          ": expected exactly 2 fields (metadata, value), found " +
+          (variantStruct.fields == null ? "null" : variantStruct.fields.length));
+    }
+    variantStruct.isRepeating = false;
+
+    if (variantStruct.fields[0] == null) {
+      throw new IOException("Invalid Variant vector structure for column " +
+          Arrays.toString(vc.physicalPath()) + ": metadata vector is null.");
+    }
+    variantStruct.fields[0].isRepeating = false;
+
+    if (variantStruct.fields[1] == null) {
+      throw new IOException("Invalid Variant vector structure for column " +
+          Arrays.toString(vc.physicalPath()) + ": value vector is null.");
+    }

Review Comment:
   The 2 exceptions and error messages are identical, can you combine them to reduce code duplication?



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


Re: [PR] HIVE-29354: Iceberg: [V3] Projection and Filter Pushdown for Shredded VARIANT Columns [hive]

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

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_hive&pullRequest=6224) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [44 New issues](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=6224&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=6224&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_hive&pullRequest=6224&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_hive&pullRequest=6224&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_hive&pullRequest=6224&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_hive&pullRequest=6224)
   
   


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


Re: [PR] HIVE-29354: Iceberg: [V3] Shredded Variant PPD support [hive]

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

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_hive&pullRequest=6224) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [36 New issues](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=6224&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=6224&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_hive&pullRequest=6224&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_hive&pullRequest=6224&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_hive&pullRequest=6224&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_hive&pullRequest=6224)
   
   


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


Re: [PR] HIVE-29354: Iceberg: [V3] Shredded Variant PPD support [hive]

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

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_hive&pullRequest=6224) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [34 New issues](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=6224&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=6224&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_hive&pullRequest=6224&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_hive&pullRequest=6224&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_hive&pullRequest=6224&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_hive&pullRequest=6224)
   
   


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


Re: [PR] HIVE-29354: Iceberg: [V3] Shredded Variant PPD support [hive]

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

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_hive&pullRequest=6224) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [35 New issues](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=6224&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=6224&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_hive&pullRequest=6224&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_hive&pullRequest=6224&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_hive&pullRequest=6224&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_hive&pullRequest=6224)
   
   


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


Re: [PR] HIVE-29354: Iceberg: [V3] Projection and Filter Pushdown for Shredded VARIANT Columns [hive]

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


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


Re: [PR] HIVE-29354: Iceberg: [V3] Projection and Filter Pushdown for Shredded VARIANT Columns [hive]

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

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_hive&pullRequest=6224) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [44 New issues](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=6224&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=6224&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_hive&pullRequest=6224&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_hive&pullRequest=6224&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_hive&pullRequest=6224&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_hive&pullRequest=6224)
   
   


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


Re: [PR] HIVE-29354: Iceberg: [V3] Projection and Filter Pushdown for Shredded VARIANT Columns [hive]

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


##########
iceberg/iceberg-handler/src/test/results/positive/variant_type_filter.q.out:
##########
@@ -95,19 +282,20 @@ STAGE PLANS:
         Map 1 
             Map Operator Tree:
                 TableScan
-                  alias: variant_filter_basic
-                  filterExpr: (try_variant_get(data, '$.age', 'int') >= 30) (type: boolean)
-                  Statistics: Num rows: 3 Data size: 1008 Basic stats: COMPLETE Column stats: NONE
+                  alias: shredded_variant_ppd
+                  filterExpr: variant_get(data, '$.address.city') is not null (type: boolean)
+                  Pruned Column Paths: data.name, data.address.city

Review Comment:
   Expected projection with select and filter columns pushdown



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


Re: [PR] HIVE-29354: Iceberg: [V3] Shredded Variant PPD support [hive]

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

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_hive&pullRequest=6224) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [44 New issues](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=6224&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=6224&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_hive&pullRequest=6224&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_hive&pullRequest=6224&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_hive&pullRequest=6224&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_hive&pullRequest=6224)
   
   


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


Re: [PR] HIVE-29354: Iceberg: [V3] Shredded Variant PPD support [hive]

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

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_hive&pullRequest=6224) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [40 New issues](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=6224&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=6224&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_hive&pullRequest=6224&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_hive&pullRequest=6224&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_hive&pullRequest=6224&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_hive&pullRequest=6224)
   
   


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


Re: [PR] HIVE-29354: Iceberg: [V3] Shredded Variant PPD support [hive]

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

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_hive&pullRequest=6224) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [39 New issues](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=6224&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=6224&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_hive&pullRequest=6224&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_hive&pullRequest=6224&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_hive&pullRequest=6224&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_hive&pullRequest=6224)
   
   


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


Re: [PR] HIVE-29354: Iceberg: [V3] Projection and Filter Pushdown for Shredded VARIANT Columns [hive]

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

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_hive&pullRequest=6224) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [44 New issues](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=6224&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=6224&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_hive&pullRequest=6224&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_hive&pullRequest=6224&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_hive&pullRequest=6224&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_hive&pullRequest=6224)
   
   


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


Re: [PR] HIVE-29354: Iceberg: [V3] Projection and Filter Pushdown for Shredded VARIANT Columns [hive]

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

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_hive&pullRequest=6224) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [63 New issues](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=6224&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=6224&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_hive&pullRequest=6224&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_hive&pullRequest=6224&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_hive&pullRequest=6224&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_hive&pullRequest=6224)
   
   


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


Re: [PR] HIVE-29354: Iceberg: [V3] Projection and Filter Pushdown for Shredded VARIANT Columns [hive]

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


##########
iceberg/iceberg-handler/src/main/java/org/apache/iceberg/mr/hive/vector/ParquetVariantRecordReader.java:
##########
@@ -0,0 +1,388 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iceberg.mr.hive.vector;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Optional;
+import java.util.function.ToIntFunction;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.hive.ql.exec.vector.BytesColumnVector;
+import org.apache.hadoop.hive.ql.exec.vector.ColumnVector;
+import org.apache.hadoop.hive.ql.exec.vector.StructColumnVector;
+import org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch;
+import org.apache.hadoop.hive.ql.io.parquet.ParquetRecordReaderBase;
+import org.apache.hadoop.io.NullWritable;
+import org.apache.hadoop.mapred.JobConf;
+import org.apache.hadoop.mapred.RecordReader;
+import org.apache.iceberg.FileScanTask;
+import org.apache.iceberg.mr.hive.variant.VariantProjectionUtil.VariantColumnDescriptor;
+import org.apache.iceberg.mr.hive.variant.VariantProjectionUtil.VariantProjection;
+import org.apache.iceberg.parquet.ParquetValueReader;
+import org.apache.iceberg.parquet.ParquetVariantVisitor;
+import org.apache.iceberg.parquet.VariantReaderBuilder;
+import org.apache.iceberg.relocated.com.google.common.collect.Lists;
+import org.apache.iceberg.variants.Variant;
+import org.apache.iceberg.variants.VariantMetadata;
+import org.apache.iceberg.variants.VariantValue;
+import org.apache.parquet.column.page.PageReadStore;
+import org.apache.parquet.hadoop.ParquetFileReader;
+import org.apache.parquet.hadoop.metadata.BlockMetaData;
+import org.apache.parquet.hadoop.metadata.ParquetMetadata;
+import org.apache.parquet.schema.MessageType;
+import org.apache.parquet.schema.Type;
+
+final class ParquetVariantRecordReader implements RecordReader<NullWritable, VectorizedRowBatch> {
+
+  private final RecordReader<NullWritable, VectorizedRowBatch> delegate;
+  private final ParquetFileReader parquetReader;
+
+  private final List<VariantColumnDescriptor> variantColumns;
+  private final ParquetValueReader<Variant>[] readers;
+  private final StructColumnVector[] structCvb;
+
+  private long remainingInRowGroup;
+
+  @SuppressWarnings("unchecked")
+  private ParquetVariantRecordReader(
+      RecordReader<NullWritable, VectorizedRowBatch> delegate,
+      JobConf job,
+      Path path,
+      ParquetMetadata parquetMetadata,
+      List<BlockMetaData> blocks,
+      VariantProjection projection) throws IOException {
+    this.delegate = delegate;
+    this.variantColumns = projection.variantColumns();
+    this.structCvb = new StructColumnVector[variantColumns.size()];
+    this.readers = new ParquetValueReader[variantColumns.size()];
+
+    MessageType fileSchema = parquetMetadata.getFileMetaData().getSchema();
+    for (int i = 0; i < variantColumns.size(); i++) {
+      readers[i] = createReader(fileSchema, variantColumns.get(i));
+    }
+
+    this.parquetReader = new ParquetFileReader(
+        job, parquetMetadata.getFileMetaData(), path, blocks, projection.requestedColumns());
+
+    advanceRowGroup();
+  }
+
+  /**
+   * Wrapper to read Iceberg shredded VARIANT data and populate Hive's VARIANT struct (metadata/value).
+   * <p>
+   * Ensures correct reconstruction from shredded fields which standard Hive readers might miss.
+   */
+  static Optional<RecordReader<NullWritable, VectorizedRowBatch>> tryWrap(
+      RecordReader<NullWritable, VectorizedRowBatch> delegate,
+      JobConf job,
+      FileScanTask task,
+      Path path,
+      long start,
+      long length,
+      ParquetMetadata parquetMetadata) throws IOException {
+
+    if (delegate == null || parquetMetadata == null || parquetMetadata.getFileMetaData() == null) {
+      return Optional.empty();
+    }
+
+    MessageType fileSchema = parquetMetadata.getFileMetaData().getSchema();
+    if (fileSchema == null) {
+      return Optional.empty();
+    }
+
+    VariantProjection projection = VariantProjection.create(fileSchema, job, task.spec().schema());
+    if (projection == null) {
+      return Optional.empty();
+    }
+
+    List<BlockMetaData> blocks = blocksForSplit(delegate, start, length, parquetMetadata);
+    if (blocks.isEmpty()) {
+      // Delegate reader will handle empty split; don't wrap.
+      return Optional.empty();
+    }
+
+    return Optional.of(
+        new ParquetVariantRecordReader(
+            delegate, job, path, parquetMetadata, blocks, projection));
+  }
+
+  private static List<BlockMetaData> blocksForSplit(
+      RecordReader<NullWritable, VectorizedRowBatch> delegate,
+      long start,
+      long length,
+      ParquetMetadata parquetMetadata) {
+
+    // If the underlying Hive Parquet reader already computed row-group filtering (e.g. from SARG),
+    // we must use the exact same blocks to keep this reader aligned with the delegate.
+    if (delegate instanceof ParquetRecordReaderBase parquetDelegate) {
+      List<BlockMetaData> filteredBlocks = parquetDelegate.getFilteredBlocks();
+      // Treat an empty list as authoritative (delegate filtered out all row groups).
+      if (filteredBlocks != null) {
+        return filteredBlocks;
+      }
+    }
+    // Fallback: compute blocks from split boundaries
+    List<BlockMetaData> splitBlocks = Lists.newArrayList();
+    for (BlockMetaData block : parquetMetadata.getBlocks()) {
+      long firstDataPage = block.getColumns().getFirst().getFirstDataPageOffset();
+      if (firstDataPage >= start && firstDataPage < start + length) {
+        splitBlocks.add(block);
+      }
+    }
+    return splitBlocks;
+  }
+
+  @Override
+  public boolean next(NullWritable key, VectorizedRowBatch value) throws IOException {
+    boolean hasNext = delegate.next(key, value);
+    if (!hasNext || value == null || value.size <= 0) {
+      return hasNext;
+    }
+    populateVariantStructColumns(value);
+    return true;
+  }
+
+  private void populateVariantStructColumns(VectorizedRowBatch batch) throws IOException {
+    for (int i = 0; i < variantColumns.size(); i++) {
+      structCvb[i] = variantStructVector(batch, variantColumns.get(i));
+    }
+
+    int offset = 0;
+    while (offset < batch.size) {
+      ensureRowAvailable();
+      if (remainingInRowGroup == 0) {
+        break;
+      }
+      int length = (int) Math.min(batch.size - offset, remainingInRowGroup);
+      processChunk(batch, offset, length);
+
+      remainingInRowGroup -= length;
+      offset += length;
+    }
+  }
+
+  private void processChunk(VectorizedRowBatch batch, int offset, int length) {
+    boolean selectedInUse = batch.selectedInUse;
+    int[] selected = batch.selected;
+
+    for (int i = 0; i < variantColumns.size(); i++) {
+      StructColumnVector structVector = structCvb[i];
+      ParquetValueReader<Variant> reader = readers[i];
+
+      // variantStructVector guarantees fields != null and fields.length >= 2 when non-null
+      // and that metadata/value vectors are present.
+      BytesColumnVector metadataVector = (BytesColumnVector) structVector.fields[0];
+      BytesColumnVector valueVector = (BytesColumnVector) structVector.fields[1];
+
+      ByteBuffer metadataBuffer = null;
+      byte[] lastMetadataArray = null;
+
+      ByteBuffer valueBuffer = null;
+      byte[] lastValueArray = null;
+
+      for (int pos = 0; pos < length; pos++) {
+        int batchIndex = offset + pos;
+        int row = selectedInUse ? selected[batchIndex] : batchIndex;
+
+        Variant variant = reader.read(null);
+
+        if (variant != null) {
+          structVector.isNull[row] = false;
+          metadataVector.isNull[row] = false;
+          valueVector.isNull[row] = false;
+
+          metadataBuffer = writeMetadata(
+              metadataVector, row, variant.metadata(), metadataBuffer, lastMetadataArray);
+          lastMetadataArray = metadataVector.getValPreallocatedBytes();
+
+          valueBuffer = writeValue(
+              valueVector, row, variant.value(), valueBuffer, lastValueArray);
+          lastValueArray = valueVector.getValPreallocatedBytes();
+        } else {
+          structVector.noNulls = false;
+          structVector.isNull[row] = true;
+          metadataVector.noNulls = false;
+          metadataVector.isNull[row] = true;
+          valueVector.noNulls = false;
+          valueVector.isNull[row] = true;
+        }
+      }
+    }
+  }
+
+  @SuppressWarnings("checkstyle:CyclomaticComplexity")
+  private static StructColumnVector variantStructVector(
+      VectorizedRowBatch batch, VariantColumnDescriptor vc) throws IOException {
+    if (batch == null || vc == null || batch.cols == null) {
+      throw new IOException("Invalid batch or descriptor: batch=" + batch + ", vc=" + vc);
+    }
+
+    int rootIndex = vc.rootColumnIndex();
+    if (rootIndex < 0 || rootIndex >= batch.cols.length) {
+      throw new IOException("Root column index " + rootIndex + " out of bounds (cols=" + batch.cols.length + ")");
+    }
+
+    ColumnVector current = batch.cols[rootIndex];
+
+    for (int fieldIndex : vc.fieldPath()) {
+      if (!(current instanceof StructColumnVector struct)) {
+        throw new IOException("Expected nested StructColumnVector at field index " + fieldIndex +
+            " for column " + Arrays.toString(vc.physicalPath()) + ", found " +
+            (current == null ? "null" : current.getClass().getSimpleName()));
+      }
+      struct.isRepeating = false;
+
+      if (struct.fields == null || fieldIndex < 0 || fieldIndex >= struct.fields.length) {
+        throw new IOException("Invalid field path index " + fieldIndex + " for struct with " +
+            (struct.fields == null ? "null" : struct.fields.length) + " fields");
+      }
+      current = struct.fields[fieldIndex];
+    }
+
+    if (!(current instanceof StructColumnVector variantStruct)) {
+      throw new IOException("Expected Variant StructColumnVector at " + Arrays.toString(vc.physicalPath()) +
+          ", found " + (current == null ? "null" : current.getClass().getSimpleName()));
+    }
+
+    if (variantStruct.fields == null || variantStruct.fields.length != 2) {
+      throw new IOException("Invalid Variant struct fields at " + Arrays.toString(vc.physicalPath()) +
+          ": expected exactly 2 fields (metadata, value), found " +
+          (variantStruct.fields == null ? "null" : variantStruct.fields.length));
+    }
+    variantStruct.isRepeating = false;
+
+    if (variantStruct.fields[0] == null) {
+      throw new IOException("Invalid Variant vector structure for column " +
+          Arrays.toString(vc.physicalPath()) + ": metadata vector is null.");
+    }
+    variantStruct.fields[0].isRepeating = false;
+
+    if (variantStruct.fields[1] == null) {
+      throw new IOException("Invalid Variant vector structure for column " +
+          Arrays.toString(vc.physicalPath()) + ": value vector is null.");
+    }

Review Comment:
   moved to constant



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