title: Spark DDL Schema JSON Struct
body: <h1>Question</h1>
  <p>I am trying to define a nested .json schema in pyspark, but cannot get the ddl_schema string to work.</p>
  <p>Usually in SQL this would be ROW, I have tried STRUCT below but can't get the data type correct this is the error...</p>
  <pre class="lang-py prettyprint-override"><code>ParseException: 
  mismatched input '(' expecting {&lt;EOF&gt;, ',', 'COMMENT', NOT}(line 6, pos 15)
  
  == SQL ==
  
      driverId INT,
      driverRef STRING,
      number STRING,
      code STRING,
      name STRUCT(forename STRING, surname STRING),
  ---------------^^^
      dob DATE,
      nationality STRING,
      url STRING
  </code></pre>
  <h1>Data Sample</h1>
  <pre><code>            +--------+----------+------+----+--------------------+----------+-----------+--------------------+
              |driverId| driverRef|number|code|                name|       dob|nationality|                 url|
              +--------+----------+------+----+--------------------+----------+-----------+--------------------+
              |       1|  hamilton|    44| HAM|   {Lewis, Hamilton}|1985-01-07|    British|http://en.wikiped...|
  </code></pre>
  <h1>Code Sample</h1>
  <pre class="lang-py prettyprint-override"><code>        mnt = &quot;/mnt/dev/root&quot;
          env = &quot;raw&quot;
          path = &quot;formula1/drivers&quot;
          fileFormat = &quot;json&quot;
          
          inPath = f&quot;{mnt}/{env.upper()}/{path}.{fileFormat}&quot;
          
          
          options = {'header': 'True'}
          
          ddl_schema = &quot;&quot;&quot;
              driverId INT,
              driverRef STRING,
              number STRING,
              code STRING,
              name STRUCT(forename STRING, surname STRING),
              dob DATE,
              nationality STRING,
              url STRING
          &quot;&quot;&quot;
          
          drivers_df = (spark
                         .read
                         .options(**options)
                         .schema(ddl_schema)
                         .format(fileFormat)
                         .load(inPath)
                       )
  </code></pre>