[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

How do you branch your code with BigQuery?

I believe this is quite common case when working with data.

If something : do A
else: do B
With coding PythonBranchOperator is the solution.

But when working on Google Cloud there is no way to do this.
All existed operators are designed to continue or fail on comparison of specific value:
BigQueryValueCheckOperator  with pass_value=500 will continue if 500 return or fail in any other case. Same for all other CheckOperators. You must know the value in advanced for this to work and it's not an actual branch but more of a way to stop the workflow if an unexpected result has been found.

But how do you handle a scenario where you want to do A or B based on condition from a query result? Nothing needs to be failed. just a simple branch.

XCOM could solve it. But there is no support for XCOM yet.


Say for example:
the query represent the number of frauds.. if it's <1000 you want to email specific users (EmailOperator) , if it's >=1000 you want to run another operator and continue the workflow.

Any thoughts on the matter will be appreciated.