Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: impl __field__ special matcher to project value columns #1320

Merged
merged 6 commits into from
Apr 4, 2023

Conversation

waynexia
Copy link
Member

@waynexia waynexia commented Apr 4, 2023

I hereby agree to the terms of the GreptimeDB CLA

What's changed and what's your intention?

Implement __field__ special matcher. It can do projection on value columns under multi-value model. E.g.:

MySQL [(none)]> TQL eval (1667446797, 1667446807, '10s') system_metrics{ __field__="cpu_util"};
+----------+-------+-------+---------------------+
| cpu_util | host  | idc   | ts                  |
+----------+-------+-------+---------------------+
|     11.8 | host1 | idc_a | 2022-11-03 03:40:07 |
|       50 | host1 | idc_b | 2022-11-03 03:40:07 |
|     80.1 | host2 | idc_a | 2022-11-03 03:40:07 |
+----------+-------+-------+---------------------+
3 rows in set (0.005 sec)

MySQL [(none)]> TQL eval (1667446797, 1667446807, '10s') system_metrics{ __field__="cpu_util", __value__="disk_util"};
+-----------+----------+-------+-------+---------------------+
| disk_util | cpu_util | host  | idc   | ts                  |
+-----------+----------+-------+-------+---------------------+
|      10.3 |     11.8 | host1 | idc_a | 2022-11-03 03:40:07 |
|      40.6 |       50 | host1 | idc_b | 2022-11-03 03:40:07 |
|        90 |     80.1 | host2 | idc_a | 2022-11-03 03:40:07 |
+-----------+----------+-------+-------+---------------------+
3 rows in set (0.004 sec)

MySQL [(none)]> TQL eval (1667446797, 1667446807, '10s') system_metrics{ __field__!="cpu_util"};
+-----------+-------------+-------+-------+---------------------+
| disk_util | memory_util | host  | idc   | ts                  |
+-----------+-------------+-------+-------+---------------------+
|      10.3 |        10.3 | host1 | idc_a | 2022-11-03 03:40:07 |
|      40.6 |        66.7 | host1 | idc_b | 2022-11-03 03:40:07 |
|        90 |        70.3 | host2 | idc_a | 2022-11-03 03:40:07 |
+-----------+-------------+-------+-------+---------------------+
3 rows in set (0.005 sec)

Checklist

  • I have written the necessary rustdoc comments.
  • I have added the necessary unit tests and integration tests.

Refer to a related PR or issue link (optional)

waynexia added 2 commits April 3, 2023 16:40
Signed-off-by: Ruihang Xia <waynestxia@gmail.com>
Signed-off-by: Ruihang Xia <waynestxia@gmail.com>
@waynexia waynexia requested review from killme2008 and yuanbohan April 4, 2023 06:30
Signed-off-by: Ruihang Xia <waynestxia@gmail.com>
src/promql/src/planner.rs Show resolved Hide resolved
src/promql/src/planner.rs Show resolved Hide resolved
src/promql/src/planner.rs Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Apr 4, 2023

Codecov Report

Merging #1320 (6405a45) into develop (2458b4e) will decrease coverage by 0.40%.
The diff coverage is 99.47%.

❗ Current head 6405a45 differs from pull request most recent head 5921067. Consider uploading reports for the commit 5921067 to get more accurate results

@@             Coverage Diff             @@
##           develop    #1320      +/-   ##
===========================================
- Coverage    85.82%   85.43%   -0.40%     
===========================================
  Files          504      505       +1     
  Lines        76288    76687     +399     
===========================================
+ Hits         65473    65515      +42     
- Misses       10815    11172     +357     

Signed-off-by: Ruihang Xia <waynestxia@gmail.com>
@waynexia waynexia changed the title feat: impl __value__ special matcher to project value columns feat: impl __field__ special matcher to project value columns Apr 4, 2023
@killme2008
Copy link
Contributor

@waynexia The PR content must be edited too. The __value__ is renamed to __field__.

waynexia added 2 commits April 4, 2023 16:42
Signed-off-by: Ruihang Xia <waynestxia@gmail.com>
Signed-off-by: Ruihang Xia <waynestxia@gmail.com>
Copy link
Contributor

@killme2008 killme2008 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@killme2008 killme2008 enabled auto-merge (squash) April 4, 2023 08:59
@killme2008 killme2008 merged commit a2d8804 into GreptimeTeam:develop Apr 4, 2023
@waynexia waynexia deleted the bool_add branch April 4, 2023 10:36
paomian pushed a commit to paomian/greptimedb that referenced this pull request Oct 19, 2023
…timeTeam#1320)

* plan new come functions

Signed-off-by: Ruihang Xia <waynestxia@gmail.com>

* implement __value__ matcher

Signed-off-by: Ruihang Xia <waynestxia@gmail.com>

* fix typo

Signed-off-by: Ruihang Xia <waynestxia@gmail.com>

* change __value__ to __field__

Signed-off-by: Ruihang Xia <waynestxia@gmail.com>

* add bad-case tests

Signed-off-by: Ruihang Xia <waynestxia@gmail.com>

* rename variables

Signed-off-by: Ruihang Xia <waynestxia@gmail.com>

---------

Signed-off-by: Ruihang Xia <waynestxia@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants