Unable to deploy streamlit app from Snowflake quickstart

When I tried your code locally, a very clear error message showed up

SnowparkFetchDataException: (1406): Failed to fetch a Pandas Dataframe. The error is: to_pandas() did not return a Pandas DataFrame. If you use session.sql(…).to_pandas(), the input query can only be a SELECT statement. Or you can use session.sql(…).collect() to get a list of Row objects for a non-SELECT statement, then convert it to a Pandas DataFrame.

Now, this error message doesn’t really make sense, because what you are doing is in fact a select call, as far as I can tell, but I tried their suggestion of using .collect() and converting it to a dataframe, and that worked fine.

You might look on on GitHub - snowflakedb/snowpark-python: Snowflake Snowpark Python API to see if this has already been reported as an issue, and if not than add a new issue for this.

Anyway, this code seems to work fine, in place of .to_pandas()

snow_df_co2 = pd.DataFrame(snow_df_co2.collect())