通过 SQLExecuteQueryOperator 连接到 Apache Drill¶
前提条件¶
使用 SQLExecuteQueryOperator
,在 Drill 查询引擎中执行 SQL 命令。
要连接到 Drill,您必须配置一个 Drill 连接,并将其作为 conn_id
传递给 SQLExecuteQueryOperator。
警告
之前使用 DrillOperator 执行此类操作。但目前 DrillOperator 已弃用,并将在提供包的未来版本中移除。请尽快考虑切换到 SQLExecuteQueryOperator。
SQLExecuteQueryOperator¶
在 Apache Drill 服务器上执行一个或多个 SQL 查询。sql
参数是可模板化的,并且可以是外部的 .sql
文件。
使用 Operator¶
tests/system/apache/drill/example_drill_dag.py
sql_task = SQLExecuteQueryOperator(
task_id="json_to_parquet_table",
sql="""
drop table if exists dfs.tmp.employee;
create table dfs.tmp.employee as select * from cp.`employee.json`;
""",
)
参考¶
更多信息,请参阅 有关查询数据的 Drill 文档。