<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic how to read columns dynamically using pyspark in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/how-to-read-columns-dynamically-using-pyspark/m-p/4236#M1010</link>
    <description>&lt;P&gt;I have a table called MetaData and what columns are needed in the select are stored in MetaData.columns&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would like to read columns dynamically from MetaData.columns and create a view based on that.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;csv_values = "col1, col2, col3, col4"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;df = spark.createDataFrame([(csv_values,)], ["csv_column"])&lt;/P&gt;&lt;P&gt;df = df.select(split(df["csv_column"], ",").alias("array_column"))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;df1 = spark.read.format("parquet").load("FilePath").select(df["*"])&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This code is throwing error like below&lt;/P&gt;&lt;P&gt;Unexpected exception formatting exception. Falling back to standard exception&lt;/P&gt;</description>
    <pubDate>Wed, 17 May 2023 14:54:05 GMT</pubDate>
    <dc:creator>Enthusiastic_Da</dc:creator>
    <dc:date>2023-05-17T14:54:05Z</dc:date>
    <item>
      <title>how to read columns dynamically using pyspark</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-read-columns-dynamically-using-pyspark/m-p/4236#M1010</link>
      <description>&lt;P&gt;I have a table called MetaData and what columns are needed in the select are stored in MetaData.columns&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would like to read columns dynamically from MetaData.columns and create a view based on that.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;csv_values = "col1, col2, col3, col4"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;df = spark.createDataFrame([(csv_values,)], ["csv_column"])&lt;/P&gt;&lt;P&gt;df = df.select(split(df["csv_column"], ",").alias("array_column"))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;df1 = spark.read.format("parquet").load("FilePath").select(df["*"])&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This code is throwing error like below&lt;/P&gt;&lt;P&gt;Unexpected exception formatting exception. Falling back to standard exception&lt;/P&gt;</description>
      <pubDate>Wed, 17 May 2023 14:54:05 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-read-columns-dynamically-using-pyspark/m-p/4236#M1010</guid>
      <dc:creator>Enthusiastic_Da</dc:creator>
      <dc:date>2023-05-17T14:54:05Z</dc:date>
    </item>
  </channel>
</rss>

