You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by "xiangfu0 (via GitHub)" <gi...@apache.org> on 2026/04/25 06:13:44 UTC
Re: [PR] Fix Parquet LIST/MAP wrapper extraction in native and Avro readers [pinot]
xiangfu0 commented on code in PR #18325:
URL: https://github.com/apache/pinot/pull/18325#discussion_r3141562539
##########
pinot-plugins/pinot-input-format/pinot-parquet/src/main/java/org/apache/pinot/plugin/inputformat/parquet/ParquetAvroRecordExtractor.java:
##########
@@ -63,4 +77,22 @@ Object handleDeprecatedTypes(Object value, Schema.Field field) {
}
return value;
}
+
+ private boolean isListElementWrapper(Schema.Field field) {
Review Comment:
Done. `transformValue` now checks `isListElementWrapper(field)` first and only converts/recurses on the inner element field accordingly. For nested `LIST<LIST<...>>` and INT96, recursing via `transformValue` keeps applying `isListElementWrapper` and `handleDeprecatedTypes` at every level — added a regression test for that.
Map handling is delegated to parquet-avro: a Parquet `MAP` is surfaced as an Avro `map` and converted by the base `AvroRecordExtractor.convert()` path, so no extra branch is needed here. Documented inline.
##########
pinot-plugins/pinot-input-format/pinot-parquet/src/main/java/org/apache/pinot/plugin/inputformat/parquet/ParquetNativeRecordExtractor.java:
##########
@@ -195,4 +195,38 @@ public Map<String, Object> extractMap(Group group) {
}
return map;
}
+
+ private Map<String, Object> extractKeyValueMap(Group group) {
+ int numValues = group.getFieldRepetitionCount(0);
+ if (numValues == 0) {
+ return Map.of();
+ }
+
+ // MAP has a single repeated key/value child, so extract entries from that schema instead of probing user data.
+ Map<String, Object> map = Maps.newHashMapWithExpectedSize(numValues);
+ for (int i = 0; i < numValues; i++) {
+ Group keyValueGroup = group.getGroup(0, i);
+ GroupType keyValueType = keyValueGroup.getType();
+ Object key = extractValue(keyValueGroup, keyValueType.getFieldIndex("key"));
+ Object value = extractValue(keyValueGroup, keyValueType.getFieldIndex("value"));
+ map.put(key.toString(), value);
+ }
+ return map;
+ }
+
+ @Nullable
+ private Object extractListElement(Group group, Type repeatedField, int index) {
Review Comment:
Per the Parquet spec MAP is always under `key`/`value`, so the new `extractKeyValueMap` resolves those indices once from the schema and reuses them.
LIST is different: only the standard 3-level encoding has the inner `element` wrapper. Legacy 2-level encodings exist — repeated primitive (`repeated <type> <name>;`), repeated multi-field group, and repeated single-field group not named `element` (e.g. Hive's `_tuple` / `bag` / `item`) — where the repeated field IS the element. We still need the schema check, but it's hoisted out of the per-row loop now (decided once per LIST value, not per element). Each branch documents the scenario it handles.
##########
pinot-plugins/pinot-input-format/pinot-parquet/src/main/java/org/apache/pinot/plugin/inputformat/parquet/ParquetRecordExtractorUtils.java:
##########
@@ -0,0 +1,112 @@
+/**
+ * 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.pinot.plugin.inputformat.parquet;
+
+import java.util.Collection;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+
+/**
+ * Shared helpers for normalizing Parquet list wrapper records while extracting Pinot rows.
+ *
+ * <p>This class is stateless and thread-safe.
+ */
+final class ParquetRecordExtractorUtils {
Review Comment:
The utility class was removed in the refactor — wrapper detection lives directly in `ParquetAvroRecordExtractor` / `ParquetNativeRecordExtractor` now, so there's no shared helper to expose.
--
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: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org