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 Xd day granularity that engines can still opt into via a custom parameters: declaration)

Screenshots or screen recordings

Not applicable, no UI changes.

How to set up and validate locally

  1. 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
  2. In rails console, check the generated parameter for any engine, for example:
    Analytics::AggregationEngines::CodeSuggestions.dimensions.find { |d| d.name == :timestamp }.parameters
    This should return the default granularity hash with daily, weekly, and monthly.
  3. In GraphiQL at http://gdk.test:3000/-/graphql-explorer, run an aggregation query with a granularity argument that was previously rejected for code suggestions:
    query {
      group(fullPath: "gitlab-org") {
        analytics {
          duoCodeSuggestions {
            aggregated {
              nodes {
                dimensions {
                  timestamp(granularity: "weekly")
                }
                shownCount
              }
            }
          }
        }
      }
    }
    Confirm weekly is now accepted, and that the docs panel shows the new description for the granularity argument.

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

Edited by Pavel Shutsin

Merge request reports

Loading
Loading