rdblue commented on code in PR #5417:
URL: https://github.com/apache/iceberg/pull/5417#discussion_r941890556


##########
python/pyiceberg/cli/console.py:
##########
@@ -0,0 +1,228 @@
+# 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.
+import os
+from typing import Literal, Optional, Tuple
+
+import click
+
+from pyiceberg.catalog import Catalog
+from pyiceberg.catalog.hive import HiveCatalog
+from pyiceberg.catalog.rest import RestCatalog
+from pyiceberg.cli.output import ConsoleOutput, JsonOutput, Output
+from pyiceberg.exceptions import NoSuchNamespaceError, NoSuchTableError
+
+
[email protected]()
[email protected]("--catalog", default="catalog")
[email protected]("--output", type=click.Choice(["text", "json"]), default="text")
[email protected]("--uri", default=lambda: os.environ.get("PYICEBERG_URI"))
[email protected]("--credential", default=lambda: 
os.environ.get("PYICEBERG_CREDENTIAL"))
[email protected]_context
+def run(ctx, catalog: str, output: str, uri: str, credential: str):
+    ctx.ensure_object(dict)
+    if output == "text":
+        ctx.obj["output"] = ConsoleOutput()
+    elif output == "json":
+        ctx.obj["output"] = JsonOutput()
+    else:
+        raise ValueError(f"Unknown output: {output}")
+
+    if not uri:
+        ctx.obj["output"].exception(
+            f"Missing uri, cannot connect to catalog. Please provide using 
--uri or by setting the environment variable PYICEBERG_URI"
+        )

Review Comment:
   Probably want to exit here. Othewise, I get multiple errors:
   
   ```
   [blue@work python]$ poetry run pyiceberg properties taxi.nyc_taxi_yellow
   Missing uri, cannot connect to catalog. Please provide using --uri or by 
setting the environment variable PYICEBERG_URI
   Traceback (most recent call last):
     File "<string>", line 1, in <module>
     File 
"/home/blue/.cache/pypoetry/virtualenvs/pyiceberg-_q_E1N9K-py3.10/lib/python3.10/site-packages/click/core.py",
 line 1130, in __call__
       return self.main(*args, **kwargs)
     File 
"/home/blue/.cache/pypoetry/virtualenvs/pyiceberg-_q_E1N9K-py3.10/lib/python3.10/site-packages/click/core.py",
 line 1055, in main
       rv = self.invoke(ctx)
     File 
"/home/blue/.cache/pypoetry/virtualenvs/pyiceberg-_q_E1N9K-py3.10/lib/python3.10/site-packages/click/core.py",
 line 1654, in invoke
       super().invoke(ctx)
     File 
"/home/blue/.cache/pypoetry/virtualenvs/pyiceberg-_q_E1N9K-py3.10/lib/python3.10/site-packages/click/core.py",
 line 1404, in invoke
       return ctx.invoke(self.callback, **ctx.params)
     File 
"/home/blue/.cache/pypoetry/virtualenvs/pyiceberg-_q_E1N9K-py3.10/lib/python3.10/site-packages/click/core.py",
 line 760, in invoke
       return __callback(*args, **kwargs)
     File 
"/home/blue/.cache/pypoetry/virtualenvs/pyiceberg-_q_E1N9K-py3.10/lib/python3.10/site-packages/click/decorators.py",
 line 26, in new_func
       return f(get_current_context(), *args, **kwargs)
     File "/home/blue/workspace/iceberg/python/pyiceberg/cli/console.py", line 
49, in run
       if uri.startswith("http"):
   AttributeError: 'NoneType' object has no attribute 'startswith'
   ```



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

Reply via email to