I solved the problem. Noting it down here in case someone else has the same issue.
- The issue was happening because one of the tables used in the SQL query was being populated from a Google Sheet directly. When I commented out the join with this table, the issue stopped. This however was not the problem but just a symptom of the real issue.
- The main issue was that I was not taking care of caching the data properly. That is why the table linked to the Google Sheet kept triggering the query run for some reason. I solved this by using
@st.experimental_memo
decorator. Please note that earlier I used@st.cache
and ran into other issues. In their documentation, Streamlit has also suggested using@st.experimental_memo
instead, as it is much faster.