SQLExecuteQueryOperator 连接到 Apache Hive¶
使用 SQLExecuteQueryOperator
在 Apache Hive 数据库中执行 Hive 命令。
注意
此前,使用 HiveOperator
执行此类操作。弃用后,此 Operator 已被移除。请改用 SQLExecuteQueryOperator
。
注意
请确保已安装 apache-airflow-providers-apache-hive
包以启用 Hive 支持。
使用 Operator¶
使用 conn_id
参数连接到您的 Apache Hive 实例,连接元数据结构如下
参数 |
输入 |
---|---|
Host: string |
HiveServer2 主机名或 IP 地址 |
Schema: string |
默认数据库名称 (可选) |
Login: string |
Hive 用户名 (如果适用) |
Password: string |
Hive 密码 (如果适用) |
Port: int |
HiveServer2 端口 (默认: 10000) |
Extra: JSON |
额外连接配置,例如身份验证方法: |
SQLExecuteQueryOperator 连接到 Apache Hive 的一个示例用法如下
tests/system/apache/hive/example_hive.py
create_table_hive_task = SQLExecuteQueryOperator(
task_id="create_table_hive",
sql="create table hive_example(a string, b int) partitioned by(c int)",
)
参考¶
更多信息,请查阅
注意
通过 SQLExecuteQueryOperator() 直接提供的参数优先于 Airflow 连接元数据中指定的参数 (如 schema
, login
, password
等)。