This connector demonstrates how to fetch data from Apache Hive using SQLAlchemy with the PyHive dialect and fivetran-connector-sdk library. The connector is designed to handle large datasets by processing data in a streaming fashion and maintaining sync state to resume from the last successful position.
- Supported Python versions
- Operating system:
- Windows: 10 or later (64-bit only)
- macOS: 13 (Ventura) or later (Apple Silicon [arm64] or Intel [x86_64])
- Linux: Distributions such as Ubuntu 20.04 or later, Debian 10 or later, or Amazon Linux 2 or later (arm64 or x86_64)
Refer to the Connector SDK setup guide to get started.
To initialize a new Connector SDK project using this connector as a starting point, run:
fivetran init --template apache_hive/using_sqlalchemy
fivetran init initializes a new Connector SDK project by setting up the project structure, configuration files, and a connector you can run immediately with fivetran debug. For more information on fivetran init, refer to the Connector SDK init documentation.
Note: Ensure you have updated the
configuration.jsonfile with the necessary parameters before runningfivetran debug. See the Configuration file section for details on the required configuration parameters.
- Connection to Apache Hive data source using SQLAlchemy ORM.
- Incremental sync based on
created_attimestamp. - Streaming data retrieval using execution options to handle large datasets efficiently.
This connector requires the following configuration parameters to establish a connection to your Hive instance:
{
"hostname": "<YOUR_HIVE_HOSTNAME>",
"port": "<YOUR_HIVE_PORT>",
"username": "<YOUR_HIVE_USERNAME>",
"database": "<YOUR_HIVE_DATABASE>"
}Note: When submitting connector code as a Community Connector in the open-source Connector SDK repository, ensure the
configuration.jsonfile has placeholder values. When adding the connector to your production repository, ensure that theconfiguration.jsonfile is not checked into version control to protect sensitive information.
Include the following dependencies in your requirements.txt file:
SQLAlchemy==2.0.40
PyHive==0.7.0
thrift_sasl
sasl
PyHive is required for actual dialect implementation for Hive along with the SQLAlchemy ORM. The thrift_sasl and sasl packages are necessary for SASL authentication, which is commonly used with Hive.
Note: Some packages are pre-installed in the Connector SDK runtime environment. To avoid dependency conflicts, do not declare them in your
requirements.txt.
The connector supports authentication for Apache Hive through SQLAlchemy. You need to provide the following:
hostname: The address of your Hive serverport: The port number Hive is listening on (typically 10000)username: Your Hive usernamedatabase: The name of the Hive database you want to connect to
Authentication is handled in the create_hive_connection function.
The connector performs the following data handling operations:
- Fetching: Data is retrieved from Apache Hive using SQLAlchemy with raw SQL queries and stream options.
- Processing: The
process_rowfunction converts raw Hive data into a dictionary format suitable for Fivetran.- Column names are extracted and mapped to their values.
- Streaming: Uses SQLAlchemy's
stream_resultsexecution option to efficiently process large datasets without loading everything into memory. - State management: The connector tracks the latest created timestamp to enable incremental syncs.
The connector creates a table named PEOPLE with the following schema:
{
"table": "people",
"primary_key": ["id"],
"columns": {
"id": "INT",
"created_at": "UTC_DATETIME"
}
}The examples provided are intended to help you effectively use Fivetran's Connector SDK. While we've tested the code, Fivetran cannot be held responsible for any unexpected or negative consequences that may arise from using these examples. For inquiries, please reach out to our Support team.