JingsongLi commented on code in PR #1548:
URL: https://github.com/apache/incubator-paimon/pull/1548#discussion_r1267499242
##########
paimon-flink/paimon-flink-common/src/main/java/org/apache/paimon/flink/FlinkCatalog.java:
##########
@@ -237,21 +255,66 @@ public void createTable(ObjectPath tablePath,
CatalogBaseTable table, boolean ig
+ " You can create TEMPORARY table instead if you
want to create the table of other connector.");
}
+ Identifier identifier = toIdentifier(tablePath);
+ Map<String, String> logSystemOptions = registerLogSystem(identifier,
options);
// remove table path
String specific = options.remove(PATH.key());
- if (specific != null) {
+ if (specific != null || !logSystemOptions.isEmpty()) {
+ options.putAll(logSystemOptions);
catalogTable = catalogTable.copy(options);
}
+ boolean unRegisterLogSystem = false;
try {
catalog.createTable(
- toIdentifier(tablePath),
- FlinkCatalog.fromCatalogTable(catalogTable),
- ignoreIfExists);
+ identifier, FlinkCatalog.fromCatalogTable(catalogTable),
ignoreIfExists);
} catch (Catalog.TableAlreadyExistException e) {
+ unRegisterLogSystem = true;
throw new TableAlreadyExistException(getName(), tablePath);
} catch (Catalog.DatabaseNotExistException e) {
+ unRegisterLogSystem = true;
throw new DatabaseNotExistException(getName(), e.database());
+ } finally {
+ if (unRegisterLogSystem && !logSystemOptions.isEmpty()) {
+ unRegisterLogSystem(identifier, options);
+ }
+ }
+ }
+
+ private Map<String, String> registerLogSystem(
+ Identifier identifier, Map<String, String> options) {
+ Options tableOptions = Options.fromMap(options);
+ if (tableOptions.get(LOG_SYSTEM_AUTO_REGISTER)) {
+ String logStore = tableOptions.get(LOG_SYSTEM);
+ checkArgument(
+ !tableOptions.get(LOG_SYSTEM).equalsIgnoreCase(NONE),
+ String.format(
+ "%s must be configured when you use log system
register.",
+ LOG_SYSTEM.key()));
+ if (catalog.tableExists(identifier)) {
+ return Collections.emptyMap();
+ }
+ LogStoreTableFactory registerFactory =
+ FactoryUtil.discoverFactory(classLoader,
LogStoreTableFactory.class, logStore);
+ LogStoreRegister logStoreRegister =
registerFactory.createRegister(tableOptions);
Review Comment:
And this options is tableOptions? Not kafka options?
##########
paimon-flink/paimon-flink-common/src/main/java/org/apache/paimon/flink/FlinkCatalog.java:
##########
@@ -237,21 +255,66 @@ public void createTable(ObjectPath tablePath,
CatalogBaseTable table, boolean ig
+ " You can create TEMPORARY table instead if you
want to create the table of other connector.");
}
+ Identifier identifier = toIdentifier(tablePath);
+ Map<String, String> logSystemOptions = registerLogSystem(identifier,
options);
// remove table path
String specific = options.remove(PATH.key());
- if (specific != null) {
+ if (specific != null || !logSystemOptions.isEmpty()) {
+ options.putAll(logSystemOptions);
catalogTable = catalogTable.copy(options);
}
+ boolean unRegisterLogSystem = false;
try {
catalog.createTable(
- toIdentifier(tablePath),
- FlinkCatalog.fromCatalogTable(catalogTable),
- ignoreIfExists);
+ identifier, FlinkCatalog.fromCatalogTable(catalogTable),
ignoreIfExists);
} catch (Catalog.TableAlreadyExistException e) {
+ unRegisterLogSystem = true;
throw new TableAlreadyExistException(getName(), tablePath);
} catch (Catalog.DatabaseNotExistException e) {
+ unRegisterLogSystem = true;
throw new DatabaseNotExistException(getName(), e.database());
+ } finally {
+ if (unRegisterLogSystem && !logSystemOptions.isEmpty()) {
+ unRegisterLogSystem(identifier, options);
+ }
+ }
+ }
+
+ private Map<String, String> registerLogSystem(
+ Identifier identifier, Map<String, String> options) {
+ Options tableOptions = Options.fromMap(options);
+ if (tableOptions.get(LOG_SYSTEM_AUTO_REGISTER)) {
+ String logStore = tableOptions.get(LOG_SYSTEM);
+ checkArgument(
+ !tableOptions.get(LOG_SYSTEM).equalsIgnoreCase(NONE),
+ String.format(
+ "%s must be configured when you use log system
register.",
+ LOG_SYSTEM.key()));
+ if (catalog.tableExists(identifier)) {
+ return Collections.emptyMap();
+ }
+ LogStoreTableFactory registerFactory =
+ FactoryUtil.discoverFactory(classLoader,
LogStoreTableFactory.class, logStore);
+ LogStoreRegister logStoreRegister =
registerFactory.createRegister(tableOptions);
Review Comment:
And this options is tableOptions? Not log system options?
--
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]