Apache Druid 運算子¶
先決條件¶
要使用 DruidOperator
,您必須先設定 Druid 連線。
DruidOperator¶
若要直接將任務提交到 Druid,您需要提供 Druid 索引規範 json_index_file
的檔案路徑,以及 Druid overlord druid_ingest_conn_id
的連線 ID,後者接受 Airflow 連線中的索引任務。此外,您可以提供攝取類型 ingestion_type
以確定作業是批次攝取還是基於 SQL 的攝取。
以下還有 Druid 攝取規範的範例內容。
有關參數定義,請查看 DruidOperator
。
使用運算子¶
submit_job = DruidOperator(task_id="spark_submit_job", json_index_file="json_index.json")
# Example content of json_index.json:
JSON_INDEX_STR = """
{
"type": "index_hadoop",
"datasource": "datasource_prd",
"spec": {
"dataSchema": {
"granularitySpec": {
"intervals": ["2021-09-01/2021-09-02"]
}
}
}
}
"""
參考¶
如需更多資訊,請參閱 Apache Druid 攝取規範參考。