InfoGrab Docs

집계 프레임워크(Aggregations Framework)

집계 프레임워크(Aggregations Framework)에 대해 설명합니다.

집계 프레임워크는 서로 다른 데이터베이스 백엔드에서 분석 쿼리를 구성하기 위한 통합 인터페이스를 제공합니다. PostgreSQL(ActiveRecord를 통한)과 ClickHouse를 모두 지원하며, 개발자가 메트릭, 차원, 필터가 있는 재사용 가능한 집계 엔진을 정의할 수 있도록 합니다. ActiveRecord 엔진 정의 # ActiveRecord 엔진( Gitlab::Database::Aggregation::ActiveRecord::Engine )은 ActiveRecord의 쿼리 인터페이스를 사용하여 PostgreSQL 쿼리를 생성합니다. ActiveRecord 엔진 예시 # class IssueAggregationEngine < Gitlab::Database::Aggregation::ActiveRecord::Engine filters do exact_match :project_id , :integer , description: 'Filter by project ID' exact_match :state , :string , description: 'Filter by issue state' end dimensions do column :author_id , :integer , description: 'Group by author' date_bucket :created_at , :datetime , parameters: { granularity: { in: %i[daily weekly monthly yearly], type: :string } }, description: 'Group by creation date' end metrics do count description: 'Total number of issues' mean :weight , :float , description: 'Average issue weight' end end ActiveRecord 엔진은 단일 수준 SQL 쿼리를 생성합니다: SELECT "issues"."author_id" AS aeq_author_id, date_trunc( 'month' , "issues"."created_at") AS aeq_created_at, COUNT ( * ) AS aeq_total_count, AVG ("issues"."weight") AS aeq_mean_weight FROM "issues" WHERE "issues"."project_id" IN ( 1 , 2 , 3 ) AND "issues"."state" IN ( 'opened' ) GROUP BY aeq_author_id, aeq_created_at ORDER BY aeq_author_id, aeq_created_at 주요 특징: 모든 컬럼은 aeq_ (Aggregation Engine Query)로 접두사가 붙습니다. 이 접두사는 AggregationResult 객체에 의해 제거됩니다. 필터는 WHERE 또는 HAVING 절로 적용됩니다 차원은 GROUP BY 컬럼이 됩니다 메트릭은 집계 함수( COUNT ,