morrySnow commented on code in PR #36187:
URL: https://github.com/apache/doris/pull/36187#discussion_r1636150258


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/physical/PhysicalHudiScan.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.doris.nereids.trees.plans.physical;
+
+import org.apache.doris.analysis.TableScanParams;
+import org.apache.doris.analysis.TableSnapshot;
+import org.apache.doris.datasource.ExternalTable;
+import org.apache.doris.datasource.hudi.source.IncrementalRelation;
+import org.apache.doris.nereids.memo.GroupExpression;
+import org.apache.doris.nereids.properties.DistributionSpec;
+import org.apache.doris.nereids.properties.LogicalProperties;
+import org.apache.doris.nereids.properties.PhysicalProperties;
+import org.apache.doris.nereids.trees.TableSample;
+import org.apache.doris.nereids.trees.expressions.Expression;
+import org.apache.doris.nereids.trees.plans.Plan;
+import org.apache.doris.nereids.trees.plans.PlanType;
+import org.apache.doris.nereids.trees.plans.RelationId;
+import 
org.apache.doris.nereids.trees.plans.logical.LogicalFileScan.SelectedPartitions;
+import org.apache.doris.nereids.trees.plans.visitor.PlanVisitor;
+import org.apache.doris.statistics.Statistics;
+
+import java.util.List;
+import java.util.Optional;
+import java.util.Set;
+
+/**
+ * Physical Hudi scan for Hudi table.
+ */
+public class PhysicalHudiScan extends PhysicalFileScan {
+
+    // for hudi incremental read
+    private Optional<TableScanParams> scanParams;
+    private Optional<IncrementalRelation> incrementalRelation;

Review Comment:
   final



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/visitor/RelationVisitor.java:
##########
@@ -154,6 +160,10 @@ default R visitPhysicalFileScan(PhysicalFileScan fileScan, 
C context) {
         return visitPhysicalCatalogRelation(fileScan, context);
     }
 
+    default R visitPhysicalHudiScan(PhysicalHudiScan fileScan, C context) {

Review Comment:
   ```suggestion
       default R visitPhysicalHudiScan(PhysicalHudiScan hudiScan, C context) {
   ```



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/stats/StatsCalculator.java:
##########
@@ -465,6 +472,11 @@ public Statistics visitPhysicalFileScan(PhysicalFileScan 
fileScan, Void context)
         return computeCatalogRelation(fileScan);
     }
 
+    @Override
+    public Statistics visitPhysicalHudiScan(PhysicalHudiScan fileScan, Void 
context) {
+        return computeCatalogRelation(fileScan);
+    }

Review Comment:
   remove this code if it same with PhysicalFileScan



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/visitor/RelationVisitor.java:
##########
@@ -105,6 +107,10 @@ default R visitLogicalFileScan(LogicalFileScan fileScan, C 
context) {
         return visitLogicalExternalRelation(fileScan, context);
     }
 
+    default R visitLogicalHudiScan(LogicalHudiScan fileScan, C context) {
+        return visitLogicalExternalRelation(fileScan, context);

Review Comment:
   same as physcial visitor



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalHudiScan.java:
##########
@@ -0,0 +1,218 @@
+// 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.nereids.trees.plans.logical;
+
+import org.apache.doris.analysis.TableScanParams;
+import org.apache.doris.analysis.TableSnapshot;
+import org.apache.doris.datasource.ExternalTable;
+import org.apache.doris.datasource.hive.HMSExternalTable;
+import org.apache.doris.datasource.hive.HiveMetaStoreClientHelper;
+import org.apache.doris.datasource.hudi.source.COWIncrementalRelation;
+import org.apache.doris.datasource.hudi.source.IncrementalRelation;
+import org.apache.doris.datasource.hudi.source.MORIncrementalRelation;
+import org.apache.doris.nereids.exceptions.AnalysisException;
+import org.apache.doris.nereids.memo.GroupExpression;
+import org.apache.doris.nereids.properties.LogicalProperties;
+import org.apache.doris.nereids.trees.TableSample;
+import org.apache.doris.nereids.trees.expressions.ComparisonPredicate;
+import org.apache.doris.nereids.trees.expressions.Expression;
+import org.apache.doris.nereids.trees.expressions.GreaterThan;
+import org.apache.doris.nereids.trees.expressions.GreaterThanEqual;
+import org.apache.doris.nereids.trees.expressions.LessThanEqual;
+import org.apache.doris.nereids.trees.expressions.Slot;
+import org.apache.doris.nereids.trees.expressions.SlotReference;
+import org.apache.doris.nereids.trees.expressions.literal.StringLiteral;
+import org.apache.doris.nereids.trees.plans.Plan;
+import org.apache.doris.nereids.trees.plans.RelationId;
+import org.apache.doris.nereids.trees.plans.visitor.PlanVisitor;
+import org.apache.doris.nereids.util.Utils;
+
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Sets;
+import org.apache.hudi.common.table.HoodieTableMetaClient;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.Set;
+
+/**
+ * Logical Hudi scan for Hudi table
+ */
+public class LogicalHudiScan extends LogicalFileScan {
+    private static final Logger LOG = 
LogManager.getLogger(LogicalHudiScan.class);
+
+    // for hudi incremental read
+    private Optional<TableScanParams> scanParams;
+    private Optional<IncrementalRelation> incrementalRelation;

Review Comment:
   final



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/visitor/RelationVisitor.java:
##########
@@ -154,6 +160,10 @@ default R visitPhysicalFileScan(PhysicalFileScan fileScan, 
C context) {
         return visitPhysicalCatalogRelation(fileScan, context);
     }
 
+    default R visitPhysicalHudiScan(PhysicalHudiScan fileScan, C context) {
+        return visitPhysicalCatalogRelation(fileScan, context);

Review Comment:
   if it extends LogicalFileScan, it should
   `return visitPhysicalFileScan(fileScan, context);`



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/physical/PhysicalHudiScan.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.doris.nereids.trees.plans.physical;
+
+import org.apache.doris.analysis.TableScanParams;
+import org.apache.doris.analysis.TableSnapshot;
+import org.apache.doris.datasource.ExternalTable;
+import org.apache.doris.datasource.hudi.source.IncrementalRelation;
+import org.apache.doris.nereids.memo.GroupExpression;
+import org.apache.doris.nereids.properties.DistributionSpec;
+import org.apache.doris.nereids.properties.LogicalProperties;
+import org.apache.doris.nereids.properties.PhysicalProperties;
+import org.apache.doris.nereids.trees.TableSample;
+import org.apache.doris.nereids.trees.expressions.Expression;
+import org.apache.doris.nereids.trees.plans.Plan;
+import org.apache.doris.nereids.trees.plans.PlanType;
+import org.apache.doris.nereids.trees.plans.RelationId;
+import 
org.apache.doris.nereids.trees.plans.logical.LogicalFileScan.SelectedPartitions;
+import org.apache.doris.nereids.trees.plans.visitor.PlanVisitor;
+import org.apache.doris.statistics.Statistics;
+
+import java.util.List;
+import java.util.Optional;
+import java.util.Set;
+
+/**
+ * Physical Hudi scan for Hudi table.
+ */
+public class PhysicalHudiScan extends PhysicalFileScan {
+
+    // for hudi incremental read
+    private Optional<TableScanParams> scanParams;
+    private Optional<IncrementalRelation> incrementalRelation;
+
+    /**
+     * Constructor for PhysicalHudiScan.
+     */
+    public PhysicalHudiScan(RelationId id, ExternalTable table, List<String> 
qualifier,
+            DistributionSpec distributionSpec, Optional<GroupExpression> 
groupExpression,
+            LogicalProperties logicalProperties, Set<Expression> conjuncts,
+            SelectedPartitions selectedPartitions, Optional<TableSample> 
tableSample,
+            Optional<TableSnapshot> tableSnapshot,
+            Optional<TableScanParams> scanParams, 
Optional<IncrementalRelation> incrementalRelation) {
+        super(id, PlanType.PHYSICAL_HUDI_SCAN, table, qualifier, 
distributionSpec, groupExpression, logicalProperties,
+                conjuncts, selectedPartitions, tableSample, tableSnapshot);
+        this.scanParams = scanParams;
+        this.incrementalRelation = incrementalRelation;

Review Comment:
   check not null



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalHudiScan.java:
##########
@@ -0,0 +1,218 @@
+// 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.nereids.trees.plans.logical;
+
+import org.apache.doris.analysis.TableScanParams;
+import org.apache.doris.analysis.TableSnapshot;
+import org.apache.doris.datasource.ExternalTable;
+import org.apache.doris.datasource.hive.HMSExternalTable;
+import org.apache.doris.datasource.hive.HiveMetaStoreClientHelper;
+import org.apache.doris.datasource.hudi.source.COWIncrementalRelation;
+import org.apache.doris.datasource.hudi.source.IncrementalRelation;
+import org.apache.doris.datasource.hudi.source.MORIncrementalRelation;
+import org.apache.doris.nereids.exceptions.AnalysisException;
+import org.apache.doris.nereids.memo.GroupExpression;
+import org.apache.doris.nereids.properties.LogicalProperties;
+import org.apache.doris.nereids.trees.TableSample;
+import org.apache.doris.nereids.trees.expressions.ComparisonPredicate;
+import org.apache.doris.nereids.trees.expressions.Expression;
+import org.apache.doris.nereids.trees.expressions.GreaterThan;
+import org.apache.doris.nereids.trees.expressions.GreaterThanEqual;
+import org.apache.doris.nereids.trees.expressions.LessThanEqual;
+import org.apache.doris.nereids.trees.expressions.Slot;
+import org.apache.doris.nereids.trees.expressions.SlotReference;
+import org.apache.doris.nereids.trees.expressions.literal.StringLiteral;
+import org.apache.doris.nereids.trees.plans.Plan;
+import org.apache.doris.nereids.trees.plans.RelationId;
+import org.apache.doris.nereids.trees.plans.visitor.PlanVisitor;
+import org.apache.doris.nereids.util.Utils;
+
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Sets;
+import org.apache.hudi.common.table.HoodieTableMetaClient;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.Set;
+
+/**
+ * Logical Hudi scan for Hudi table
+ */
+public class LogicalHudiScan extends LogicalFileScan {
+    private static final Logger LOG = 
LogManager.getLogger(LogicalHudiScan.class);
+
+    // for hudi incremental read
+    private Optional<TableScanParams> scanParams;
+    private Optional<IncrementalRelation> incrementalRelation;
+
+    /**
+     * Constructor for LogicalHudiScan.
+     */
+    protected LogicalHudiScan(RelationId id, ExternalTable table, List<String> 
qualifier,
+            Optional<GroupExpression> groupExpression, 
Optional<LogicalProperties> logicalProperties,
+            Set<Expression> conjuncts, SelectedPartitions selectedPartitions, 
Optional<TableSample> tableSample,
+            Optional<TableSnapshot> tableSnapshot,
+            Optional<TableScanParams> scanParams, 
Optional<IncrementalRelation> incrementalRelation) {
+        super(id, table, qualifier, groupExpression, logicalProperties, 
conjuncts,
+                selectedPartitions, tableSample, tableSnapshot);
+        this.scanParams = scanParams;
+        this.incrementalRelation = incrementalRelation;
+    }
+
+    public LogicalHudiScan(RelationId id, ExternalTable table, List<String> 
qualifier,
+            Optional<TableSample> tableSample, Optional<TableSnapshot> 
tableSnapshot) {
+        this(id, table, qualifier, Optional.empty(), Optional.empty(),
+                Sets.newHashSet(), SelectedPartitions.NOT_PRUNED, tableSample, 
tableSnapshot,
+                Optional.empty(), Optional.empty());
+    }
+
+    /**
+     * Set scan params for incremental read
+     *
+     * @param table
+     * @param scanParams
+     */
+    public void setScanParams(HMSExternalTable table, TableScanParams 
scanParams) {

Review Comment:
   should not do set in Nereids, if u want to update some attr, u should impl 
withXXX and return a new object



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