Selective column loader unity catalog

vk217
Contributor

I am loading a table into a data frame using

 

df = spark.table(table_name)

 

Is there a way to load only the required columns? The table has more than 50+ columns and I only need a handful of column.

daniel_sahal
Databricks MVP

@vk217 Simply just use select function, ex.

df = spark.read.table(table_name).select("col1", "col2", "col3")

View solution in original post