-
Notifications
You must be signed in to change notification settings - Fork 14.3k
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
#8525 Add SQL Branch Operator #8942
Conversation
Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contribution Guide (https://github.com/apache/airflow/blob/master/CONTRIBUTING.rst)
|
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.
Hi @eladkal , the PR is ready to review again. Please take a look when you have a chance. Thanks! |
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.
Hi @eladkal , Thank you again for the review. The latest commit included changes for the last set of comments. Please take a look when you have a chance. Thanks. |
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.
LGTM.
One last observation about the file name sql_branch_operator.py
. By accepting this PR Airflow will have 2 sql related operator files in the core (check_operator.py
, sql_branch_operator.py
) so maybe the file name should be changed sql_branch_operator.py
-> sql.py
so that In the future check_operator.py can be deprecated by move the operators into sql.py
Similar to the deprecation of python_operator.py by moving classes to python.py
Lets wait to see what others think of that.
Thanks @eladkal. If everyone decided to merge the operators into one, shouldn't we use a separate PR instead? I am new to the community, so I am not sure what is the next step? Is there anyone I need to talk to in order to finish this PR? Thanks. |
@samuelkhtu we can do it in a separate PR. This will allow us to build a better git history. |
Thanks @mik-laj and @eladkal , can someone help and approve this PR? I am ready to move on to the next issue. Thanks. |
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.
Looks really great and sounds super useful - just two nits -if you can take a look
SQL Branch Operator allow user to execute a SQL query in any supported backend to decide which branch to follow. The SQL branch operator expect query to return True/False (Boolean) or 0/1 (Integer) or true/y/yes/1/on/false/n/no/0/off (String).
1. Modify foreground color to be more visible. 2. Replace hook.get_records with hook.get_first as SQL branch operator expects single row return. 3. Modify follow_task_ids_if_true/false parameters with List[str] type hint instead of str.
1. Add tuple and list return data type to SQL branch operator. 2. Add unit test for single return value
1. Query get_first should return row['column'] instead. 2. Fixed unit test to return list of result instead of list of list of result.
1. Remove unused import from unit test file. 2. Add check to verify required SQL paramter. 3. Remove blank line between param and parm type docstring.
5303fac
to
fbb84a8
Compare
Awesome work, congrats on your first merged pull request! |
Nice @samuelkhtu ! |
|
SQL Branch Operator allow user to execute a SQL query in any supported backend to decide which
branch of the DAG to follow.
The SQL branch operator expects SQL query to return any of the following:
Make sure to mark the boxes below before creating PR: [x]
In case of fundamental code change, Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in UPDATING.md.
Read the Pull Request Guidelines for more information.