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

[Hive] Fix Hive DDL and paimon schema mismatched bug #4561

Merged
merged 3 commits into from
Nov 22, 2024

Conversation

GangYang-HX
Copy link
Contributor

Purpose

Linked issue: issue-4556

HiveCatalog add column is divided into two stages: first modify the paimon schema, then modify HMS. There will be a time difference between the two stages. If there is a task read (based on hivecatalog) during this time, the paimon schema and hive schema check will fail in the getDataFieldsJsonStr link.

Solution: Actually, you only need to ensure that the Hive DDL is a subset of the paimon schema.

Tests

org.apache.paimon.hive.HiveTableSchemaTest#testSupersetColumnNameAndType
org.apache.paimon.hive.HiveTableSchemaTest#testSubsetColumnNameAndType

API and Format

org.apache.paimon.hive.HiveSchema#checkPartitionMatched

Documentation

only need to ensure that the Hive DDL is a subset of the paimon schema.

@@ -233,9 +233,10 @@ private static void checkFieldsMatched(
}
}

if (schemaFieldNames.size() != hiveFieldNames.size()) {
// It is OK that hive is a subset of paimon
if (schemaFieldNames.size() < hiveFieldNames.size()) {
Copy link
Contributor

@ChaomingZhangCN ChaomingZhangCN Nov 21, 2024

Choose a reason for hiding this comment

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

Checking by List#size() is not precise, Set#containsAll() maybe a better choice. :)

Copy link
Contributor

Choose a reason for hiding this comment

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

The following code will be checked one by one, I think it is OK

@JingsongLi
Copy link
Contributor

+1

@JingsongLi JingsongLi merged commit f0c3645 into apache:master Nov 22, 2024
12 checks passed
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.

3 participants