jbonofre commented on code in PR #4075:
URL: https://github.com/apache/polaris/pull/4075#discussion_r3013412748


##########
site/content/in-dev/unreleased/command-line-interface.md:
##########
@@ -1571,6 +1577,113 @@ options:
 polaris setup export
 ```
 
+### Find
+
+The `find` command is used to searches for an identifier across global 
entities (principals, roles, catalogs)
+and catalog entities (namespaces, tables, views) using fuzzy matching.
+
+##### Examples
+
+```
+polaris find my_table
+polaris find ns1.ns2
+polaris find --catalog my_catalog my_table
+polaris find my_table --type table
+```
+
+### Tables
+
+The `tables` command is used to manage Iceberg tables within a Polaris Catalog.
+
+`tables` supports the following subcommands:
+
+1. list
+2. get
+3. summarize
+4. delete
+
+#### list
+
+The `list` subcommand is used to list tables within a namesace from a given 
catalog.
+
+```
+input: polaris tables list --help
+options:
+  list
+    Named arguments:
+      --catalog  The name of an existing catalog
+      --namespace  A period-delimited namespace
+```
+
+##### Examples
+
+```
+polaris tables list
+```
+
+#### get
+
+The `get` subcommand retrieves the table metadata for a specific table.
+
+```
+input: polaris tables get --help
+options:
+  get
+    Named arguments:
+      --catalog  The name of an existing catalog
+      --namespace  A period-delimited namespace
+    Positional arguments:
+      table
+```
+
+##### Examples
+
+```
+polaris tables get my_table --catalog my_catalog --namespace ns1
+```
+
+#### summarize
+
+The `summarize` subcommand provides a detail overview of a table.
+
+```
+input: polaris tables summarize --help
+options:
+  summarize
+    Named arguments:
+      --catalog  The name of an existing catalog
+      --namespace  A period-delimited namespace
+    Positional arguments:
+      table
+```
+
+##### Examples
+
+```
+polaris tables summarize my_table --catalog my_catalog --namespace ns1
+```
+
+#### delete
+
+The `delete` subcommand de-registers a table from catalog (metadata-only 
deletion).
+
+```
+input: polaris tables delete --help
+options:
+  delete
+    Named arguments:
+      --catalog  The name of an existing catalog
+      --namespace  A period-delimited namespace
+    Positional arguments:
+      table
+```
+
+##### Examples
+
+```
+polaris tables delete my_table --catalog my_catalog --namesapce ns1

Review Comment:
   typo: `namespace` instead of `namesapce`



##########
client/python/apache_polaris/cli/command/tables.py:
##########
@@ -0,0 +1,265 @@
+#
+# 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.
+#
+from dataclasses import dataclass
+from typing import List
+
+from apache_polaris.cli.command import Command
+from apache_polaris.cli.command.utils import get_catalog_api_client
+from apache_polaris.cli.constants import Subcommands, Arguments, UNIT_SEPARATOR
+from apache_polaris.cli.options.option_tree import Argument
+from apache_polaris.sdk.catalog import IcebergCatalogAPI
+from apache_polaris.sdk.management import PolarisDefaultApi
+from apache_polaris.sdk.catalog.api.policy_api import PolicyAPI
+from apache_polaris.cli.command.utils import (
+    handle_api_exception,
+    format_timestamp,
+    format_iceberg_type,
+)
+from prettytable import PrettyTable
+
+
+@dataclass
+class TableCommand(Command):
+    """
+    A Command implemtation to represent `polaris tables`. It manages Iceberg 
tables within a Polaris Catalog.
+
+    Example commands:
+        * ./polaris tables list --catalog my_catalog --namespace ns1
+        * ./polaris tables get my_table --catalog my_catalog --namespace ns1
+        * ./polaris tables summarize my_table --catalog my_catalog --namespace 
ns1
+        * ./polaris tables delete my_table --catalog my_catalog --namesapce ns1
+    """
+
+    table_subcommand: str
+    catalog_name: str
+    namespace: List[str]
+    table_name: str
+
+    def validate(self) -> None:
+        if not self.catalog_name:
+            raise Exception(
+                f"Missing required argument: 
{Argument.to_flag_name(Arguments.CATALOG)}"
+            )
+        if not self.namespace:
+            raise Exception(
+                f"Missing required argument: 
{Argument.to_flag_name(Arguments.NAMESPACE)}"
+            )
+        if (
+            self.table_subcommand == Subcommands.GET
+            or self.table_subcommand == Subcommands.SUMMARIZE
+            or self.table_subcommand == Subcommands.DELETE
+        ):
+            if not self.table_name.strip():
+                raise Exception("The table name cannot be empty.")
+
+    def execute(self, api: PolarisDefaultApi) -> None:
+        catalog_api = IcebergCatalogAPI(get_catalog_api_client(api))
+        ns_str = UNIT_SEPARATOR.join(self.namespace)
+        if self.table_subcommand == Subcommands.LIST:
+            try:
+                result = catalog_api.list_tables(
+                    prefix=self.catalog_name, namespace=ns_str
+                )
+                for table_identifier in result.identifiers:
+                    print(table_identifier.to_json())
+            except Exception as e:
+                handle_api_exception(f"Table Listing 
({'.'.join(self.namespace)})", e)
+        elif self.table_subcommand == Subcommands.GET:
+            try:
+                print(
+                    catalog_api.load_table(
+                        prefix=self.catalog_name,
+                        namespace=ns_str,
+                        table=self.table_name,
+                    ).to_json()
+                )
+            except Exception as e:
+                handle_api_exception(f"Table Load ({self.table_name})", e)
+        elif self.table_subcommand == Subcommands.DELETE:
+            print(
+                f"De-registering table 
{'.'.join(self.namespace)}.{self.table_name}..."
+            )
+            try:
+                catalog_api.drop_table(
+                    prefix=self.catalog_name,
+                    namespace=ns_str,
+                    table=self.table_name,
+                    purge_requested=False,
+                )
+            except Exception as e:
+                handle_api_exception(f"Table De-registration 
({self.table_name})", e)
+            print(

Review Comment:
   nit: I think this message is printed even if an `Exception` is raised 
(`handle_api_exception`).
   Maybe better to display completed only when no error.



-- 
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]

Reply via email to