924060929 commented on code in PR #70808:
URL: https://github.com/apache/doris/pull/70808#discussion_r4675007486


##########
fe/fe-connector/fe-connector-hive/src/main/java/org/apache/doris/connector/hive/HiveScanPlanProvider.java:
##########
@@ -733,6 +737,14 @@ public Map<String, String> getScanNodeProperties(
             }
         }
 
+        if (fileFormat == HiveFileFormat.AVRO) {
+            String readerSchema = 
HiveAvroSchemaPolicy.readerSchema(hiveHandle);

Review Comment:
   [P1] A Hive partition can override `avro.schema.literal` in its SerDe 
properties. `ThriftHmsClient.convertPartition()` drops those properties, so 
this lookup uses the table schema for every split. I checked an old record 
missing `added`: Hive's effective partition schema resolved it to `7`, while 
the schema selected here resolved it to `NULL`. This also bypasses the intended 
rejection of custom defaults. Please retain the partition override and validate 
the effective schema when planning that partition. Rejecting a differing 
override would be sufficient for the current scope. A regression should query 
the old record through the affected partition.



##########
fe/fe-core/src/main/java/org/apache/doris/load/BrokerFileGroup.java:
##########
@@ -258,8 +256,11 @@ public void 
initDeferredFileFormatPropertiesIfNecessary(List<TBrokerFileStatus>
 
     public boolean isBinaryFileFormat() {
         // Must call initDeferredFileFormatPropertiesIfNecessary before
-        return fileFormatProperties instanceof ParquetFileFormatProperties
-                || fileFormatProperties instanceof OrcFileFormatProperties;
+        // Deferred properties retain their wrapper class after inferring the 
actual file format.
+        TFileFormatType formatType = fileFormatProperties.getFileFormatType();

Review Comment:
   [P2] Deferred format inference still takes `fileStatuses.get(0)` before the 
empty-file filter runs. With a zero-byte `_SUCCESS` followed by `part-0.avro`, 
I get `csv` and `isBinaryFileFormat() == false`. Reversing the two entries 
gives `avro` and `true`. A wildcard Broker Load or COPY can therefore send the 
same Avro data to the CSV reader depending on listing order. Please infer from 
the first non-empty data file when one exists and cover a leading extensionless 
marker in the tests.



##########
fe/fe-core/src/main/java/org/apache/doris/datasource/scan/FileQueryScanNode.java:
##########
@@ -556,6 +556,11 @@ protected long coarseSplitSizeForBeRefinement() {
 
     protected long selectFeSplitSizeForBe(long fallbackSize, TFileFormatType 
format, boolean supportsBeSplit) {
         long coarseSize = coarseSplitSizeForBeRefinement();
+        if (supportsBeSplit && coarseSize > 0 && format == 
TFileFormatType.FORMAT_AVRO) {
+            // Avro aligns byte ranges in its reader and has no BE 
physical-granule planner.
+            // Apply the final target in FE so coarse ranges do not reduce 
parallelism.
+            return sessionVariable.getFileSplitSizeOnBe();

Review Comment:
   [P2] This applies a 64 MiB default target to a reader that walks from the 
container header for every split. I exercised `seek_range` and `FileCursor` 
with a counting reader modeling 1 GiB of data in 64 KiB OCF blocks. Locating 
the 16 split starts alone requested 7.5 GiB across 7,680 `read_at` calls, 
before reading the assigned ranges. Remote traffic will depend on cache hits. 
Could we bound the number of splits per Avro file until readers can reuse block 
positions, and add a bytes-read check alongside the split-count test?



##########
fe/fe-connector/fe-connector-hive/src/main/java/org/apache/doris/connector/hive/HiveScanPlanProvider.java:
##########
@@ -733,6 +737,14 @@ public Map<String, String> getScanNodeProperties(
             }
         }
 
+        if (fileFormat == HiveFileFormat.AVRO) {
+            String readerSchema = 
HiveAvroSchemaPolicy.readerSchema(hiveHandle);
+            if (readerSchema != null) {
+                // The native reader must validate resolution before 
predicates or SQL casts run.
+                props.put(ScanNodePropertyKeys.LOCATION_PREFIX + 
"avro.schema.literal", readerSchema);

Review Comment:
   [P2] `LOCATION_PREFIX` puts the entire reader schema into 
`THdfsParams.hdfs_conf` for HDFS scans. `HdfsMgr::_hdfs_hash_code` hashes every 
config key and value, so two tables with different Avro literals get separate 
HDFS handlers even when they share the same NameNode, user and filesystem 
settings. Please carry the literal in a file-scan or format-specific field so 
the tables can reuse the same connection.



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

To unsubscribe, e-mail: [email protected]

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


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

Reply via email to