diqiu50 commented on code in PR #12121:
URL: https://github.com/apache/gravitino/pull/12121#discussion_r3654186684
##########
flink-connector/flink-common/src/main/java/org/apache/gravitino/flink/connector/paimon/GravitinoPaimonCatalog.java:
##########
@@ -129,43 +143,124 @@ public void open() throws CatalogException {
super.open();
return;
}
+ Map<String, String> paimonOptions = new HashMap<>(mutableOptions);
+ Configuration hadoopConf =
+
HadoopUtils.getHadoopConfiguration(Options.fromMap(withoutHadoopOptions(paimonOptions)));
+ moveHadoopOptionsToConf(paimonOptions, hadoopConf);
+ movePaimonStorageOptionsToConf(paimonOptions, hadoopConf);
try {
- CredentialPropertyUtils.applyPaimonCredentials(
- CredentialPropertyUtils.getCredentials(catalog()), mutableOptions);
+ applyCredentialsToCatalog(
+ CredentialPropertyUtils.getCredentials(catalog()), paimonOptions,
hadoopConf);
} catch (NoSuchCatalogException e) {
LOG.warn(
"Catalog '{}' not found in Gravitino during open(); credential
injection skipped."
+ " This is expected during CREATE CATALOG.",
getName(),
e);
}
- CatalogFactory.Context contextWithCredentials =
- new CatalogFactory.Context() {
- @Override
- public String getName() {
- return context.getName();
- }
-
- @Override
- public Map<String, String> getOptions() {
- return mutableOptions;
- }
-
- @Override
- public ReadableConfig getConfiguration() {
- return context.getConfiguration();
- }
-
- @Override
- public ClassLoader getClassLoader() {
- return context.getClassLoader();
- }
- };
- this.paimonCatalog =
- (AbstractCatalog) new
FlinkCatalogFactory().createCatalog(contextWithCredentials);
+ this.paimonCatalog = createInnerCatalog(paimonOptions, hadoopConf);
super.open();
}
+ /**
+ * Creates the inner Paimon Flink catalog from sanitized Paimon options and
Hadoop configuration.
+ *
+ * @param paimonOptions Paimon catalog options without Hadoop-prefixed
sensitive properties.
+ * @param hadoopConf Hadoop configuration carrying filesystem credentials
and Hadoop options.
+ * @return the created inner Paimon catalog.
+ */
+ @VisibleForTesting
+ protected AbstractCatalog createInnerCatalog(
+ Map<String, String> paimonOptions, Configuration hadoopConf) {
+ CatalogContext catalogContext =
+ CatalogContext.create(
+ Options.fromMap(paimonOptions), hadoopConf, new
FlinkFileIOLoader(), null);
+ return (AbstractCatalog)
Review Comment:
`new FlinkFileIOLoader()` should last parameter in the function
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]