/**
  * Helper method: gets the data corresponding to a given table column
  * from a row of the database scalar results
  *
  * @param array                                                    $dataRow Plain array of data for a single row, from the database
  * @param \Netdudes\DataSourceryBundle\DataSource\Configuration\Field $dataSourceField
  *
  * @throws \Exception
  *
  * @return mixed
  */
 protected function getCellValueByDataSourceField(array $dataRow, Field $dataSourceField, $fields)
 {
     $selectAlias = $dataSourceField->getDatabaseSelectAlias();
     if (is_array($selectAlias)) {
         // Alias is an array of aliases. The cell value is an array then too.
         $cellValue = [];
         foreach ($selectAlias as $key => $subAlias) {
             // Resolve recursively
             $field = $this->findQueryBuilderDataSourceFieldByUniqueName($subAlias, $fields);
             if (is_null($field)) {
                 throw new ColumnNotFoundException("Could not find data source field {$subAlias}, alias of  {$selectAlias}");
             }
             foreach ($fields as $field) {
                 if ($field->getUniqueName() === $subAlias) {
                     $cellValue[$key] = $this->getCellValueByDataSourceField($dataRow, $field, $fields);
                     break;
                 }
             }
         }
         return $cellValue;
     }
     // Try to get the data from the result row
     if (array_key_exists($selectAlias, $dataRow)) {
         return $dataRow[$selectAlias];
     }
     throw new ColumnNotSelectedException("Value for column '{$selectAlias}' cannot be found as the field was not selected");
 }