title: BigQuery, how to define array like field programmatically?
body: <p>I'm trying to start a datawarehouse project, this is what I would like my schema to look like:</p>
  
  <p>table: event_log
  schema:</p>
  
  <pre><code> -&gt; info
      -&gt; user_id: "xyz"
      -&gt; user_properties // &lt;- I want this to be array like
         -&gt; 0
            -&gt; key: "name
            -&gt; value
               -&gt; int_value: null
               -&gt; string_value: "osp"
               ...
         -&gt; 1 // and it goes on
  </code></pre>
  
  <p>The problem is I don't know how to programatically define this array like structure.</p>
  
  <p>I took the idea from here:</p>
  
  <p><a href="https://www.youtube.com/watch?v=pxNrkjBeHpw" rel="nofollow noreferrer">https://www.youtube.com/watch?v=pxNrkjBeHpw</a></p>
  
  <p>here is my code (kotlin using the java google cloud library) so far:</p>
  
  <pre><code>    val tableId = TableId.of(datasetName, tableName)
  
      // First part, general field
      val generalInfoFields = ArrayList&lt;Field&gt;()
      generalInfoFields.add(Field.of("user_id", LegacySQLTypeName.STRING))
  
  
      generalInfoFields.add(Field.of("user_properties", {ARRAY LIKE TYPE??}))
  
      val general_info = Field.of("general_info", LegacySQLTypeName.RECORD, FieldList.of(generalInfoFields))
  
  
      // Combine fields and create table
      val tableSchema = Schema.of(general_info)
      val tableDefinition = StandardTableDefinition.of(tableSchema)
      val tableInfo = TableInfo.newBuilder(tableId, tableDefinition).build()
      val table = bigquery.create(tableInfo)
  
  
  
      log.info("dataset created " + dataset.datasetId.dataset)
  </code></pre>
  
  <p>Any help would be greatly appreciated</p>