You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by "sashapolo (via GitHub)" <gi...@apache.org> on 2024/01/10 14:59:28 UTC
[PR] IGNITE-21215 Add Catalog API for renaming a table [ignite-3]
sashapolo opened a new pull request, #3029:
URL: https://github.com/apache/ignite-3/pull/3029
https://issues.apache.org/jira/browse/IGNITE-21215
Thank you for submitting the pull request.
To streamline the review process of the patch and ensure better code quality
we ask both an author and a reviewer to verify the following:
### The Review Checklist
- [ ] **Formal criteria:** TC status, codestyle, mandatory documentation. Also make sure to complete the following:
\- There is a single JIRA ticket related to the pull request.
\- The web-link to the pull request is attached to the JIRA ticket.
\- The JIRA ticket has the Patch Available state.
\- The description of the JIRA ticket explains WHAT was made, WHY and HOW.
\- The pull request title is treated as the final commit message. The following pattern must be used: IGNITE-XXXX Change summary where XXXX - number of JIRA issue.
- [ ] **Design:** new code conforms with the design principles of the components it is added to.
- [ ] **Patch quality:** patch cannot be split into smaller pieces, its size must be reasonable.
- [ ] **Code quality:** code is clean and readable, necessary developer documentation is added if needed.
- [ ] **Tests code quality:** test set covers positive/negative scenarios, happy/edge cases. Tests are effective in terms of execution time and resources.
### Notes
- [Apache Ignite Coding Guidelines](https://cwiki.apache.org/confluence/display/IGNITE/Java+Code+Style+Guide)
--
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-21215 Add Catalog API for renaming a table [ignite-3]
Posted by "sashapolo (via GitHub)" <gi...@apache.org>.
sashapolo commented on code in PR #3029:
URL: https://github.com/apache/ignite-3/pull/3029#discussion_r1448702033
##########
modules/catalog/src/test/java/org/apache/ignite/internal/catalog/CatalogManagerSelfTest.java:
##########
@@ -2067,6 +2070,71 @@ void testGetIndexesForTableInSortedOrderById() {
assertThat(tableIndexIds(catalogVersion, tableId(TABLE_NAME)), equalTo(List.of(indexId0, indexId1, indexId2)));
}
+ @Test
+ void testTableRename() {
+ createSomeTable(TABLE_NAME);
+
+ int prevVersion = manager.latestCatalogVersion();
+
+ int tableId = manager.tables(prevVersion).iterator().next().id();
+
+ CatalogCommand command = RenameTableCommand.builder()
+ .schemaName(SCHEMA_NAME)
+ .tableName(TABLE_NAME)
+ .newTableName(TABLE_NAME_2)
+ .build();
+
+ CompletableFuture<Void> renameFuture = manager.execute(command);
Review Comment:
fixed
##########
modules/catalog/src/test/java/org/apache/ignite/internal/catalog/CatalogManagerSelfTest.java:
##########
@@ -2067,6 +2070,71 @@ void testGetIndexesForTableInSortedOrderById() {
assertThat(tableIndexIds(catalogVersion, tableId(TABLE_NAME)), equalTo(List.of(indexId0, indexId1, indexId2)));
}
+ @Test
+ void testTableRename() {
+ createSomeTable(TABLE_NAME);
+
+ int prevVersion = manager.latestCatalogVersion();
+
+ int tableId = manager.tables(prevVersion).iterator().next().id();
+
+ CatalogCommand command = RenameTableCommand.builder()
+ .schemaName(SCHEMA_NAME)
+ .tableName(TABLE_NAME)
+ .newTableName(TABLE_NAME_2)
+ .build();
+
+ CompletableFuture<Void> renameFuture = manager.execute(command);
+
+ assertThat(renameFuture, willCompleteSuccessfully());
+
+ int curVersion = manager.latestCatalogVersion();
+
+ CatalogTableDescriptor prevDescriptor = manager.table(tableId, prevVersion);
+ CatalogTableDescriptor curDescriptor = manager.table(tableId, curVersion);
+
+ assertThat(prevDescriptor, is(notNullValue()));
+ assertThat(prevDescriptor.name(), is(TABLE_NAME));
+
+ assertThat(curDescriptor, is(notNullValue()));
+ assertThat(curDescriptor.name(), is(TABLE_NAME_2));
+
+ assertThat(curDescriptor.tableVersion(), is(prevDescriptor.tableVersion() + 1));
Review Comment:
fixed
--
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-21215 Add Catalog API for renaming a table [ignite-3]
Posted by "sashapolo (via GitHub)" <gi...@apache.org>.
sashapolo commented on code in PR #3029:
URL: https://github.com/apache/ignite-3/pull/3029#discussion_r1449006527
##########
modules/catalog/src/main/java/org/apache/ignite/internal/catalog/commands/RenameTableCommand.java:
##########
@@ -0,0 +1,97 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.catalog.commands;
+
+import static org.apache.ignite.internal.catalog.CatalogParamsValidationUtils.ensureNoTableIndexOrSysViewExistsWithGivenName;
+import static org.apache.ignite.internal.catalog.CatalogParamsValidationUtils.validateIdentifier;
+import static org.apache.ignite.internal.catalog.commands.CatalogUtils.schemaOrThrow;
+import static org.apache.ignite.internal.catalog.commands.CatalogUtils.tableOrThrow;
+
+import java.util.List;
+import org.apache.ignite.internal.catalog.Catalog;
+import org.apache.ignite.internal.catalog.CatalogCommand;
+import org.apache.ignite.internal.catalog.CatalogValidationException;
+import org.apache.ignite.internal.catalog.descriptors.CatalogSchemaDescriptor;
+import org.apache.ignite.internal.catalog.descriptors.CatalogTableDescriptor;
+import org.apache.ignite.internal.catalog.storage.RenameTableEntry;
+import org.apache.ignite.internal.catalog.storage.UpdateEntry;
+
+/**
+ * A command that changes the name of a table.
+ */
+public class RenameTableCommand extends AbstractTableCommand {
Review Comment:
Done
##########
modules/catalog/src/main/java/org/apache/ignite/internal/catalog/commands/RenameTableCommandBuilder.java:
##########
@@ -0,0 +1,23 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.catalog.commands;
+
+/** Builder for {@link RenameTableCommand}s. */
+public interface RenameTableCommandBuilder extends AbstractTableCommandBuilder<RenameTableCommandBuilder> {
+ RenameTableCommandBuilder newTableName(String newTableName);
Review Comment:
Done
--
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-21215 Add Catalog API for renaming a table [ignite-3]
Posted by "rpuch (via GitHub)" <gi...@apache.org>.
rpuch commented on code in PR #3029:
URL: https://github.com/apache/ignite-3/pull/3029#discussion_r1448649481
##########
modules/catalog/src/test/java/org/apache/ignite/internal/catalog/CatalogManagerSelfTest.java:
##########
@@ -2067,6 +2070,71 @@ void testGetIndexesForTableInSortedOrderById() {
assertThat(tableIndexIds(catalogVersion, tableId(TABLE_NAME)), equalTo(List.of(indexId0, indexId1, indexId2)));
}
+ @Test
+ void testTableRename() {
+ createSomeTable(TABLE_NAME);
+
+ int prevVersion = manager.latestCatalogVersion();
+
+ int tableId = manager.tables(prevVersion).iterator().next().id();
+
+ CatalogCommand command = RenameTableCommand.builder()
+ .schemaName(SCHEMA_NAME)
+ .tableName(TABLE_NAME)
+ .newTableName(TABLE_NAME_2)
+ .build();
+
+ CompletableFuture<Void> renameFuture = manager.execute(command);
Review Comment:
Do we need this variable? Could it be just inlined?
##########
modules/catalog/src/test/java/org/apache/ignite/internal/catalog/CatalogManagerSelfTest.java:
##########
@@ -2067,6 +2070,71 @@ void testGetIndexesForTableInSortedOrderById() {
assertThat(tableIndexIds(catalogVersion, tableId(TABLE_NAME)), equalTo(List.of(indexId0, indexId1, indexId2)));
}
+ @Test
+ void testTableRename() {
+ createSomeTable(TABLE_NAME);
+
+ int prevVersion = manager.latestCatalogVersion();
+
+ int tableId = manager.tables(prevVersion).iterator().next().id();
+
+ CatalogCommand command = RenameTableCommand.builder()
+ .schemaName(SCHEMA_NAME)
+ .tableName(TABLE_NAME)
+ .newTableName(TABLE_NAME_2)
+ .build();
+
+ CompletableFuture<Void> renameFuture = manager.execute(command);
+
+ assertThat(renameFuture, willCompleteSuccessfully());
+
+ int curVersion = manager.latestCatalogVersion();
+
+ CatalogTableDescriptor prevDescriptor = manager.table(tableId, prevVersion);
+ CatalogTableDescriptor curDescriptor = manager.table(tableId, curVersion);
+
+ assertThat(prevDescriptor, is(notNullValue()));
+ assertThat(prevDescriptor.name(), is(TABLE_NAME));
+
+ assertThat(curDescriptor, is(notNullValue()));
+ assertThat(curDescriptor.name(), is(TABLE_NAME_2));
+
+ assertThat(curDescriptor.tableVersion(), is(prevDescriptor.tableVersion() + 1));
Review Comment:
How about also making sure that column definitions have not changed?
--
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-21215 Add Catalog API for renaming a table [ignite-3]
Posted by "korlov42 (via GitHub)" <gi...@apache.org>.
korlov42 commented on code in PR #3029:
URL: https://github.com/apache/ignite-3/pull/3029#discussion_r1448897357
##########
modules/catalog/src/main/java/org/apache/ignite/internal/catalog/commands/RenameTableCommand.java:
##########
@@ -0,0 +1,97 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.catalog.commands;
+
+import static org.apache.ignite.internal.catalog.CatalogParamsValidationUtils.ensureNoTableIndexOrSysViewExistsWithGivenName;
+import static org.apache.ignite.internal.catalog.CatalogParamsValidationUtils.validateIdentifier;
+import static org.apache.ignite.internal.catalog.commands.CatalogUtils.schemaOrThrow;
+import static org.apache.ignite.internal.catalog.commands.CatalogUtils.tableOrThrow;
+
+import java.util.List;
+import org.apache.ignite.internal.catalog.Catalog;
+import org.apache.ignite.internal.catalog.CatalogCommand;
+import org.apache.ignite.internal.catalog.CatalogValidationException;
+import org.apache.ignite.internal.catalog.descriptors.CatalogSchemaDescriptor;
+import org.apache.ignite.internal.catalog.descriptors.CatalogTableDescriptor;
+import org.apache.ignite.internal.catalog.storage.RenameTableEntry;
+import org.apache.ignite.internal.catalog.storage.UpdateEntry;
+
+/**
+ * A command that changes the name of a table.
+ */
+public class RenameTableCommand extends AbstractTableCommand {
Review Comment:
every command has its own validation test class (see descendants of `org.apache.ignite.internal.catalog.commands.AbstractCommandValidationTest`). Please add validation test to the new command as well
##########
modules/catalog/src/main/java/org/apache/ignite/internal/catalog/commands/RenameTableCommandBuilder.java:
##########
@@ -0,0 +1,23 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.catalog.commands;
+
+/** Builder for {@link RenameTableCommand}s. */
+public interface RenameTableCommandBuilder extends AbstractTableCommandBuilder<RenameTableCommandBuilder> {
+ RenameTableCommandBuilder newTableName(String newTableName);
Review Comment:
it would be nice to have meaningful javadoc for `newTableName` parameter (it worth to mention validation restrictions)
--
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-21215 Add Catalog API for renaming a table [ignite-3]
Posted by "sashapolo (via GitHub)" <gi...@apache.org>.
sashapolo merged PR #3029:
URL: https://github.com/apache/ignite-3/pull/3029
--
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org