Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AIP-47 - Migrate hive DAGs to new design #22439 #24204

Merged
merged 1 commit into from
Jun 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/apache-airflow-providers-apache-hive/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Content
:maxdepth: 1
:caption: Resources

Example DAGs <https://github.com/apache/airflow/tree/main/airflow/providers/apache/hive/example_dags>
Example DAGs <https://github.com/apache/airflow/tree/main/tests/system/providers/apache/hive>
PyPI Repository <https://pypi.org/project/apache-airflow-providers-apache-hive/>
Installing from sources <installing-providers-from-sources>

Expand Down
3 changes: 2 additions & 1 deletion docs/apache-airflow-providers-apache-hive/operators.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ HiveOperator

This operator executes hql code or hive script in a specific Hive database.

.. exampleinclude:: /../../airflow/providers/apache/hive/example_dags/example_twitter_dag.py
.. exampleinclude:: /../../tests/system/providers/apache/hive/example_twitter_dag.py
:language: python
:dedent: 4
:start-after: [START create_hive]
:end-before: [END create_hive]

Expand Down
17 changes: 17 additions & 0 deletions tests/system/providers/apache/hive/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,18 @@
"""
This is an example dag for managing twitter data.
"""

import os
from datetime import date, datetime, timedelta

from airflow import DAG
from airflow.decorators import task
from airflow.operators.bash import BashOperator
from airflow.providers.apache.hive.operators.hive import HiveOperator

ENV_ID = os.environ.get("SYSTEM_TESTS_ENV_ID")
DAG_ID = "example_twitter_dag"


@task
def fetch_tweets():
Expand Down Expand Up @@ -68,7 +73,7 @@ def transfer_to_db():


with DAG(
dag_id='example_twitter_dag',
dag_id=DAG_ID,
default_args={
'owner': 'Ekhtiar',
'retries': 1,
Expand Down Expand Up @@ -145,3 +150,14 @@ def transfer_to_db():
)

analyze >> load_to_hdfs >> load_to_hive >> hive_to_mysql

from tests.system.utils.watcher import watcher

# This test needs watcher in order to properly mark success/failure
# when "tearDown" task with trigger rule is part of the DAG
list(dag.tasks) >> watcher()

from tests.system.utils import get_test_run # noqa: E402

# Needed to run the example DAG with pytest (see: tests/system/README.md#run_via_pytest)
test_run = get_test_run(dag)