Skip to content

Add @task.analytics Decorator#62648

Merged
gopidesupavan merged 2 commits intoapache:mainfrom
gopidesupavan:add-decorator-analytics-operator
Feb 28, 2026
Merged

Add @task.analytics Decorator#62648
gopidesupavan merged 2 commits intoapache:mainfrom
gopidesupavan:add-decorator-analytics-operator

Conversation

@gopidesupavan
Copy link
Member

@gopidesupavan gopidesupavan commented Feb 28, 2026

Follow-up to #62232 which introduced the AnalyticsOperator.

This PR adds TaskFlow API support for the AnalyticsOperator via the @task.analytics decorator.

Usage Example

from airflow.providers.common.sql.config import DataSourceConfig
from airflow.sdk import DAG, task

datasource_config = DataSourceConfig(
    conn_id="aws_default", table_name="users_data", uri="s3://bucket/path/", format="parquet"
)

with DAG(dag_id="example_analytics_decorator") as dag:

    @task.analytics(datasource_configs=[datasource_config])
    def get_user_summary_queries():
        return ["SELECT * FROM users_data LIMIT 10", "SELECT count(*) FROM users_data"]

    @task.analytics(datasource_configs=[datasource_config], result_output_format="json")
    def get_filtered_user_queries(limit: int = 50):
        return [f"SELECT * FROM users_data LIMIT {limit}", "SELECT count(*) FROM users_data"]

    get_user_summary_queries() >> get_filtered_user_queries(limit=25)

Was generative AI tooling used to co-author this PR?
  • Yes (please specify the tool below)
    Generated-by: Copilot following the guidelines

  • Read the Pull Request Guidelines for more information. Note: commit author/co-author name and email in commits become permanently public when merged.
  • For fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
  • When adding dependency, check compliance with the ASF 3rd Party License Policy.
  • For significant user-facing changes create newsfragment: {pr_number}.significant.rst or {issue_number}.significant.rst, in airflow-core/newsfragments.

@gopidesupavan gopidesupavan force-pushed the add-decorator-analytics-operator branch from e7345b8 to 7df04f0 Compare February 28, 2026 20:44
@gopidesupavan gopidesupavan merged commit 07945cb into apache:main Feb 28, 2026
125 of 127 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Development

Successfully merging this pull request may close these issues.

2 participants