chl-wxp commented on code in PR #10657:
URL: https://github.com/apache/seatunnel/pull/10657#discussion_r2999680926
##########
seatunnel-api/src/main/java/org/apache/seatunnel/api/metadata/MetaDataProviderManager.java:
##########
@@ -108,20 +106,32 @@ public static Config resolveDataSourceConfigs(
return ConfigFactory.parseMap(resultMap);
}
+ public static Optional<TableSchema> resolveTableSchema(
+ String metaDataTableId, MetaDataConfig dataSourceConfig) {
+ if (dataSourceConfig == null || !dataSourceConfig.isEnabled()) {
+ return Optional.empty();
+ }
+ MetaDataProvider provider =
+ getOrCreateProvider(
+ dataSourceConfig.getKind(),
+
ConfigFactory.parseMap(dataSourceConfig.getProperties()));
+ return provider.tableSchema(metaDataTableId);
+ }
+
/**
* Gets or creates an initialized DataSourceProvider instance with lazy
loading caching.
*
* @param kind the provider kind (e.g., "gravitino", "datahub")
* @param config the configuration for the provider
* @return initialized DataSourceProvider instance
*/
- private static DataSourceProvider getOrCreateProvider(String kind, Config
config) {
- DataSourceProvider provider = cachedProvider;
+ private static MetaDataProvider getOrCreateProvider(String kind, Config
config) {
Review Comment:
> I think this cache may be unnecessary and adds avoidable complexity.
Creating and initializing the provider on demand seems simpler and safer here
When we submit the configuration file to the server or local, it is okay to
close the MetaDataProvider instance when it is used up. However, when
submitting the job in restApi mode, the server is processing the
MetaDataProvider. If there is no cache, a new MetaDataProvider instance will be
created every time restApi is submitted, which is unreasonable.
--
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]