kevinjqliu commented on code in PR #3934: URL: https://github.com/apache/iceberg-python/pull/3934#discussion_r3992776520
########## pyiceberg/cli/console.py: ########## @@ -142,38 +143,61 @@ def list(ctx: Context, parent: str | None) -> None: # pylint: disable=redefined @run.command() [email protected]("--entity", type=click.Choice(["any", "namespace", "table"]), default="any") [email protected]( + "--entity", + type=click.Choice(["any", "namespace", "table"]), + default="any", + help="Entity type. 'any' auto-detects and requires --entity when ambiguous.", +) @click.argument("identifier") @click.pass_context @catch_exception() -def describe(ctx: Context, entity: Literal["name", "namespace", "table"], identifier: str) -> None: +def describe(ctx: Context, entity: Literal["any", "namespace", "table"], identifier: str) -> None: """Describe a namespace or a table.""" catalog, output = _catalog_and_output(ctx) identifier_tuple = Catalog.identifier_to_tuple(identifier) - is_namespace = False - if entity in {"namespace", "any"} and len(identifier_tuple) > 0: - try: - namespace_properties = catalog.load_namespace_properties(identifier_tuple) - output.describe_properties(namespace_properties) - is_namespace = True - except NoSuchNamespaceError as exc: - if entity != "any" or len(identifier_tuple) == 1: # type: ignore - raise exc - - is_table = False - if entity in {"table", "any"} and len(identifier_tuple) > 1: - try: - catalog_table = catalog.load_table(identifier) - output.describe_table(catalog_table) - is_table = True - except NoSuchTableError as exc: - if entity != "any": - raise exc - - if is_namespace is False and is_table is False: + if entity == "namespace": Review Comment: i actually did this intentionally. these ifs are for the individual checks namespace / table / and view (in #3926) starting L167 is the "any" fallback behavior. i can add a inline comment for that to be more explicit -- 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] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
