title: mv-expand operator in Azure Data Explorer not working as expected for JSON Array
body: <p>I'm trying to follow the instructions in <a href="https://docs.microsoft.com/en-us/azure/data-explorer/ingest-json-formats?tabs=kusto-query-language#ingest-json-records-containing-arrays" rel="nofollow noreferrer">the documentation</a> to ingest a JSON array and create records for each item in the array in Azure Data Explorer but things aren't behaving as expected. </p>
  
  <p>My intermediate table has some top level fields that I want carried over and that is working but all of the fields from the array are just blank.</p>
  
  <pre><code>.create function RecordsExpandTest() {
      records_intermediate_test
      | mv-expand records_test = answers
      | project
          fullraw = tostring(fullraw),
          question = tostring(question),
          question_class = tostring(question_class),
          question_raw = tostring(question_raw),
          answer_class = tostring(answers["class"]),
          answer_type = tostring(answers["type"]),
          answer_raw = tostring(answers["raw"]),
          request_time = todatetime(request_time)
  }
  </code></pre>
  
  <p>When I ingest a row into my intermediate table (records_intermediate_test) that has an array of 3 answers, 3 rows are created in the final table (records_test) but all of the field's related to answers are empty even though in the source data they are not. </p>
  
  <p>Create for intermediate table:</p>
  
  <pre><code>.create table records_intermediate_test(fullraw: string, question: string, question_class: string, question_raw: string, answers : dynamic, request_time: datetime)
  </code></pre>
  
  <p>Create for final table: </p>
  
  <pre><code>.create table records_test(fullraw: string, question: string, question_class: string, question_raw: string, answer_class : string, answer_type: string, answer_raw : string, request_time: datetime)
  </code></pre>
  
  <p>Alter table that applies the mv-expand:</p>
  
  <pre><code>.alter table records_test policy update @'[{"Source": "records_intermediate_test", "Query": "RecordsExpandTest()", "IsEnabled": "True"}]'
  </code></pre>
  
  <p>Sample row from records_intermediate_test</p>
  
  <pre><code>"fullraw": TEST,
  "question": TEST,
  "question_class": TEST,
  "answers": [
      {
          "class": "C",
          "type": "C",
          "raw": "TEST"
      },
      {
          "class": "B",
          "type": "B",
          "raw": "TEST"
      },
      {
          "class": "A",
          "type": "A",
          "raw": "TEST"
      }
  ],
  "request_time": 2019-01-01T10:07:49.0105654Z
  </code></pre>
  
  <p>Sample row from records_test</p>
  
  <pre><code>"fullraw": TEST,
  "question": TEST,
  "question_class": TEST,
  "answer_class": ,
  "answer_type": ,
  "answers_raw": ,
  "request_time": 2019-01-01T10:07:49.0105654Z
  </code></pre>
  
  <p>^Repeated 3 times in the table</p>
  
  <p>Expected rows from records_test</p>
  
  <pre><code>"fullraw": TEST,
  "question": TEST,
  "question_class": TEST,
  "answer_class": A,
  "answer_type": A,
  "answers_raw": TEST,
  "request_time": 2019-01-01T10:07:49.0105654Z
  
  "fullraw": TEST,
  "question": TEST,
  "question_class": TEST,
  "answer_class": B,
  "answer_type": B,
  "answers_raw": TEST,
  "request_time": 2019-01-01T10:07:49.0105654Z
  
  "fullraw": TEST,
  "question": TEST,
  "question_class": TEST,
  "answer_class": C,
  "answer_type": C,
  "answers_raw": TEST,
  "request_time": 2019-01-01T10:07:49.0105654Z
  </code></pre>
  
  <p>The intermediate table's input always includes an array with 1 question in it. This is the mapping:</p>
  
  <pre><code>.create table records_intermediate_test ingestion json mapping 'mappingtest' 
  '['
  '   { "column" : "fullraw", "Properties":{"Path":"$.fullraw"}},'
  '   { "column" : "question", "Properties" {"Path":"$.question[0].question"}},'
  '   { "column" : "question_class", "Properties":{"Path":"$.question[0].class"}},'
  '   { "column" : "question_raw", "Properties":{"Path":"$.question[0].raw"}},'
  '   { "column" : "answers", "Properties":{"Path":"$.answers"}},'
      '   { "column" : "request_time", "Properties":{"Path":"$.request_time"}}'
  ']'
  </code></pre>
  
  <p>Sample raw JSON input for the records_intermediate_test table:</p>
  
  <pre><code>{
  "fullraw": "TEST",
  "question": "TEST",
  "question_class": "TEST",
  "answers": [
      {
          "class": "C",
          "type": "C",
          "raw": "TEST"
      },
      {
          "class": "B",
          "type": "B",
          "raw": "TEST"
      },
      {
          "class": "A",
          "type": "A",
          "raw": "TEST"
      }
  ],
  "request_time": 2019-01-01T10:07:49.0105654Z
  }
  </code></pre>