Q: Can SparkR::structField() argument 'type' be a structType()? I have the following spark data frame in R:
df <- SparkR::read.df(path, "json", schema = schema)

My schema is built as follows:
schema <-
  SparkR::structType(
    structField('visitor_id', 'string'),
    structField('timestamp','string')
    )

My problem is that 'df' has multiple nested columns. The timestamp column is nested and the schema doesn't build correctly. The current head and schema are as follows:
schema(df)

StructType
|-name = "visitor_id", type = "StringType", nullable = TRUE
|-name = "timestamp", type = "StringType", nullable = TRUE

Timestamp should not be NA
head(df)

  visitor_id timestamp 
1 abc123     <NA>     
2 abc123     <NA>     
3 abc123     <NA>
6 abc123     <NA>

The schema and head should be something similar to the below output that I fictitiously created, where the 'type' argument in SparkR::structField() for 'data' and 'udo' are structures and not strings:
schema(df)
StructType
|-name = "visitor_id", type = "StringType", nullable = TRUE
|       |-name = " data ", type = struct, nullable = TRUE
        |      |-name = " udo ", type = struct, nullable = TRUE
               |       |-name = " timestamp ", type = "StringType", nullable = TRUE


head(df)
  visitor_id timestamp 
1 abc123     1581949496
2 abc123     1581969492
3 abc123     1581978651
6 abc123     1581912570

My attempt to build the schema below is where timestamp exists in two nested column 'data' and 'udo' where the structure for 'data' and 'udo' are structTypes and not strings. My hope is that the argument 'type' in structField() can be something other than a string. In the package documentation and using online resources I haven't found any examples of schemas built with SparkR that deal with non-flattened json tables. Is there a solution for this problem using SparkR? 
schema1 <-
  SparkR::structType({
    structField('visitor_id', 'string')
    structField('data', structType({
      structField('udo', structType({
        structField('timestamp','string')
      })
      )
    })
    )
  })

Error in structField.character("udo", structType({ : 
  Field type must be a string.

