problem: I was attempting to solve
this issue and found that cells were automatically converting to different cell types.
Auto conversion from Python --> SQL
- To mitigate some downstream dependency issues, I first tried converting the SQL cell to python (e.g, "df_result = mo.sql(f""" query """)") , and then would save the file, and then reset the Kernel. Post kernel reset, that cell that I converted to Python was back to being a SQL file.
- I resolved this auto-conversion by making df_result local (_df_result) and then df_result = _df_result.copy().
- Even though both were outputting the same DF, the python version seemed to work more extensively for dependencies.
Auto conversion from mo.sql + Python code --> SQL- I have data from an mo.sql outputting to a dataframe.
- This dataframe is then used in am mo.md
- Everything would be set up correctly - I would restart the kernel and the script would autorun
- Upon restart/rerun, my cells with mo.sql + Python would convert to SQL. I tried many times to have the .py cell format stick.
- To resolve this, I had to break out my mo.sql -> dataframe code (also unfortunately having to use the fix above) into a previous cell, and then display that resulting dataframe via an mo.md in the next cell.
RecommendationIdeally, cells would not auto-convert from Python --> SQL. Some people might be more comfortable using mo.sql explicitly.
Additionally, ideally I could generate a DF with mo.sql in a cell, and also present that DF in mo.md. If this is undesired, then throwing an exception and stating this requirement would be helpful.