cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results for 
Search instead for 
Did you mean: 

how to read columns dynamically using pyspark

Enthusiastic_Da
New Contributor II

I have a table called MetaData and what columns are needed in the select are stored in MetaData.columns

I would like to read columns dynamically from MetaData.columns and create a view based on that.

csv_values = "col1, col2, col3, col4"

df = spark.createDataFrame([(csv_values,)], ["csv_column"])

df = df.select(split(df["csv_column"], ",").alias("array_column"))

df1 = spark.read.format("parquet").load("FilePath").select(df["*"])

This code is throwing error like below

Unexpected exception formatting exception. Falling back to standard exception

0 REPLIES 0

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you won’t want to miss the chance to attend and share knowledge.

If there isn’t a group near you, start one and help create a community that brings people together.

Request a New Group