You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by "lexluo09 (via GitHub)" <gi...@apache.org> on 2023/05/21 16:00:41 UTC

[GitHub] [doris] lexluo09 opened a new pull request, #19909: [Enhancement](multi catalog) Support hudi mor java side

lexluo09 opened a new pull request, #19909:
URL: https://github.com/apache/doris/pull/19909

   # Proposed changes
   
   Issue Number: close #18432
   
   ## Problem summary
   
   Support reading Hudi MOR table by using jni connector
   
   ## Checklist(Required)
   
   * [ ] Does it affect the original behavior
   * [ ] Has unit tests been added
   * [ ] Has document been added or modified
   * [ ] Does it need to update dependencies
   * [ ] Is this PR support rollback (If NO, please explain WHY)
   
   ## Further comments
   
   If this is a relatively large or complex change, kick off the discussion at [dev@doris.apache.org](mailto:dev@doris.apache.org) by explaining why you chose the solution you did and what alternatives you considered, etc...
   
   


-- 
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@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] AshinGau commented on pull request #19909: [Enhancement](multi catalog) Support hudi mor java side

Posted by "AshinGau (via GitHub)" <gi...@apache.org>.
AshinGau commented on PR #19909:
URL: https://github.com/apache/doris/pull/19909#issuecomment-1556925875

   Cloud you please add in the description that the FE part of the current PR is completed, and the BE part will be supplemented in next PR.


-- 
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@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] morningman merged pull request #19909: [Enhancement](hudi) Support hudi mor only java side ,be side not support

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


-- 
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@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] github-actions[bot] commented on pull request #19909: [Enhancement](multi catalog) Support hudi mor java side

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #19909:
URL: https://github.com/apache/doris/pull/19909#issuecomment-1557273174

   clang-tidy review says "All clean, LGTM! :+1:"


-- 
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@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] morningman commented on pull request #19909: [Enhancement](multi catalog) Support hudi mor only java side ,be side not support

Posted by "morningman (via GitHub)" <gi...@apache.org>.
morningman commented on PR #19909:
URL: https://github.com/apache/doris/pull/19909#issuecomment-1560590927

   run buildall


-- 
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@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] hello-stephen commented on pull request #19909: [Enhancement](hudi) Support hudi mor only java side ,be side not support

Posted by "hello-stephen (via GitHub)" <gi...@apache.org>.
hello-stephen commented on PR #19909:
URL: https://github.com/apache/doris/pull/19909#issuecomment-1560747587

   TeamCity pipeline, clickbench performance test result:
    the sum of best hot time: 34.91 seconds
    stream load tsv:          420 seconds loaded 74807831229 Bytes, about 169 MB/s
    stream load json:         23 seconds loaded 2358488459 Bytes, about 97 MB/s
    stream load orc:          59 seconds loaded 1101869774 Bytes, about 17 MB/s
    stream load parquet:          30 seconds loaded 861443392 Bytes, about 27 MB/s
    insert into select:          78.0 seconds inserted 10000000 Rows, about 128K ops/s
    https://doris-community-test-1308700295.cos.ap-hongkong.myqcloud.com/tmp/20230524091604_clickbench_pr_149641.html


-- 
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@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] github-actions[bot] commented on pull request #19909: [Enhancement](multi catalog) Support hudi mor java side

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #19909:
URL: https://github.com/apache/doris/pull/19909#issuecomment-1557392496

   clang-tidy review says "All clean, LGTM! :+1:"


-- 
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@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] github-actions[bot] commented on pull request #19909: [Enhancement](multi catalog) Support hudi mor java side

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #19909:
URL: https://github.com/apache/doris/pull/19909#issuecomment-1556214632

   clang-tidy review says "All clean, LGTM! :+1:"


-- 
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@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] DongLiang-0 commented on pull request #19909: [Enhancement](hudi) Support hudi mor only java side ,be side not support

Posted by "DongLiang-0 (via GitHub)" <gi...@apache.org>.
DongLiang-0 commented on PR #19909:
URL: https://github.com/apache/doris/pull/19909#issuecomment-1562514340

   LGTM


-- 
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@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] AshinGau commented on a diff in pull request #19909: [Enhancement](multi catalog) Support hudi mor java side

Posted by "AshinGau (via GitHub)" <gi...@apache.org>.
AshinGau commented on code in PR #19909:
URL: https://github.com/apache/doris/pull/19909#discussion_r1200253792


##########
fe/fe-core/src/main/java/org/apache/doris/catalog/external/HudiExternalTable.java:
##########
@@ -0,0 +1,125 @@
+// 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.catalog.external;
+
+import org.apache.doris.catalog.Column;
+import org.apache.doris.catalog.Type;
+import org.apache.doris.datasource.hudi.HudiHMSExternalCatalog;
+import org.apache.doris.thrift.THudiTable;
+import org.apache.doris.thrift.TTableDescriptor;
+import org.apache.doris.thrift.TTableType;
+
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Lists;
+import org.apache.avro.Schema;
+import org.apache.hadoop.hive.metastore.api.FieldSchema;
+import org.apache.hadoop.hive.metastore.api.Table;
+import org.apache.hudi.common.table.HoodieTableConfig;
+import org.apache.hudi.common.util.Option;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.stream.Collectors;
+
+public class HudiExternalTable extends ExternalTable {
+
+    public HudiExternalTable(long id, String name, String dbName, HudiHMSExternalCatalog catalog) {
+        super(id, name, catalog, dbName, TableType.HUDI_EXTERNAL_TABLE);
+    }
+
+    public String getHudiCatalogType() {
+        return ((HudiHMSExternalCatalog) catalog).getHudiCatalogType();
+    }
+
+    protected synchronized void makeSureInitialized() {
+        super.makeSureInitialized();
+        if (!objectCreated) {
+            objectCreated = true;
+        }
+    }
+
+    @Override
+    public TTableDescriptor toThrift() {
+        List<Column> schema = getFullSchema();
+        String hudiCatalogType = getHudiCatalogType();
+        if (hudiCatalogType.equals("hms")) {
+            THudiTable hudiTable = new THudiTable();
+            hudiTable.setDbName(dbName);
+            hudiTable.setTableName(dbName);
+
+            TTableDescriptor tTableDescriptor = new TTableDescriptor(getId(), TTableType.HIVE_TABLE, schema.size(), 0,
+                    getName(), dbName);
+            tTableDescriptor.setHudiTable(hudiTable);
+            return tTableDescriptor;
+        }
+        throw new UnsupportedOperationException("hudi not supported  the catalog type :" + hudiCatalogType);
+    }
+
+    public static String fromAvroHudiTypeToHiveTypeString(Schema avroSchema) {
+        Schema.Type columnType = avroSchema.getType();
+        switch (columnType) {

Review Comment:
   How about `decimal` and `timestamp` ... types?



##########
fe/fe-core/src/main/java/org/apache/doris/catalog/external/HudiExternalDatabase.java:
##########
@@ -0,0 +1,72 @@
+// 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.catalog.external;
+
+import org.apache.doris.catalog.TableIf;
+import org.apache.doris.datasource.ExternalCatalog;
+import org.apache.doris.datasource.InitDatabaseLog;
+import org.apache.doris.datasource.hudi.HudiHMSExternalCatalog;
+import org.apache.doris.persist.gson.GsonPostProcessable;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+import java.util.Comparator;
+import java.util.List;
+import java.util.stream.Collectors;
+
+public class HudiExternalDatabase extends ExternalDatabase<HudiExternalTable> implements GsonPostProcessable {

Review Comment:
   We should register the subtype of `DatabaseIf` in `org.apache.doris.persist.gson.GsonUtils`



##########
fe/fe-core/src/main/java/org/apache/doris/planner/external/hudi/HudiScanNode.java:
##########
@@ -0,0 +1,231 @@
+// 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.planner.external.hudi;
+
+import org.apache.doris.analysis.TupleDescriptor;
+import org.apache.doris.catalog.HiveMetaStoreClientHelper;
+import org.apache.doris.catalog.external.ExternalTable;
+import org.apache.doris.catalog.external.HMSExternalTable;
+import org.apache.doris.catalog.external.HudiExternalTable;
+import org.apache.doris.common.AnalysisException;
+import org.apache.doris.common.UserException;
+import org.apache.doris.planner.PlanNodeId;
+import org.apache.doris.planner.external.HiveScanNode;
+import org.apache.doris.planner.external.TableFormatType;
+import org.apache.doris.spi.Split;
+import org.apache.doris.statistics.StatisticalType;
+import org.apache.doris.thrift.TFileFormatType;
+import org.apache.doris.thrift.TFileRangeDesc;
+import org.apache.doris.thrift.THudiFileDesc;
+import org.apache.doris.thrift.TTableFormatFileDesc;
+
+import avro.shaded.com.google.common.base.Preconditions;
+import org.apache.avro.Schema;
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.hadoop.fs.FileStatus;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.hive.metastore.api.FieldSchema;
+import org.apache.hudi.avro.HoodieAvroUtils;
+import org.apache.hudi.common.fs.FSUtils;
+import org.apache.hudi.common.model.BaseFile;
+import org.apache.hudi.common.model.FileSlice;
+import org.apache.hudi.common.model.HoodieBaseFile;
+import org.apache.hudi.common.model.HoodieLogFile;
+import org.apache.hudi.common.table.HoodieTableMetaClient;
+import org.apache.hudi.common.table.TableSchemaResolver;
+import org.apache.hudi.common.table.timeline.HoodieInstant;
+import org.apache.hudi.common.table.timeline.HoodieTimeline;
+import org.apache.hudi.common.table.view.HoodieTableFileSystemView;
+import org.apache.hudi.common.util.Option;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+import java.util.Optional;
+import java.util.stream.Collectors;
+
+public class HudiScanNode extends HiveScanNode {
+
+    private static final Logger LOG = LogManager.getLogger(HudiScanNode.class);
+
+    private HudiSource source;
+
+    // table location -> HoodieTableMetaClient
+
+    /**
+     * External file scan node for Query Hudi table
+     * needCheckColumnPriv: Some of ExternalFileScanNode do not need to check column priv
+     * eg: s3 tvf
+     * These scan nodes do not have corresponding catalog/database/table info, so no need to do priv check
+     */
+    public HudiScanNode(PlanNodeId id, TupleDescriptor desc, boolean needCheckColumnPriv) {
+        super(id, desc, "HUDI_SCAN_NODE", StatisticalType.HUDI_SCAN_NODE, needCheckColumnPriv);
+    }
+
+    @Override
+    public TFileFormatType getFileFormatType() {
+        return TFileFormatType.FORMAT_PARQUET;
+    }
+
+    @Override
+    public List<String> getPathPartitionKeys() {
+        return Collections.emptyList();
+    }
+
+
+    @Override
+    protected void doInitialize() throws UserException {
+        ExternalTable table = (ExternalTable) desc.getTable();
+        if (table.isView()) {
+            throw new AnalysisException(
+                    String.format("Querying external view '%s.%s' is not supported", table.getDbName(),
+                            table.getName()));
+        }
+        computeColumnFilter();
+        initBackendPolicy();
+        if (table instanceof HMSExternalTable) {
+            source = new HudiHMSSource((HMSExternalTable) table, desc, columnNameToRange);
+        }
+        Preconditions.checkNotNull(source);
+        initSchemaParams();
+    }
+
+
+    public static void setHudiParams(TFileRangeDesc rangeDesc, HudiSplit hudiSplit) {
+        TTableFormatFileDesc tableFormatFileDesc = new TTableFormatFileDesc();
+        tableFormatFileDesc.setTableFormatType(hudiSplit.getTableFormatType().value());
+        THudiFileDesc fileDesc = new THudiFileDesc();
+        fileDesc.setBasePath(hudiSplit.getBasePath());
+        fileDesc.setDataFilePath(hudiSplit.getDataFilePath());
+        fileDesc.setDeltaFilePaths(hudiSplit.getHudiDeltaLogs());
+        tableFormatFileDesc.setHudiParams(fileDesc);
+        rangeDesc.setTableFormatParams(tableFormatFileDesc);
+    }
+
+    @Override
+    public List<Split> getSplits() throws UserException {
+        // TODO expressions
+        // List<Expression> expressions = new ArrayList<>();
+
+        // for (Expr conjunct : conjuncts) {
+        //     Expression expression = null;
+        //     if (expression != null) {
+        //         expressions.add(expression);
+        //     }
+        // }
+
+        HMSExternalTable targetTable = (HMSExternalTable) source.getTargetTable();
+        HoodieTableMetaClient hudiClient = HiveMetaStoreClientHelper.getHudiClient(targetTable);
+
+        hudiClient.reloadActiveTimeline();
+
+        String partitionName = getHudiPartitionName(targetTable, hudiClient);
+
+        List<Split> splits = new ArrayList<>();
+
+        String basePath = targetTable.getRemoteTable().getSd().getLocation();
+        String inputFormat = targetTable.getRemoteTable().getSd().getInputFormat();
+        String serdeLib = targetTable.getRemoteTable().getSd().getSerdeInfo().getSerializationLib();
+
+        TableSchemaResolver schemaUtil = new TableSchemaResolver(hudiClient);
+        Schema hudiSchema;
+        try {
+            hudiSchema = HoodieAvroUtils.createHoodieWriteSchema(schemaUtil.getTableAvroSchema());
+        } catch (Exception e) {
+            throw new RuntimeException("Cannot get hudi table schema.");
+        }
+
+        List<String> columnNames = new ArrayList<>();
+        List<String> columnTypes = new ArrayList<>();
+        List<FieldSchema> allFields = targetTable.getRemoteTable().getSd().getCols();
+        allFields.addAll(targetTable.getRemoteTable().getPartitionKeys());
+
+        for (Schema.Field hudiField : hudiSchema.getFields()) {
+
+            String columnName = hudiField.name().toLowerCase(Locale.ROOT);
+            Optional<FieldSchema> field = allFields.stream()
+                    .filter(f -> f.getName().equals(columnName)).findFirst();
+            if (!field.isPresent()) {
+                String errorMsg = String.format("Hudi column %s not exists in hive metastore.", hudiField.name());

Review Comment:
   How is this situation caused? Can the [synchronization tools](https://hudi.apache.org/docs/syncing_metastore#hive-sync-tool) maintain strong consistency in the table schema of the hive schema?



##########
fe/fe-core/src/main/java/org/apache/doris/datasource/InternalCatalog.java:
##########
@@ -2431,14 +2432,17 @@ private void createHudiTable(Database db, CreateTableStmt stmt) throws DdlExcept
         HiveConf hiveConf = new HiveConf();
         hiveConf.set(HMSProperties.HIVE_METASTORE_URIS,
                 hudiTable.getTableProperties().get(HudiProperty.HUDI_HIVE_METASTORE_URIS));
+

Review Comment:
   Many unexpected changes.



##########
fe/fe-core/src/main/java/org/apache/doris/planner/external/hudi/HudiScanNode.java:
##########
@@ -0,0 +1,231 @@
+// 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.planner.external.hudi;
+
+import org.apache.doris.analysis.TupleDescriptor;
+import org.apache.doris.catalog.HiveMetaStoreClientHelper;
+import org.apache.doris.catalog.external.ExternalTable;
+import org.apache.doris.catalog.external.HMSExternalTable;
+import org.apache.doris.catalog.external.HudiExternalTable;
+import org.apache.doris.common.AnalysisException;
+import org.apache.doris.common.UserException;
+import org.apache.doris.planner.PlanNodeId;
+import org.apache.doris.planner.external.HiveScanNode;
+import org.apache.doris.planner.external.TableFormatType;
+import org.apache.doris.spi.Split;
+import org.apache.doris.statistics.StatisticalType;
+import org.apache.doris.thrift.TFileFormatType;
+import org.apache.doris.thrift.TFileRangeDesc;
+import org.apache.doris.thrift.THudiFileDesc;
+import org.apache.doris.thrift.TTableFormatFileDesc;
+
+import avro.shaded.com.google.common.base.Preconditions;
+import org.apache.avro.Schema;
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.hadoop.fs.FileStatus;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.hive.metastore.api.FieldSchema;
+import org.apache.hudi.avro.HoodieAvroUtils;
+import org.apache.hudi.common.fs.FSUtils;
+import org.apache.hudi.common.model.BaseFile;
+import org.apache.hudi.common.model.FileSlice;
+import org.apache.hudi.common.model.HoodieBaseFile;
+import org.apache.hudi.common.model.HoodieLogFile;
+import org.apache.hudi.common.table.HoodieTableMetaClient;
+import org.apache.hudi.common.table.TableSchemaResolver;
+import org.apache.hudi.common.table.timeline.HoodieInstant;
+import org.apache.hudi.common.table.timeline.HoodieTimeline;
+import org.apache.hudi.common.table.view.HoodieTableFileSystemView;
+import org.apache.hudi.common.util.Option;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+import java.util.Optional;
+import java.util.stream.Collectors;
+
+public class HudiScanNode extends HiveScanNode {
+
+    private static final Logger LOG = LogManager.getLogger(HudiScanNode.class);
+
+    private HudiSource source;
+
+    // table location -> HoodieTableMetaClient
+
+    /**
+     * External file scan node for Query Hudi table
+     * needCheckColumnPriv: Some of ExternalFileScanNode do not need to check column priv
+     * eg: s3 tvf
+     * These scan nodes do not have corresponding catalog/database/table info, so no need to do priv check
+     */
+    public HudiScanNode(PlanNodeId id, TupleDescriptor desc, boolean needCheckColumnPriv) {
+        super(id, desc, "HUDI_SCAN_NODE", StatisticalType.HUDI_SCAN_NODE, needCheckColumnPriv);
+    }
+
+    @Override
+    public TFileFormatType getFileFormatType() {
+        return TFileFormatType.FORMAT_PARQUET;
+    }
+
+    @Override
+    public List<String> getPathPartitionKeys() {
+        return Collections.emptyList();
+    }
+
+
+    @Override
+    protected void doInitialize() throws UserException {
+        ExternalTable table = (ExternalTable) desc.getTable();
+        if (table.isView()) {
+            throw new AnalysisException(
+                    String.format("Querying external view '%s.%s' is not supported", table.getDbName(),
+                            table.getName()));
+        }
+        computeColumnFilter();
+        initBackendPolicy();
+        if (table instanceof HMSExternalTable) {
+            source = new HudiHMSSource((HMSExternalTable) table, desc, columnNameToRange);
+        }
+        Preconditions.checkNotNull(source);
+        initSchemaParams();
+    }
+
+
+    public static void setHudiParams(TFileRangeDesc rangeDesc, HudiSplit hudiSplit) {
+        TTableFormatFileDesc tableFormatFileDesc = new TTableFormatFileDesc();
+        tableFormatFileDesc.setTableFormatType(hudiSplit.getTableFormatType().value());
+        THudiFileDesc fileDesc = new THudiFileDesc();
+        fileDesc.setBasePath(hudiSplit.getBasePath());
+        fileDesc.setDataFilePath(hudiSplit.getDataFilePath());
+        fileDesc.setDeltaFilePaths(hudiSplit.getHudiDeltaLogs());
+        tableFormatFileDesc.setHudiParams(fileDesc);
+        rangeDesc.setTableFormatParams(tableFormatFileDesc);
+    }
+
+    @Override
+    public List<Split> getSplits() throws UserException {
+        // TODO expressions
+        // List<Expression> expressions = new ArrayList<>();
+
+        // for (Expr conjunct : conjuncts) {
+        //     Expression expression = null;
+        //     if (expression != null) {
+        //         expressions.add(expression);
+        //     }
+        // }
+
+        HMSExternalTable targetTable = (HMSExternalTable) source.getTargetTable();
+        HoodieTableMetaClient hudiClient = HiveMetaStoreClientHelper.getHudiClient(targetTable);
+
+        hudiClient.reloadActiveTimeline();
+
+        String partitionName = getHudiPartitionName(targetTable, hudiClient);
+
+        List<Split> splits = new ArrayList<>();
+
+        String basePath = targetTable.getRemoteTable().getSd().getLocation();
+        String inputFormat = targetTable.getRemoteTable().getSd().getInputFormat();
+        String serdeLib = targetTable.getRemoteTable().getSd().getSerdeInfo().getSerializationLib();
+
+        TableSchemaResolver schemaUtil = new TableSchemaResolver(hudiClient);
+        Schema hudiSchema;
+        try {
+            hudiSchema = HoodieAvroUtils.createHoodieWriteSchema(schemaUtil.getTableAvroSchema());
+        } catch (Exception e) {
+            throw new RuntimeException("Cannot get hudi table schema.");
+        }
+
+        List<String> columnNames = new ArrayList<>();
+        List<String> columnTypes = new ArrayList<>();
+        List<FieldSchema> allFields = targetTable.getRemoteTable().getSd().getCols();
+        allFields.addAll(targetTable.getRemoteTable().getPartitionKeys());
+
+        for (Schema.Field hudiField : hudiSchema.getFields()) {
+
+            String columnName = hudiField.name().toLowerCase(Locale.ROOT);
+            Optional<FieldSchema> field = allFields.stream()
+                    .filter(f -> f.getName().equals(columnName)).findFirst();
+            if (!field.isPresent()) {
+                String errorMsg = String.format("Hudi column %s not exists in hive metastore.", hudiField.name());
+                throw new IllegalArgumentException(errorMsg);
+            }
+            columnNames.add(columnName);
+            String columnType = HudiExternalTable.fromAvroHudiTypeToHiveTypeString(hudiField.schema());
+            columnTypes.add(columnType);
+        }
+
+        try {
+            String globPath = String.format("%s/%s/*", hudiClient.getBasePath(), partitionName);
+            List<FileStatus> statuses = FSUtils.getGlobStatusExcludingMetaFolder(hudiClient.getRawFs(),
+                    new Path(globPath));
+
+            HoodieTimeline timeline = hudiClient.getCommitsAndCompactionTimeline().filterCompletedInstants();
+            Option<HoodieInstant> latestInstant = timeline.lastInstant();

Review Comment:
   So currently only support MOR from the last snapshots. Can we reserve interfaces to support `Time Travel Query` and `Incremental query`.



-- 
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@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] AshinGau commented on pull request #19909: [Enhancement](multi catalog) Support hudi mor only java side ,be side not support

Posted by "AshinGau (via GitHub)" <gi...@apache.org>.
AshinGau commented on PR #19909:
URL: https://github.com/apache/doris/pull/19909#issuecomment-1560563429

   LGTM


-- 
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@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org