Skip to content

Commit 80b6754

Browse files
authored
Migrate Google example sql_to_sheets to new design AIP-47 (#24814)
related: #22447, #22430
1 parent 2c4fd05 commit 80b6754

3 files changed

Lines changed: 31 additions & 7 deletions

File tree

docs/apache-airflow-providers-google/operators/transfer/sql_to_sheets.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Upload data from SQL to Google Sheets
3535
To upload data from and Database using SQL to Google Spreadsheet you can use the
3636
:class:`~airflow.providers.google.suite.transfers.sql_to_sheets.SQLToGoogleSheetsOperator`.
3737

38-
.. exampleinclude:: /../../airflow/providers/google/suite/example_dags/example_sql_to_sheets.py
38+
.. exampleinclude:: /../../tests/system/providers/google/cloud/sql_to_sheets/example_sql_to_sheets.py
3939
:language: python
4040
:dedent: 4
4141
:start-after: [START upload_sql_to_sheets]
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.

airflow/providers/google/suite/example_dags/example_sql_to_sheets.py renamed to tests/system/providers/google/cloud/sql_to_sheets/example_sql_to_sheets.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,25 @@
1515
# KIND, either express or implied. See the License for the
1616
# specific language governing permissions and limitations
1717
# under the License.
18-
18+
import os
1919
from datetime import datetime
2020

2121
from airflow import models
2222
from airflow.providers.google.suite.transfers.sql_to_sheets import SQLToGoogleSheetsOperator
2323

24+
ENV_ID = os.environ.get("SYSTEM_TESTS_ENV_ID")
25+
DAG_ID = "example_sql_to_sheets"
26+
2427
SQL = "select 1 as my_col"
25-
NEW_SPREADSHEET_ID = "123"
28+
NEW_SPREADSHEET_ID = os.environ.get("NEW_SPREADSHEET_ID", "123")
2629

2730
with models.DAG(
28-
"example_sql_to_sheets",
31+
DAG_ID,
2932
start_date=datetime(2021, 1, 1),
30-
schedule_interval=None, # Override to match your needs
33+
schedule_interval='@once', # Override to match your needs
3134
catchup=False,
32-
tags=["example"],
35+
tags=["example", "sql"],
3336
) as dag:
34-
3537
# [START upload_sql_to_sheets]
3638
upload_gcs_to_sheet = SQLToGoogleSheetsOperator(
3739
task_id="upload_sql_to_sheet",
@@ -40,3 +42,9 @@
4042
spreadsheet_id=NEW_SPREADSHEET_ID,
4143
)
4244
# [END upload_sql_to_sheets]
45+
46+
47+
from tests.system.utils import get_test_run # noqa: E402
48+
49+
# Needed to run the example DAG with pytest (see: tests/system/README.md#run_via_pytest)
50+
test_run = get_test_run(dag)

0 commit comments

Comments
 (0)