/**
  * @return Query
  */
 protected function buildQuery()
 {
     $filter = new Filter([new FilterCondition('TEST_FIELD_6_REQUIRED_BY_FILTER', FilterCondition::METHOD_STRING_EQ, 'TEST_VALUE')]);
     $sort = new Sort([new SortCondition('TEST_FIELD_7_REQUIRED_BY_SORT', null, SortCondition::ASC)]);
     $query = new Query();
     $query->setFilter($filter);
     $query->setSort($sort);
     $query->setSelect(['TEST_FIELD_4_REQUIRED_BY_SELECT', 'TEST_FIELD_3_THAT_IS_COMPLEX']);
     return $query;
 }
 /**
  * Transforms a fully-built query builder into a row collection with the results
  *
  * @param QueryBuilder        $queryBuilder
  *
  * @param Query               $query
  * @param DataSourceInterface $dataSource
  *
  * @return array
  * @throws ColumnNotSelectedException
  * @throws \Netdudes\DataSourceryBundle\DataSource\Driver\Doctrine\Exception\ColumnNotFoundException
  *
  */
 protected function fetchData(QueryBuilder $queryBuilder, Query $query, DataSourceInterface $dataSource)
 {
     $fields = $dataSource->getFields();
     $rowCollection = [];
     $queryResults = $queryBuilder->getQuery()->getResult();
     foreach ($queryResults as $queryResultsRow) {
         $row = [];
         foreach ($fields as $queryBuilderDataSourceField) {
             if (!in_array($queryBuilderDataSourceField->getUniqueName(), $query->getSelect(), true)) {
                 continue;
             }
             $row[$queryBuilderDataSourceField->getUniqueName()] = $this->getCellValueByDataSourceField($queryResultsRow, $queryBuilderDataSourceField, $fields);
         }
         $rowCollection[] = $row;
     }
     $event = new PostFetchEvent($dataSource, $rowCollection);
     $dataSource->getEventDispatcher()->dispatch(self::EVENT_POST_FETCH, $event);
     return $event->data;
 }