Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions mkdocs/docs/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Options:
--catalog TEXT
--verbose BOOLEAN
--output [text|json]
--ugi TEXT
--uri TEXT
--credential TEXT
--help Show this message and exit.
Expand Down
1 change: 1 addition & 0 deletions mkdocs/docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ catalog:
| Key | Example | Description |
| ---------------------- | ----------------------- | -------------------------------------------------------------------------------------------------- |
| uri | https://rest-catalog/ws | URI identifying the REST Server |
| ugi | t-1234:secret | Hadoop UGI for Hive client. |
| credential | t-1234:secret | Credential to use for OAuth2 credential flow when initializing the catalog |
| token | FEW23.DFSDF.FSDF | Bearer token value to use for `Authorization` header |
| rest.sigv4-enabled | true | Sign requests to the REST Server using AWS SigV4 protocol |
Expand Down
8 changes: 6 additions & 2 deletions pyiceberg/catalog/hive.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,17 +130,21 @@ class _HiveClient:

_transport: TTransport
_client: Client
_ugi: Optional[List[str]]

def __init__(self, uri: str):
def __init__(self, uri: str, ugi: Optional[str] = None):
url_parts = urlparse(uri)
transport = TSocket.TSocket(url_parts.hostname, url_parts.port)
self._transport = TTransport.TBufferedTransport(transport)
protocol = TBinaryProtocol.TBinaryProtocol(transport)

self._client = Client(protocol)
self._ugi = ugi.split(':') if ugi else None

def __enter__(self) -> Client:
self._transport.open()
if self._ugi:
self._client.set_ugi(*self._ugi)
return self._client

def __exit__(
Expand Down Expand Up @@ -233,7 +237,7 @@ class HiveCatalog(Catalog):

def __init__(self, name: str, **properties: str):
super().__init__(name, **properties)
self._client = _HiveClient(properties["uri"])
self._client = _HiveClient(properties["uri"], properties.get("ugi"))

def _convert_hive_into_iceberg(self, table: HiveTable, io: FileIO) -> Table:
properties: Dict[str, str] = table.parameters
Expand Down
13 changes: 12 additions & 1 deletion pyiceberg/cli/console.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,22 @@ def wrapper(*args: Any, **kwargs: Any): # type: ignore
@click.option("--catalog")
@click.option("--verbose", type=click.BOOL)
@click.option("--output", type=click.Choice(["text", "json"]), default="text")
@click.option("--ugi")
@click.option("--uri")
@click.option("--credential")
@click.pass_context
def run(ctx: Context, catalog: Optional[str], verbose: bool, output: str, uri: Optional[str], credential: Optional[str]) -> None:
def run(
ctx: Context,
catalog: Optional[str],
verbose: bool,
output: str,
ugi: Optional[str],
uri: Optional[str],
credential: Optional[str],
) -> None:
properties = {}
if ugi:
properties["ugi"] = ugi
if uri:
properties["uri"] = uri
if credential:
Expand Down