Gabriel39 commented on code in PR #70808:
URL: https://github.com/apache/doris/pull/70808#discussion_r4680590570
##########
fe/fe-connector/fe-connector-hive/src/main/java/org/apache/doris/connector/hive/HiveScanPlanProvider.java:
##########
@@ -818,9 +847,11 @@ void recordPruningProfile(HiveTableHandle handle) {
}
private List<PartitionScanInfo> convertPartitions(
- List<HmsPartitionInfo> hmsPartitions, List<String> partKeyNames) {
+ List<HmsPartitionInfo> hmsPartitions, HiveTableHandle handle,
HiveFileFormat format) {
+ List<String> partKeyNames = handle.getPartitionKeyNames();
List<PartitionScanInfo> result = new ArrayList<>(hmsPartitions.size());
for (HmsPartitionInfo part : hmsPartitions) {
+ HiveAvroSchemaPolicy.validatePartition(handle, part, format);
Review Comment:
Fixed in `a53925b495`. The shared Hive partition conversion now rejects
incompatible explicit storage formats before listing files. Tests cover
synchronous, batch and both streaming planning paths; the external regression
adds a real Parquet partition under an Avro table.
##########
fe/fe-connector/fe-connector-iceberg/src/main/java/org/apache/doris/connector/iceberg/IcebergScanPlanProvider.java:
##########
@@ -1352,12 +1353,13 @@ private IcebergScanRange
buildPositionDeleteRange(PositionDeletesScanTask task,
}
/**
- * PARQUET and PUFFIN both read through BE's parquet path; ORC through the
orc one. AVRO position-delete
- * files have no native reader — fail loud rather than mis-route. Message
text mirrors legacy exactly.
+ * PUFFIN deletion vectors travel through the Parquet path; ordinary
delete files retain their format.
*/
private static TFileFormatType
getNativePositionDeleteFileFormat(FileFormat fileFormat) {
if (fileFormat == FileFormat.PARQUET || fileFormat ==
FileFormat.PUFFIN) {
return TFileFormatType.FORMAT_PARQUET;
+ } else if (fileFormat == FileFormat.AVRO) {
+ return TFileFormatType.FORMAT_AVRO;
Review Comment:
Fixed in `a53925b495`. Position-delete metadata scans now apply the same
Avro range bound as ordinary data scans. Tasks with more than two stored
offsets stay whole because the SDK ignores its target size in that case. Tests
cover both target sizes and stored offsets, with a Parquet control.
##########
fe/fe-connector/fe-connector-hive/src/main/java/org/apache/doris/connector/hive/HiveAvroSchemaPolicy.java:
##########
@@ -0,0 +1,252 @@
+// 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.doris.connector.hive;
+
+import org.apache.doris.connector.hms.HmsPartitionInfo;
+import org.apache.doris.connector.spi.ConnectorColumn;
+import org.apache.doris.connector.spi.ConnectorType;
+import org.apache.doris.connector.spi.DorisConnectorException;
+
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonParseException;
+import com.google.gson.JsonParser;
+
+import java.util.List;
+import java.util.Objects;
+import java.util.Set;
+
+final class HiveAvroSchemaPolicy {
+ private static final String LITERAL = "avro.schema.literal";
+ private static final String URL = "avro.schema.url";
+ private static final Set<String> PRIMITIVES =
+ Set.of("null", "boolean", "int", "long", "float", "double",
"bytes", "string");
+
+ private HiveAvroSchemaPolicy() {
+ }
+
+ static void validate(HiveTableHandle handle, HiveFileFormat format) {
+ if (format != HiveFileFormat.AVRO) {
+ return;
+ }
+ if (handle.requiresAvroStringCoercion()) {
+ throw new DorisConnectorException("Native Hive Avro CHAR/VARCHAR
coercion is unsupported");
+ }
+ String literal = property(handle, LITERAL);
+ if (literal == null || "none".equals(literal)) {
+ String url = property(handle, URL);
+ if (url != null && !"none".equals(url)) {
+ throw unsupported();
+ }
+ return;
+ }
+ // Hive synthesizes nullable fields with explicit null defaults for
ordinary column DDL.
+ // Custom reader defaults/aliases require Avro schema resolution;
returning NULL instead
+ // of a declared default (for example 7) would silently change the
table's result.
+ if (literal.length() > 1024 * 1024 || !boundedJson(literal)) {
+ throw unsupported();
+ }
+ try {
+ JsonElement schema = JsonParser.parseString(literal);
+ if (!schema.isJsonObject() || !"record".equals(typeName(schema))
+ || !supported(schema, 0)) {
+ throw unsupported();
+ }
+ } catch (JsonParseException | IllegalStateException e) {
+ throw unsupported();
+ }
+ }
+
+ static void validatePartition(HiveTableHandle handle, HmsPartitionInfo
partition, HiveFileFormat format) {
+ if (format != HiveFileFormat.AVRO) {
+ return;
+ }
+ String literal = partitionProperty(partition, LITERAL);
+ String url = partitionProperty(partition, URL);
+ // Hive opens partition files using partition-local reader properties
before adapting
+ // records to the table schema. A table literal cannot hide a
partition URL. Even URL
+ // "none" is a non-null URL setting in this path, rather than the
literal's sentinel.
+ if ((literal == null || "none".equals(literal)) && url != null) {
+ throw unsupportedPartition();
+ }
+ literal = literal != null ? literal : property(handle, LITERAL);
+ String tableLiteral = readerSchema(handle);
+ literal = "none".equals(literal) ? null : literal;
+ // BE receives one reader schema for the whole scan. A different
partition schema could
+ // supply a default (e.g. 7) where the table schema would silently
materialize NULL.
+ if (!Objects.equals(literal, tableLiteral)) {
Review Comment:
Fixed in `a53925b495`. Bounded Jackson tree comparison now accepts
Hive-compatible whitespace, comments and object-key ordering while retaining
array order, defaults, logical annotations and integer/floating distinctions.
The original table reader literal still reaches BE unchanged. Tests cover
equivalent formatting through every planning entry and semantic differences
that must reject.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]