You are here

public function Sql::getAggregationInfo in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/views/src/Plugin/views/query/Sql.php \Drupal\views\Plugin\views\query\Sql::getAggregationInfo()

Get aggregation info for group by queries.

If NULL, aggregation is not allowed.

Overrides QueryPluginBase::getAggregationInfo

1 call to Sql::getAggregationInfo()
Sql::compileFields in core/modules/views/src/Plugin/views/query/Sql.php
Adds fields to the query.

File

core/modules/views/src/Plugin/views/query/Sql.php, line 1724

Class

Sql
Views query plugin for an SQL query.

Namespace

Drupal\views\Plugin\views\query

Code

public function getAggregationInfo() {

  // @todo -- need a way to get database specific and customized aggregation
  // functions into here.
  return [
    'group' => [
      'title' => $this
        ->t('Group results together'),
      'is aggregate' => FALSE,
    ],
    'count' => [
      'title' => $this
        ->t('Count'),
      'method' => 'aggregationMethodSimple',
      'handler' => [
        'argument' => 'groupby_numeric',
        'field' => 'numeric',
        'filter' => 'groupby_numeric',
        'sort' => 'groupby_numeric',
      ],
    ],
    'count_distinct' => [
      'title' => $this
        ->t('Count DISTINCT'),
      'method' => 'aggregationMethodDistinct',
      'handler' => [
        'argument' => 'groupby_numeric',
        'field' => 'numeric',
        'filter' => 'groupby_numeric',
        'sort' => 'groupby_numeric',
      ],
    ],
    'sum' => [
      'title' => $this
        ->t('Sum'),
      'method' => 'aggregationMethodSimple',
      'handler' => [
        'argument' => 'groupby_numeric',
        'field' => 'numeric',
        'filter' => 'groupby_numeric',
        'sort' => 'groupby_numeric',
      ],
    ],
    'avg' => [
      'title' => $this
        ->t('Average'),
      'method' => 'aggregationMethodSimple',
      'handler' => [
        'argument' => 'groupby_numeric',
        'field' => 'numeric',
        'filter' => 'groupby_numeric',
        'sort' => 'groupby_numeric',
      ],
    ],
    'min' => [
      'title' => $this
        ->t('Minimum'),
      'method' => 'aggregationMethodSimple',
      'handler' => [
        'argument' => 'groupby_numeric',
        'field' => 'numeric',
        'filter' => 'groupby_numeric',
        'sort' => 'groupby_numeric',
      ],
    ],
    'max' => [
      'title' => $this
        ->t('Maximum'),
      'method' => 'aggregationMethodSimple',
      'handler' => [
        'argument' => 'groupby_numeric',
        'field' => 'numeric',
        'filter' => 'groupby_numeric',
        'sort' => 'groupby_numeric',
      ],
    ],
    'stddev_pop' => [
      'title' => $this
        ->t('Standard deviation'),
      'method' => 'aggregationMethodSimple',
      'handler' => [
        'argument' => 'groupby_numeric',
        'field' => 'numeric',
        'filter' => 'groupby_numeric',
        'sort' => 'groupby_numeric',
      ],
    ],
  ];
}