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

[HUDI-7213] When using wrong tabe.type value in hudi catalog happends npe #10300

Merged
merged 8 commits into from
Dec 21, 2023

Conversation

LXin96
Copy link
Contributor

@LXin96 LXin96 commented Dec 11, 2023

Change Logs

when using wrong table.type in hudi catalog, then the VALUE_MAPPING.get() will return null and throw npe, as detail in jira
maybe we need to tell user the wrong key

Impact

Describe any public API or user-facing feature change or any performance impact.

Risk level (write none, low medium or high below)

If medium or high, explain what verification was done to mitigate the risks.

Documentation Update

Describe any necessary documentation update if there is any new feature, config, or user-facing change

  • The config description must be updated if new configs are added or the default value of the configs are changed
  • Any new feature or user-facing change requires updating the Hudi website. Please create a Jira ticket, attach the
    ticket number here and follow the instruction to make
    changes to the website.

Contributor's checklist

  • Read through contributor's guide
  • Change Logs and Impact were stated clearly
  • Adequate tests were added if applicable
  • CI passed

String sparkTableType = VALUE_MAPPING.get(e.getValue());
if (sparkTableType == null) {
throw new HoodieValidationException(String.format("%s's value is invalid", e.getKey()));
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice catch, can you write a UT in TestHoodieCatalog ?

@LXin96
Copy link
Contributor Author

LXin96 commented Dec 14, 2023

@danny0405 hello, i have added a ut in TestHoodieHiveCatalog,as the npe appears in translateFlinkTableProperties2Spark

try {
hoodieCatalog.createTable(tablePath, table, false);
} catch (HoodieValidationException e) {
assertEquals("table.type's value is invalid", e.getMessage());
Copy link
Contributor

Choose a reason for hiding this comment

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

This patch fixes the hoodie catalog instead of hoodie hive catalog right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this patch fix the hoodie hive catalog, when using hudi hive catalog ,using create if not exists table , the code will go to org.apache.hudi.table.catalog.HoodieHiveCatalog#createTable | org.apache.hudi.table.catalog.HoodieHiveCatalog#instantiateHiveTable| org.apache.hudi.table.catalog.TableOptionProperties#translateFlinkTableProperties2Spark
and in this method if the table.type is wrong it will throw npe

Copy link
Contributor

Choose a reason for hiding this comment

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

Can we use assertThrows instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

no problem

@@ -477,6 +478,8 @@ public void createTable(ObjectPath tablePath, CatalogBaseTable table, boolean ig
if (!ignoreIfExists) {
throw new TableAlreadyExistException(getName(), tablePath, e);
}
} catch (HoodieValidationException e) {
throw e;
} catch (Exception e) {
throw new HoodieCatalogException(
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't any exception been caught by the Exception ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@danny0405 yes, but I throws a HoodieValidationException, maybe i need to fix ut to assert throw a HoodieCatalogException

Copy link
Contributor

Choose a reason for hiding this comment

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

maybe i need to fix ut to assert throw a HoodieCatalogException

You should.

@hudi-bot
Copy link

CI report:

Bot commands @hudi-bot supports the following commands:
  • @hudi-bot run azure re-run the last Azure build

@danny0405 danny0405 merged commit 9ac06ec into apache:master Dec 21, 2023
29 of 31 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