Search code examples
pythonsnowflake-cloud-data-platform

how to work with snowflake external file list on snowpark


import snowflake.snowpark as snowpark
from snowflake.snowpark.functions import col

def main(session: snowpark.Session): 
    dataframe= session.sql('list @test/ext')
    df_selected = dataframe.select(col('name'))
 
    return df_selected

I am making the following error:

snowflake.snowpark.exceptions.SnowparkSQLException: 1304): ###############: 000904 (42000): SQL compilation error: error line 1 at position 7
invalid identifier 'NAME'

Solution

  • If you execute dataframe.show() you will see that the column name Snowflake returns is lowercase. So you need the following:

    df_selected = dataframe.select(col('"name"'))