jt2594838 commented on code in PR #17780:
URL: https://github.com/apache/iotdb/pull/17780#discussion_r3370523216
##########
iotdb-client/subscription/src/main/java/org/apache/iotdb/session/subscription/ISubscriptionTableSession.java:
##########
@@ -99,6 +99,49 @@ void createTopic(final String topicName, final Properties
properties)
void createTopicIfNotExists(final String topicName, final Properties
properties)
throws IoTDBConnectionException, StatementExecutionException;
+ /**
+ * Alters a topic with the specified properties.
+ *
+ * @param topicName If the topic name contains single quotes, the passed
parameter needs to be
+ * enclosed in backticks.
+ * @param properties A {@link Properties} object containing the topic
properties to alter.
+ * @throws IoTDBConnectionException If a connection issue occurs.
+ * @throws StatementExecutionException If the SQL statement execution fails.
+ */
+ void alterTopic(final String topicName, final Properties properties)
+ throws IoTDBConnectionException, StatementExecutionException;
Review Comment:
Is the TopicOwner allowed to be modified by this interface?
Or can it only be modified through `alterTopicOwner`?
##########
iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ProcedureManager.java:
##########
@@ -1733,6 +1736,35 @@ public TSStatus createTopic(TCreateTopicReq req) {
}
}
+ public TSStatus alterTopic(TAlterTopicReq req) {
+ try {
+ final TopicMeta updatedTopicMeta =
+ configManager
+ .getSubscriptionManager()
+ .getSubscriptionCoordinator()
+ .buildAlteredTopicMeta(req);
+ if (updatedTopicMeta == null) {
+ return new TSStatus(TSStatusCode.ALTER_TOPIC_ERROR.getStatusCode())
+ .setMessage(
+ String.format(
+ "Failed to alter topic %s, the topic is not existed",
req.getTopicName()));
+ }
Review Comment:
i18n
##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/parser/ASTVisitor.java:
##########
@@ -4425,6 +4426,23 @@ public Statement
visitCreateTopic(IoTDBSqlParser.CreateTopicContext ctx) {
return createTopicStatement;
}
+ @Override
+ public Statement visitAlterTopic(IoTDBSqlParser.AlterTopicContext ctx) {
+ final AlterTopicStatement alterTopicStatement = new AlterTopicStatement();
+
+ if (ctx.topicName != null) {
+
alterTopicStatement.setTopicName(parseIdentifier(ctx.topicName.getText()));
+ } else {
+ throw new SemanticException(
+ "Not support for this sql in ALTER TOPIC, please enter topicName.");
+ }
Review Comment:
i18n
##########
iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/subscription/SubscriptionCoordinator.java:
##########
@@ -149,6 +151,25 @@ public TSStatus createTopic(TCreateTopicReq req) {
return status;
}
+ public TSStatus alterTopic(TAlterTopicReq req) {
+ final TSStatus status =
configManager.getProcedureManager().alterTopic(req);
+ if (status.getCode() != TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
+ LOGGER.warn(
+ "Failed to alter topic {} with attributes {}, result status is {}.",
+ req.getTopicName(),
+ req.getTopicAttributes(),
+ status);
+ }
+ return status;
+ }
+
+ public TopicMeta buildAlteredTopicMeta(TAlterTopicReq req) {
+ final TopicMeta existedTopicMeta =
subscriptionInfo.deepCopyTopicMeta(req.getTopicName());
+ return existedTopicMeta == null
+ ? null
+ :
existedTopicMeta.deepCopyWithUpdatedAttributes(req.getTopicAttributes());
+ }
Review Comment:
Why deep copy twice?
--
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]