-
Notifications
You must be signed in to change notification settings - Fork 14.2k
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
Add Core SQL Provider #24476
Merged
Merged
Add Core SQL Provider #24476
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
78df5ea
Add Core SQL Provider
denimalpaca 57552af
Fix build doc errors
denimalpaca 3b5303f
Fix example DAG provider import statement
denimalpaca 99482fc
Add parse_boolean() to operator file to resolve import error
denimalpaca 00fb487
Add leq and geq to spelling_wordlist
denimalpaca 3f9b7c3
Fix capitalization and grammar errors in doc
denimalpaca f867b4d
Remove core.sql from list of tags, use software tag instead for provider
denimalpaca 9179ea6
Re-remove core.sql from list of provider tags
denimalpaca 04e16f1
Fix broken link reference in provider doc
denimalpaca de4caf0
Update breeze images
denimalpaca 05f17af
Remove merge conflict lines fix after rebase
denimalpaca 4ab537e
Change names of geq_than and leq_than to geq_to and leq_to, respectively
denimalpaca 4cb5df1
Update airflow/providers/core/sql/operators/sql.py
denimalpaca c3f30d0
Unindent return in _get_match()
denimalpaca a5400fa
Return False at end of _get_match() to make static checks pass
denimalpaca f34c3d0
Update breeze output commands hash
denimalpaca f225249
Fix _get_match() logic
denimalpaca 138838a
Fix output-commands-hash file after rebase
denimalpaca File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,6 +43,7 @@ body: | |
- celery | ||
- cloudant | ||
- cncf-kubernetes | ||
- core-sql | ||
- databricks | ||
- datadog | ||
- dbt-cloud | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# 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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
.. 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. | ||
|
||
|
||
Changelog | ||
--------- | ||
|
||
1.0.0 | ||
..... | ||
|
||
Initial version of the provider. | ||
Adds SQLColumnCheckOperator and SQLTableCheckOperator. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# 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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# 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. |
77 changes: 77 additions & 0 deletions
77
airflow/providers/core/sql/example_dags/example_sql_column_table_check.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
# | ||
# 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. | ||
from airflow import DAG | ||
from airflow.providers.core.sql.operators.sql import SQLColumnCheckOperator, SQLTableCheckOperator | ||
from airflow.utils.dates import datetime | ||
|
||
AIRFLOW_DB_METADATA_TABLE = "ab_role" | ||
connection_args = { | ||
"conn_id": "airflow_db", | ||
"conn_type": "Postgres", | ||
"host": "postgres", | ||
"schema": "postgres", | ||
"login": "postgres", | ||
"password": "postgres", | ||
"port": 5432, | ||
} | ||
|
||
with DAG( | ||
"example_sql_column_table_check", | ||
description="Example DAG for SQLColumnCheckOperator and SQLTableCheckOperator.", | ||
default_args=connection_args, | ||
start_date=datetime(2021, 1, 1), | ||
schedule_interval=None, | ||
catchup=False, | ||
) as dag: | ||
""" | ||
### Example SQL Column and Table Check DAG | ||
|
||
Runs the SQLColumnCheckOperator and SQLTableCheckOperator against the Airflow metadata DB. | ||
""" | ||
|
||
# [START howto_operator_sql_column_check] | ||
column_check = SQLColumnCheckOperator( | ||
task_id="column_check", | ||
table=AIRFLOW_DB_METADATA_TABLE, | ||
column_mapping={ | ||
"id": { | ||
"null_check": { | ||
"equal_to": 0, | ||
"tolerance": 0, | ||
}, | ||
"distinct_check": { | ||
"equal_to": 1, | ||
}, | ||
} | ||
}, | ||
) | ||
# [END howto_operator_sql_column_check] | ||
|
||
# [START howto_operator_sql_table_check] | ||
row_count_check = SQLTableCheckOperator( | ||
task_id="row_count_check", | ||
table=AIRFLOW_DB_METADATA_TABLE, | ||
checks={ | ||
"row_count_check": { | ||
"check_statement": "COUNT(*) = 1", | ||
} | ||
}, | ||
) | ||
# [END howto_operator_sql_table_check] | ||
|
||
column_check >> row_count_check |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# 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. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not a fan of "core.sql" too like @ephraimbuddy -- maybe "base.sql" is better 🤷 but I do know that there already is a BaseSQLOperator -- which we should think of moving to a provider too tbh.
But naming is heard. tagging a few people if they have better suggestions for names: @dstandish @jedcunningham @uranusjr
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe "common" would be better than "core"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can still change it - before we release the provider and I think we should only do it after we move DBApiHook there (as explained in #23971).
I think common might be a better choice indeed.