Skip to content

[FLINK-29922] Support create external table for hive catalog #357

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

Merged
merged 9 commits into from
Nov 15, 2022

Conversation

wxplovecc
Copy link
Contributor

support hive catalog to create external table

Copy link
Contributor

@JingsongLi JingsongLi left a comment

Choose a reason for hiding this comment

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

Thanks wxplovecc for the contribution.

Can you add a test case for create external table?

@@ -49,6 +49,12 @@ private CatalogOptions() {}
.noDefaultValue()
.withDescription("Uri of metastore server.");

public static final ConfigOption<Boolean> HMS_EXTERNAL =
ConfigOptions.key("hms.external")
Copy link
Member

@SteNicholas SteNicholas Nov 8, 2022

Choose a reason for hiding this comment

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

@wxplovecc,could this introduce the TableType enum and table.type config option which default value is MANAGED_TABLE? In the CatalogOptions, the hms.external is specific for core module.
cc @JingsongLi

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@SteNicholas Thanks for review, updated

ConfigOptions.key("table.type")
.enumType(TableType.class)
.defaultValue(TableType.MANAGED_TABLE)
.withDescription("Table type of hms table, MANAGED_TABLE/EXTERNAL_TABLE.");
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
.withDescription("Table type of hms table, MANAGED_TABLE/EXTERNAL_TABLE.");
.withDescription("Type of table.");


package org.apache.flink.table.store.table;

/** TableType enum of catalog table. */
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
/** TableType enum of catalog table. */
/** Enum of catalog table type. */


/** Enum of catalog table type. */
public enum TableType {
MANAGED_TABLE,
Copy link
Contributor

@JingsongLi JingsongLi Nov 11, 2022

Choose a reason for hiding this comment

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

MANAGED and EXTERNAL is OK.
Can you let it implements DescribedEnum just like ChangelogProducer?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated

@@ -226,6 +227,13 @@ public void createTable(ObjectPath tablePath, UpdateSchema updateSchema, boolean
e);
}
Table table = newHmsTable(tablePath);

if (hiveConf.getEnum(TABLE_TYPE.key(), TableType.MANAGED_TABLE)
Copy link
Member

Choose a reason for hiding this comment

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

It's better to move this logic to newHmsTable which initialzes the Table and sets the parameters of the Table.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done


/** Enum of catalog table type. */
public enum TableType implements DescribedEnum {
MANAGED("MANAGED_TABLE", "Hive manage the lifecycle of the table."),
Copy link
Member

@SteNicholas SteNicholas Nov 14, 2022

Choose a reason for hiding this comment

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

Suggested change
MANAGED("MANAGED_TABLE", "Hive manage the lifecycle of the table."),
MANAGED("MANAGED_TABLE", "Table Store owned table where the entire lifecycle of the table data is managed."),

/** Enum of catalog table type. */
public enum TableType implements DescribedEnum {
MANAGED("MANAGED_TABLE", "Hive manage the lifecycle of the table."),
EXTERNAL("EXTERNAL_TABLE", "Files are already present or in remote locations.");
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
EXTERNAL("EXTERNAL_TABLE", "Files are already present or in remote locations.");
EXTERNAL("EXTERNAL_TABLE", "The table where Table Store has loose coupling with the data stored in external locations.");

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated @SteNicholas

Copy link
Member

@SteNicholas SteNicholas left a comment

Choose a reason for hiding this comment

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

LGTM.

Copy link
Contributor

@JingsongLi JingsongLi left a comment

Choose a reason for hiding this comment

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

Looks good to me!

@JingsongLi JingsongLi merged commit feffebd into apache:master Nov 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants