Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
mquery
Manage
Activity
Members
Labels
Plan
Issues
1
Issue boards
Milestones
Wiki
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Subconscious Compute (Open)
mquery
Merge requests
!25
Resolve "Add support for more features in query builder API"
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Resolve "Add support for more features in query builder API"
39-add-support-for-more-features-in-query-builder-api
into
main
Overview
0
Commits
3
Pipelines
4
Changes
6
Merged
Maaz Ahmed
requested to merge
39-add-support-for-more-features-in-query-builder-api
into
main
1 year ago
Overview
0
Commits
3
Pipelines
4
Changes
3
Expand
Closes
#39 (closed)
0
0
Merge request reports
Compare
version 2
version 2
b7abb6ba
1 year ago
version 1
08c704e1
1 year ago
main (base)
and
latest version
latest version
9d2e3b38
3 commits,
1 year ago
version 2
b7abb6ba
2 commits,
1 year ago
version 1
08c704e1
1 commit,
1 year ago
Show latest version
3 files
+
65
−
4
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
3
Search (e.g. *.vue) (Ctrl+P)
src/query/ops/modifiers.rs
+
43
−
0
Options
use
std
::
fmt
::
Display
;
use
crate
::{
query
::
IntoQuery
,
seal
::
Sealed
};
use
super
::
Operable
;
#[derive(Debug,
Clone,
Default)]
pub
(
crate
)
struct
Mod
<
'a
,
M
>
{
mod_type
:
M
,
@@ -114,3 +118,42 @@ impl Display for Mod<'_, AggrType> {
Ok
(())
}
}
/// MetricsQL's `keep_metric_names` modifier
///
/// This modifier can only be applied using the `keep_metric_names` method made available by the [`QueryExt`](crate::query::QueryExt) trait.
#[cfg(feature
=
"metricsql"
)]
#[derive(Debug,
Clone)]
pub
struct
KeepNames
<
E
:
Operable
>
(
pub
(
crate
)
E
);
#[cfg(feature
=
"metricsql"
)]
impl
<
E
:
Operable
>
Display
for
KeepNames
<
E
>
{
fn
fmt
(
&
self
,
f
:
&
mut
std
::
fmt
::
Formatter
<
'_
>
)
->
std
::
fmt
::
Result
{
write!
(
f
,
"{exp} keep_metric_names"
,
exp
=
self
.0
)
}
}
#[cfg(feature
=
"metricsql"
)]
impl
<
E
:
Operable
>
Sealed
for
KeepNames
<
E
>
{}
#[cfg(feature
=
"metricsql"
)]
impl
<
E
:
Operable
>
Operable
for
KeepNames
<
E
>
{}
#[cfg(feature
=
"metricsql"
)]
impl
<
E
:
Operable
>
IntoQuery
for
KeepNames
<
E
>
{
type
Target
=
String
;
fn
into_query
(
self
)
->
Self
::
Target
{
self
.to_string
()
}
}
#[cfg(test)]
mod
tests
{
use
crate
::
query
::{
Metric
,
QueryExt
};
#[cfg(feature
=
"metricsql"
)]
#[test]
fn
keep_names
()
{
let
qry
=
Metric
::
new
(
"metric"
)
.keep_metric_names
();
assert_eq!
(
qry
.to_string
(),
"metric keep_metric_names"
);
}
}
Loading