Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix](HMSExternalTable) refactor code to support mtmv on hudi #46466

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix 4
  • Loading branch information
BePPPower authored and morningman committed Jan 14, 2025
commit 2aab2fccb49481ea4bcc546d575d59da5f3e18ba
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,26 @@
import java.util.Optional;
import java.util.Set;

/**
* This abstract class represents a Hive Metastore (HMS) Dla Table and provides a blueprint for
* various operations related to metastore tables in Doris.
*
* Purpose:
* - To encapsulate common functionalities that HMS Dla tables should have for implementing other interfaces
*
* Why needed:
* - To provide a unified way to manage and interact with different kinds of Dla Table
* - To facilitate the implementation of multi-table materialized views (MTMV) by providing necessary
* methods for snapshot and partition management.
* - To abstract out the specific details of HMS table operations, making the code more modular and maintainable.
*/
public abstract class HMSDlaTable implements MTMVBaseTableIf {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add some comment for this class.
eg, why need this class, what's is purpose?

HMSExternalTable hmsTable;

public HMSDlaTable(HMSExternalTable table) {
this.hmsTable = table;
}


abstract Map<String, PartitionItem> getAndCopyPartitionItems(Optional<MvccSnapshot> snapshot)
throws AnalysisException;

Expand All @@ -57,10 +69,6 @@ abstract MTMVSnapshotIf getPartitionSnapshot(String partitionName, MTMVRefreshCo
abstract MTMVSnapshotIf getTableSnapshot(MTMVRefreshContext context, Optional<MvccSnapshot> snapshot)
throws AnalysisException;

public boolean needAutoRefresh() {
return true;
}

abstract boolean isPartitionColumnAllowNull();

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,9 @@ private LogicalPlan getLogicalPlan(TableIf table, UnboundRelation unboundRelatio
default:
throw new AnalysisException("Unsupported tableType " + table.getType());
}
} catch (Exception e) {
System.out.println(e);
return null;
} finally {
if (!isView) {
Optional<SqlCacheContext> sqlCacheContext = cascadesContext.getStatementContext().getSqlCacheContext();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import org.apache.doris.datasource.hive.HMSExternalDatabase;
import org.apache.doris.datasource.hive.HMSExternalTable;
import org.apache.doris.datasource.hive.HMSExternalTable.DLAType;
import org.apache.doris.datasource.hive.HiveDlaTable;
import org.apache.doris.datasource.hive.source.HiveScanNode;
import org.apache.doris.nereids.datasets.tpch.AnalyzeCheckTestBase;
import org.apache.doris.planner.OlapScanNode;
Expand Down Expand Up @@ -123,6 +124,7 @@ private void init(HMSExternalCatalog hmsCatalog) {
Deencapsulation.setField(tbl, "catalog", hmsCatalog);
Deencapsulation.setField(tbl, "dbName", "hms_db");
Deencapsulation.setField(tbl, "name", "hms_tbl");
Deencapsulation.setField(tbl, "dlaTable", new HiveDlaTable(tbl));
new Expectations(tbl) {
{
tbl.getId();
Expand Down Expand Up @@ -173,6 +175,7 @@ private void init(HMSExternalCatalog hmsCatalog) {
Deencapsulation.setField(tbl2, "catalog", hmsCatalog);
Deencapsulation.setField(tbl2, "dbName", "hms_db");
Deencapsulation.setField(tbl2, "name", "hms_tbl2");
Deencapsulation.setField(tbl2, "dlaTable", new HiveDlaTable(tbl2));
new Expectations(tbl2) {
{
tbl2.getId();
Expand Down Expand Up @@ -218,6 +221,7 @@ private void init(HMSExternalCatalog hmsCatalog) {
};

Deencapsulation.setField(view1, "objectCreated", true);
Deencapsulation.setField(view1, "dlaTable", new HiveDlaTable(view1));

new Expectations(view1) {
{
Expand Down Expand Up @@ -272,6 +276,7 @@ private void init(HMSExternalCatalog hmsCatalog) {
};

Deencapsulation.setField(view2, "objectCreated", true);
Deencapsulation.setField(view2, "dlaTable", new HiveDlaTable(view2));
new Expectations(view2) {
{
view2.getId();
Expand Down