title: Give prefix to all columns when selecting with 'struct_name.*'
body: <p>The dataframe below is a temp_table named: 'table_name'.<br />
  How would you use spark.sql() to give a prefix to all columns?</p>
  <pre><code>root
   |-- MAIN_COL: struct (nullable = true)
   |    |-- a: string (nullable = true)
   |    |-- b: string (nullable = true)
   |    |-- c: string (nullable = true)
   |    |-- d: string (nullable = true)
   |    |-- f: long (nullable = true)
   |    |-- g: long (nullable = true)
   |    |-- h: long (nullable = true)
   |    |-- j: long (nullable = true)
  </code></pre>
  <p>The below query</p>
  <pre><code>spark.sql(&quot;select MAIN_COL.* from table_name&quot;)
  </code></pre>
  <p>gives back columns named a,b,c..., but how to make them all look like e.g. pre_a, pre_b, pre_c?<br />
  <strong>Want to avoid selecting and giving them alias one by one. What if I have 30 columns?</strong></p>
  <p>I hope a custom UDF can solve it which is used in SQL, but really not sure how to handle this.</p>
  <pre><code> # Generate a pandas DataFrame
  import pandas as pd
  a_dict={
      'a':[1,2,3,4,5],
      'b':[1,2,3,4,5],
      'c':[1,2,3,4,5],
      'e':list('abcde'),
      'f':list('abcde'),
      'g':list('abcde')
  }
  pandas_df=pd.DataFrame(a_dict)
  # Create a Spark DataFrame from a pandas DataFrame using Arrow
  spark.conf.set(&quot;spark.sql.execution.arrow.enabled&quot;, &quot;true&quot;)
  df = spark.createDataFrame(pandas_df)
  
  #struct
  from pyspark.sql.functions import struct
  main=df.select(struct(df.columns).alias(&quot;MAIN_COL&quot;))
  </code></pre>