The `hive-metastore-client` library provides a Pythonic interface for connecting to and performing Data Definition Language (DDL) operations on a Hive Metastore using the Thrift protocol. It simplifies interactions with Hive metadata, enabling users to programmatically create and manage databases, tables, and partitions. Actively maintained by QuintoAndar, the library is currently at version 1.0.9, offering a high-level abstraction over the underlying Thrift APIs.
pip install hive-metastore-clientVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to instantiate the HiveMetastoreClient, create a new database, and then create a table within that database. It uses the provided builders for constructing Thrift objects and includes basic error handling for connection issues. Ensure the Hive Metastore service is running and accessible at the specified host and port (defaults to localhost:9083, configurable via environment variables).
For most users, this library provides pre-generated Thrift interfaces, so manual compilation is not required. If necessary, refer to the library's `thrift_files` directory and documentation for guidance on specific Thrift compiler versions and generation steps.
Double-check `HIVE_HOST` and `HIVE_PORT` (or equivalent configuration) values. Ensure the Hive Metastore service is actively running and is reachable from where the Python client is executed. Network firewalls or incorrect DNS resolution can also prevent connections.
Consult the `hive-metastore-client` GitHub issues or documentation for known compatibility limitations with specific Hive Metastore versions. It's generally recommended to test thoroughly when upgrading either the client library or the Hive Metastore server.
Verify that the Hive Metastore service is running. Check that the `HIVE_METASTORE_HOST` and `HIVE_METASTORE_PORT` (or equivalent) configured in your client code precisely match the running Metastore service. Use network tools (like `ping`, `telnet`, or `nc`) to confirm network reachability from the client machine to the Metastore server on the specified port.
This usually points to an issue on the Hive Metastore server side, not directly the Python client. Check the Hive Metastore server logs for more detailed errors. Common fixes include verifying the `hive-site.xml` configuration (especially `hive.metastore.uris` and database connection details), ensuring the Metastore's backend database is accessible and not overloaded, and restarting the Metastore service.