You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by "iting0321 (via GitHub)" <gi...@apache.org> on 2025/03/22 09:07:14 UTC

[PR] Fix CLI command order and catalog not found error [iceberg-python]

iting0321 opened a new pull request, #1828:
URL: https://github.com/apache/iceberg-python/pull/1828

   Closes #1784 
   
   # Rationale for this change
   The command order for `pyiceberg list --catalog hive` would raise error; it should be `pyiceberg --catalog hive list`. 
   Now, `pyiceberg list --catalog hive` will return the same result as `pyiceberg --catalog hive list`.
   
   Additionally, for cases where the catalog is not found:  
   For example, if the default catalog is not set and the command `pyiceberg list` is executed, it will raise an error stating:  
   `Default catalog not found. Please provide a catalog type using --type.`  
   
   # Are these changes tested?
   The tests `test_no_catalog_error` and `test_list_with_catalog_option_wrong_order` in `tests/cli/test_console.py` cover these scenarios.  
   Additionally, I fixed `test_missing_uri`. When a catalog exists but the URI is missing, it will now return an appropriate 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: issues-unsubscribe@iceberg.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Fix CLI command order and catalog not found error [iceberg-python]

Posted by "jason810496 (via GitHub)" <gi...@apache.org>.
jason810496 commented on code in PR #1828:
URL: https://github.com/apache/iceberg-python/pull/1828#discussion_r2008722220


##########
pyiceberg/cli/console.py:
##########
@@ -86,31 +91,48 @@ def run(
         ctx.obj["output"] = JsonOutput(verbose=verbose)
 
     try:
-        ctx.obj["catalog"] = load_catalog(catalog, **properties)
+        ctx.obj["first_level_catalog"] = catalog
+        ctx.obj["second_level_catalog"] = None
+        ctx.obj["properties"] = properties
+        
     except Exception as e:
         ctx.obj["output"].exception(e)
         ctx.exit(1)
 
+
+def _load_the_catalog_with_first_level_catalog(ctx: Context) -> None:
+    if ctx.obj["first_level_catalog"] is None and ctx.obj["second_level_catalog"] is None:
+        ctx.obj["catalog"] = load_catalog(None, **ctx.obj["properties"])
+    elif ctx.obj["first_level_catalog"] is not None and ctx.obj["second_level_catalog"] is None:
+        ctx.obj["catalog"] = load_catalog(ctx.obj["first_level_catalog"],**ctx.obj["properties"])
+    else:
+        ctx.obj["catalog"] = load_catalog(ctx.obj["second_level_catalog"],**ctx.obj["properties"])
+        print("cataloglll",ctx.obj["catalog"]) 

Review Comment:
   Nit: The forgot removed `print`
   ```suggestion
   ```



-- 
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: issues-unsubscribe@iceberg.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Fix CLI command order and catalog not found error [iceberg-python]

Posted by "jason810496 (via GitHub)" <gi...@apache.org>.
jason810496 commented on code in PR #1828:
URL: https://github.com/apache/iceberg-python/pull/1828#discussion_r2008722936


##########
pyiceberg/cli/console.py:
##########
@@ -86,31 +91,48 @@ def run(
         ctx.obj["output"] = JsonOutput(verbose=verbose)
 
     try:
-        ctx.obj["catalog"] = load_catalog(catalog, **properties)
+        ctx.obj["first_level_catalog"] = catalog
+        ctx.obj["second_level_catalog"] = None
+        ctx.obj["properties"] = properties
+        
     except Exception as e:
         ctx.obj["output"].exception(e)
         ctx.exit(1)
 
+
+def _load_the_catalog_with_first_level_catalog(ctx: Context) -> None:
+    if ctx.obj["first_level_catalog"] is None and ctx.obj["second_level_catalog"] is None:
+        ctx.obj["catalog"] = load_catalog(None, **ctx.obj["properties"])
+    elif ctx.obj["first_level_catalog"] is not None and ctx.obj["second_level_catalog"] is None:
+        ctx.obj["catalog"] = load_catalog(ctx.obj["first_level_catalog"],**ctx.obj["properties"])
+    else:
+        ctx.obj["catalog"] = load_catalog(ctx.obj["second_level_catalog"],**ctx.obj["properties"])

Review Comment:
   We can refactor as:
   ```suggestion
       catalog_option = ctx.obj.get("first_level_catalog",None) or ctx.obj.get("second_level_catalog",None)
       ctx.obj["catalog"] = load_catalog(catalog_option,**ctx.obj["properties"])
   ```



-- 
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: issues-unsubscribe@iceberg.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Fix CLI command order and catalog not found error [iceberg-python]

Posted by "jason810496 (via GitHub)" <gi...@apache.org>.
jason810496 commented on code in PR #1828:
URL: https://github.com/apache/iceberg-python/pull/1828#discussion_r2008723316


##########
pyiceberg/cli/console.py:
##########
@@ -86,31 +91,48 @@ def run(
         ctx.obj["output"] = JsonOutput(verbose=verbose)
 
     try:
-        ctx.obj["catalog"] = load_catalog(catalog, **properties)
+        ctx.obj["first_level_catalog"] = catalog
+        ctx.obj["second_level_catalog"] = None
+        ctx.obj["properties"] = properties
+        
     except Exception as e:
         ctx.obj["output"].exception(e)
         ctx.exit(1)
 
+
+def _load_the_catalog_with_first_level_catalog(ctx: Context) -> None:
+    if ctx.obj["first_level_catalog"] is None and ctx.obj["second_level_catalog"] is None:
+        ctx.obj["catalog"] = load_catalog(None, **ctx.obj["properties"])
+    elif ctx.obj["first_level_catalog"] is not None and ctx.obj["second_level_catalog"] is None:
+        ctx.obj["catalog"] = load_catalog(ctx.obj["first_level_catalog"],**ctx.obj["properties"])
+    else:
+        ctx.obj["catalog"] = load_catalog(ctx.obj["second_level_catalog"],**ctx.obj["properties"])
+        print("cataloglll",ctx.obj["catalog"]) 
+
+
     if not isinstance(ctx.obj["catalog"], Catalog):
         ctx.obj["output"].exception(
-            ValueError("Could not determine catalog type from uri. REST (http/https) and Hive (thrift) is supported")
+        ValueError("Could not determine catalog type from uri. REST (http/https) and Hive (thrift) is supported")

Review Comment:
   Nit: indent
   ```suggestion
               ValueError("Could not determine catalog type from uri. REST (http/https) and Hive (thrift) is supported")
   ```



-- 
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: issues-unsubscribe@iceberg.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Fix CLI command order and catalog not found error [iceberg-python]

Posted by "jason810496 (via GitHub)" <gi...@apache.org>.
jason810496 commented on code in PR #1828:
URL: https://github.com/apache/iceberg-python/pull/1828#discussion_r2008723316


##########
pyiceberg/cli/console.py:
##########
@@ -86,31 +91,48 @@ def run(
         ctx.obj["output"] = JsonOutput(verbose=verbose)
 
     try:
-        ctx.obj["catalog"] = load_catalog(catalog, **properties)
+        ctx.obj["first_level_catalog"] = catalog
+        ctx.obj["second_level_catalog"] = None
+        ctx.obj["properties"] = properties
+        
     except Exception as e:
         ctx.obj["output"].exception(e)
         ctx.exit(1)
 
+
+def _load_the_catalog_with_first_level_catalog(ctx: Context) -> None:
+    if ctx.obj["first_level_catalog"] is None and ctx.obj["second_level_catalog"] is None:
+        ctx.obj["catalog"] = load_catalog(None, **ctx.obj["properties"])
+    elif ctx.obj["first_level_catalog"] is not None and ctx.obj["second_level_catalog"] is None:
+        ctx.obj["catalog"] = load_catalog(ctx.obj["first_level_catalog"],**ctx.obj["properties"])
+    else:
+        ctx.obj["catalog"] = load_catalog(ctx.obj["second_level_catalog"],**ctx.obj["properties"])
+        print("cataloglll",ctx.obj["catalog"]) 
+
+
     if not isinstance(ctx.obj["catalog"], Catalog):
         ctx.obj["output"].exception(
-            ValueError("Could not determine catalog type from uri. REST (http/https) and Hive (thrift) is supported")
+        ValueError("Could not determine catalog type from uri. REST (http/https) and Hive (thrift) is supported")

Review Comment:
   ```suggestion
               ValueError("Could not determine catalog type from uri. REST (http/https) and Hive (thrift) is supported")
   ```



-- 
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: issues-unsubscribe@iceberg.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Fix CLI command order and catalog not found error [iceberg-python]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #1828:
URL: https://github.com/apache/iceberg-python/pull/1828#issuecomment-4122325932

   This pull request has been closed due to lack of activity. This is not a judgement on the merit of the PR in any way. It is just a way of keeping the PR queue manageable. If you think that is incorrect, or the pull request requires review, you can revive the PR at any 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: issues-unsubscribe@iceberg.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Fix CLI command order and catalog not found error [iceberg-python]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] closed pull request #1828: Fix CLI command order and catalog not found error
URL: https://github.com/apache/iceberg-python/pull/1828


-- 
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: issues-unsubscribe@iceberg.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Fix CLI command order and catalog not found error [iceberg-python]

Posted by "jason810496 (via GitHub)" <gi...@apache.org>.
jason810496 commented on code in PR #1828:
URL: https://github.com/apache/iceberg-python/pull/1828#discussion_r2008723316


##########
pyiceberg/cli/console.py:
##########
@@ -86,31 +91,48 @@ def run(
         ctx.obj["output"] = JsonOutput(verbose=verbose)
 
     try:
-        ctx.obj["catalog"] = load_catalog(catalog, **properties)
+        ctx.obj["first_level_catalog"] = catalog
+        ctx.obj["second_level_catalog"] = None
+        ctx.obj["properties"] = properties
+        
     except Exception as e:
         ctx.obj["output"].exception(e)
         ctx.exit(1)
 
+
+def _load_the_catalog_with_first_level_catalog(ctx: Context) -> None:
+    if ctx.obj["first_level_catalog"] is None and ctx.obj["second_level_catalog"] is None:
+        ctx.obj["catalog"] = load_catalog(None, **ctx.obj["properties"])
+    elif ctx.obj["first_level_catalog"] is not None and ctx.obj["second_level_catalog"] is None:
+        ctx.obj["catalog"] = load_catalog(ctx.obj["first_level_catalog"],**ctx.obj["properties"])
+    else:
+        ctx.obj["catalog"] = load_catalog(ctx.obj["second_level_catalog"],**ctx.obj["properties"])
+        print("cataloglll",ctx.obj["catalog"]) 
+
+
     if not isinstance(ctx.obj["catalog"], Catalog):
         ctx.obj["output"].exception(
-            ValueError("Could not determine catalog type from uri. REST (http/https) and Hive (thrift) is supported")
+        ValueError("Could not determine catalog type from uri. REST (http/https) and Hive (thrift) is supported")

Review Comment:
   Nit: The indentation, as well as the order of imported modules, can be fixed based on the last comment.
   ```suggestion
               ValueError("Could not determine catalog type from uri. REST (http/https) and Hive (thrift) is supported")
   ```



-- 
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: issues-unsubscribe@iceberg.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Fix CLI command order and catalog not found error [iceberg-python]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #1828:
URL: https://github.com/apache/iceberg-python/pull/1828#issuecomment-4071510676

   This pull request has been marked as stale due to 30 days of inactivity. It will be closed in 1 week if no further activity occurs. If you think that's incorrect or this pull request requires a review, please simply write any comment. If closed, you can revive the PR at any time and @mention a reviewer or discuss it on the dev@iceberg.apache.org list. Thank you for your contributions.


-- 
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: issues-unsubscribe@iceberg.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org