Unify date_bucket granularities across aggregation engines
What does this MR do and why?
The date_bucket dimension used in ClickHouse aggregation engines takes a granularity parameter, but until now each engine had to declare its own list of allowed values. This led to drift: some engines allowed daily/weekly/monthly, others only weekly/monthly, or only monthly, and most left the GraphQL argument undocumented.
This MR gives date_bucket a built-in default granularity parameter that accepts daily, weekly, and monthly, with a proper description. All eight engines that use date_bucket now rely on this default instead of repeating their own version. An engine can still override it with its own parameters: if it needs something different (for example the dynamic Xd day granularity, which is intentionally not part of the default).
As a result, two engines gain granularities they didn't support before (agent platform sessions gains daily; code suggestions gains daily and weekly), and every granularity argument is now documented in the GraphQL reference. Previously valid values keep working, so this is backwards compatible.
References
- Related to #609138 (items 4 and 5: default parameter set on
date_bucket, and unifying existing engines) - Related to !251628 (merged) (added the dynamic
Xdday granularity that engines can still opt into via a customparameters:declaration)
Screenshots or screen recordings
Not applicable, no UI changes.
How to set up and validate locally
- Run the spec file (ClickHouse must be running in GDK):
bundle exec rspec spec/lib/gitlab/database/aggregation/click_house/date_bucket_dimension_spec.rb - In
rails console, check the generated parameter for any engine, for example:This should return the defaultAnalytics::AggregationEngines::CodeSuggestions.dimensions.find { |d| d.name == :timestamp }.parametersgranularityhash withdaily,weekly, andmonthly. - In GraphiQL at
http://gdk.test:3000/-/graphql-explorer, run an aggregation query with agranularityargument that was previously rejected for code suggestions:Confirmquery { group(fullPath: "gitlab-org") { analytics { duoCodeSuggestions { aggregated { nodes { dimensions { timestamp(granularity: "weekly") } shownCount } } } } } }weeklyis now accepted, and that the docs panel shows the new description for thegranularityargument.
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Related to #609138