SQLExecuteQueryOperator 連線 Apache Pinot

使用 SQLExecuteQueryOperator 執行針對 Apache Pinot 叢集的 SQL 查詢。

注意

對於 Apache Pinot 沒有專門的 Operator。請改用 SQLExecuteQueryOperator

注意

確保已安裝所需的 provider 包(例如 apache-airflow-providers-apache-pinot)以啟用 Apache Pinot 支援。

使用 Operator

使用 conn_id 引數連線到您的 Apache Pinot 例項,連線元資料結構如下

Pinot Airflow 連線元資料

引數

輸入

主機:字串

Pinot broker 主機名或 IP 地址

埠:整數

Pinot broker 埠(預設:8000)

模式:字串

(未使用)

額外:JSON

可選欄位,例如:{"endpoint": "query/sql"}

SQLExecuteQueryOperator 連線 Apache Pinot 的一個示例用法如下

tests/system/apache/pinot/example_pinot.py


    # Task: Simple query to test connection and query engine
    select_1_task = SQLExecuteQueryOperator(
        task_id="select_1",
        sql="SELECT 1",
    )

    # Task: Count total records in airlineStats (sample table)
    count_airline_stats = SQLExecuteQueryOperator(
        task_id="count_airline_stats",
        sql="SELECT COUNT(*) FROM airlineStats",
    )

    # Task: Group by Carrier and count flights
    group_by_carrier = SQLExecuteQueryOperator(
        task_id="group_by_carrier",
        sql=dedent("""
            SELECT Carrier, COUNT(*) AS flight_count
            FROM airlineStats
            GROUP BY Carrier
            ORDER BY flight_count DESC
            LIMIT 5
        """).strip(),
    )

參考

如需進一步資訊,請參閱

注意

直接透過 SQLExecuteQueryOperator() 提供的引數優先於 Airflow 連線元資料中指定的引數。

本條目是否有幫助?