Query Airflow XCom table with value column filter

68 Views Asked by At

I need to query the Airflow XCom table and retrieve rows who have int X in the "value" column. The "value" column is of type BYTEA.

In my case, "value" column holds a string of ints like "111" or "111 222".

I want a way to query the XCom table and look at only rows who have "111" in the "value" column. In the case above, I would like the query to return two rows; one row of "111" and one row of "111 222"

I tried the following code and this only retrieved rows who had a single value in the "value" string. In the above example, it would only return the "111" row.

from airflow.models import XCom
from airflow.utils.session import provide_session

@provide_session
def query(user_id: int, session=None):
    value = json.dumps(user_id).encode('UTF-8')
    return session.query(XCom).filter(XCom.value.like(value)).all()
0

There are 0 best solutions below