You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@gravitino.apache.org by "Abyss-lord (via GitHub)" <gi...@apache.org> on 2025/01/09 03:01:59 UTC

[PR] [#6143] improve(CLI): Refactor catalog commands in Gavitino CLI [gravitino]

Abyss-lord opened a new pull request, #6159:
URL: https://github.com/apache/gravitino/pull/6159

   ### What changes were proposed in this pull request?
   
   1. Refactor catalog commands  and Base class in Gavitino CLI.
   2. Add test case.
   
   ### Why are the changes needed?
   
   Fix: #6143 
   
   ### Does this PR introduce _any_ user-facing change?
   
   No
   
   ### How was this patch tested?
   
   local test.


-- 
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: commits-unsubscribe@gravitino.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [#6143] improve(CLI): Refactor catalog commands in Gavitino CLI [gravitino]

Posted by "justinmclean (via GitHub)" <gi...@apache.org>.
justinmclean commented on code in PR #6159:
URL: https://github.com/apache/gravitino/pull/6159#discussion_r1908180149


##########
clients/cli/src/main/java/org/apache/gravitino/cli/CatalogCommandHandler.java:
##########
@@ -0,0 +1,224 @@
+/*
+ * 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.gravitino.cli;
+
+import com.google.common.collect.Lists;
+import java.util.List;
+import java.util.Map;
+import org.apache.commons.cli.CommandLine;
+import org.apache.gravitino.cli.commands.Command;
+
+/**
+ * Handles the command execution for Catalogs based on command type and the command line options.
+ */
+public class CatalogCommandHandler extends CommandHandler {
+
+  private final GravitinoCommandLine gravitinoCommandLine;
+  private final CommandLine line;
+  private final String command;
+  private final boolean ignore;
+  private final String url;
+  private final FullName name;
+  private final String metalake;
+  private final String catalog;
+  private final String outputFormat;
+
+  /**
+   * Constructs a {@link CatalogCommandHandler} instance.
+   *
+   * @param gravitinoCommandLine The Gravitino command line instance.
+   * @param line The command line arguments.
+   * @param command The command to execute.
+   * @param ignore Ignore server version mismatch.
+   */
+  public CatalogCommandHandler(
+      GravitinoCommandLine gravitinoCommandLine, CommandLine line, String command, boolean ignore) {
+    this.gravitinoCommandLine = gravitinoCommandLine;
+    this.line = line;
+    this.command = command;
+    this.ignore = ignore;
+
+    this.url = getUrl(line);
+    this.name = new FullName(line);
+    this.metalake = name.getMetalakeName();
+    this.catalog = name.getCatalogName();

Review Comment:
   I didn't do this on purpose in the metalake code as for example the list command didn't need a metalake. Here the list command doesn't need a catalog,



-- 
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: commits-unsubscribe@gravitino.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [#6143] improve(CLI): Refactor catalog commands in Gavitino CLI [gravitino]

Posted by "justinmclean (via GitHub)" <gi...@apache.org>.
justinmclean commented on code in PR #6159:
URL: https://github.com/apache/gravitino/pull/6159#discussion_r1908180149


##########
clients/cli/src/main/java/org/apache/gravitino/cli/CatalogCommandHandler.java:
##########
@@ -0,0 +1,224 @@
+/*
+ * 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.gravitino.cli;
+
+import com.google.common.collect.Lists;
+import java.util.List;
+import java.util.Map;
+import org.apache.commons.cli.CommandLine;
+import org.apache.gravitino.cli.commands.Command;
+
+/**
+ * Handles the command execution for Catalogs based on command type and the command line options.
+ */
+public class CatalogCommandHandler extends CommandHandler {
+
+  private final GravitinoCommandLine gravitinoCommandLine;
+  private final CommandLine line;
+  private final String command;
+  private final boolean ignore;
+  private final String url;
+  private final FullName name;
+  private final String metalake;
+  private final String catalog;
+  private final String outputFormat;
+
+  /**
+   * Constructs a {@link CatalogCommandHandler} instance.
+   *
+   * @param gravitinoCommandLine The Gravitino command line instance.
+   * @param line The command line arguments.
+   * @param command The command to execute.
+   * @param ignore Ignore server version mismatch.
+   */
+  public CatalogCommandHandler(
+      GravitinoCommandLine gravitinoCommandLine, CommandLine line, String command, boolean ignore) {
+    this.gravitinoCommandLine = gravitinoCommandLine;
+    this.line = line;
+    this.command = command;
+    this.ignore = ignore;
+
+    this.url = getUrl(line);
+    this.name = new FullName(line);
+    this.metalake = name.getMetalakeName();
+    this.catalog = name.getCatalogName();

Review Comment:
   I didn't do this on purpose in the metalake code as for example the list command didn't need a metalake. Here teh list command does't need a catalog,



##########
clients/cli/src/main/java/org/apache/gravitino/cli/CatalogCommandHandler.java:
##########
@@ -0,0 +1,224 @@
+/*
+ * 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.gravitino.cli;
+
+import com.google.common.collect.Lists;
+import java.util.List;
+import java.util.Map;
+import org.apache.commons.cli.CommandLine;
+import org.apache.gravitino.cli.commands.Command;
+
+/**
+ * Handles the command execution for Catalogs based on command type and the command line options.
+ */
+public class CatalogCommandHandler extends CommandHandler {
+
+  private final GravitinoCommandLine gravitinoCommandLine;
+  private final CommandLine line;
+  private final String command;
+  private final boolean ignore;
+  private final String url;
+  private final FullName name;
+  private final String metalake;
+  private final String catalog;
+  private final String outputFormat;
+
+  /**
+   * Constructs a {@link CatalogCommandHandler} instance.
+   *
+   * @param gravitinoCommandLine The Gravitino command line instance.
+   * @param line The command line arguments.
+   * @param command The command to execute.
+   * @param ignore Ignore server version mismatch.
+   */
+  public CatalogCommandHandler(
+      GravitinoCommandLine gravitinoCommandLine, CommandLine line, String command, boolean ignore) {
+    this.gravitinoCommandLine = gravitinoCommandLine;
+    this.line = line;
+    this.command = command;
+    this.ignore = ignore;
+
+    this.url = getUrl(line);
+    this.name = new FullName(line);
+    this.metalake = name.getMetalakeName();
+    this.catalog = name.getCatalogName();

Review Comment:
   I didn't do this on purpose in the metalake code as for example the list command didn't need a metalake. Here the list command does't need a catalog,



-- 
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: commits-unsubscribe@gravitino.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [#6143] improve(CLI): Refactor catalog commands in Gavitino CLI [gravitino]

Posted by "justinmclean (via GitHub)" <gi...@apache.org>.
justinmclean commented on code in PR #6159:
URL: https://github.com/apache/gravitino/pull/6159#discussion_r1908186218


##########
clients/cli/src/test/java/org/apache/gravitino/cli/TestCommandHandler.java:
##########


Review Comment:
   We already have tests for this code in GravitinoCommandLine. I don't think there is any need to use mocks for these simple methods.



-- 
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: commits-unsubscribe@gravitino.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [#6143] improve(CLI): Refactor catalog commands in Gavitino CLI [gravitino]

Posted by "Abyss-lord (via GitHub)" <gi...@apache.org>.
Abyss-lord commented on PR #6159:
URL: https://github.com/apache/gravitino/pull/6159#issuecomment-2579249431

   Hi @justinmclean ,  I’ve finished updating the code. Please take a look at the PR again when you have time.


-- 
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: commits-unsubscribe@gravitino.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [#6143] improve(CLI): Refactor catalog commands in Gavitino CLI [gravitino]

Posted by "Abyss-lord (via GitHub)" <gi...@apache.org>.
Abyss-lord commented on PR #6159:
URL: https://github.com/apache/gravitino/pull/6159#issuecomment-2579086452

   Hi @justinmclean @tengqm , could you please review this PR when you have time? I’d really appreciate your feedback.
   


-- 
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: commits-unsubscribe@gravitino.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [#6143] improve(CLI): Refactor catalog commands in Gavitino CLI [gravitino]

Posted by "justinmclean (via GitHub)" <gi...@apache.org>.
justinmclean merged PR #6159:
URL: https://github.com/apache/gravitino/pull/6159


-- 
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: commits-unsubscribe@gravitino.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org