Expose field, type, and parameters in GLQL REST API entity
What does this MR do and why?
The GLQL compiler emits field, type, and parameters properties in the compile output, but the Grape entity (API::Entities::Glql::Field) silently drops them because it only exposes key, label, and name.
This MR adds these three attributes to the entity so API consumers can access:
field: the base field name, distinct fromkeyfor aliased parameterised fields (e.g.key: "p50",field: "durationQuantile")type: field classification ("dimension"or"metric") for analytics mode fields, omitted for standard fieldsparameters: resolved parameter metadata (e.g.{ "granularity": "weekly" }), omitted when the field has no parameters
type and parameters use expose_nil: false so they are omitted from the response rather than serialised as null when not applicable.
Related work
- Frontend: Use compile output parameter metadata for time ... (!241834 - merged)
- Documentation: Document GLQL parameterized fields and duplicat... (!246245 - merged)
- AI gateway: feat: add parameterised field and alias syntax ... (gitlab-org/modelops/applied-ml/code-suggestions/ai-assist!6050 - merged)
How to set up and validate locally
-
Run the entity spec:
bundle exec rspec spec/lib/api/entities/glql/field_spec.rb -
Set up Clickhouse in your GDK
-
Set up Siphon in your GDK
-
Enable Clickhouse-based analytics:
echo 'Gitlab::CurrentSettings.current_application_settings.update(use_clickhouse_for_analytics: true)' | rails c -
Seed Pipeline Analytics:
FILTER=pipeline_metrics SEED_PIPELINE_METRICS=1 bundle exec rake db:seed_fu -
Verify the API response includes the new fields by compiling an analytics query:
curl --request POST \ --header "PRIVATE-TOKEN: <token>" \ --header "Content-Type: application/json" \ --data '{"glql_yaml": "mode: analytics\ndimensions: ref\nmetrics: durationQuantile(0.5) as \"p50\"\nquery: type = pipeline AND project = \"gitlab-org/gitlab-shell\""}' \ --url "http://gdk.test:8080/api/v4/glql"The
fieldsarray should include"field": "durationQuantile","type": "metric", and"parameters": {"quantile": "0.5"}for thep50field.