Skip to content

Commit 7fefa31

Browse files
authored
fix histogram response parsing (#11494)
1 parent c58de52 commit 7fefa31

File tree

7 files changed

+134
-10
lines changed

7 files changed

+134
-10
lines changed

ydb/library/yql/providers/solomon/async_io/dq_solomon_read_actor.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,12 @@ class TDqSolomonReadActor : public NActors::TActorBootstrapped<TDqSolomonReadAct
359359
return;
360360
}
361361

362+
if (json.IsMap() && !json.GetMapSafe().count("vector")) {
363+
NJson::TJsonValue newJson;
364+
newJson["vector"sv].AppendValue(std::move(json));
365+
json = std::move(newJson);
366+
}
367+
362368
Batch.push_back(json);
363369
NotifyComputeActorWithData();
364370
}

ydb/library/yql/tests/sql/solomon/canondata/result.json

+11
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,17 @@
5757
"uri": "file://test.test_solomon-DownsamplingValidSettings-default.txt_/plan.txt"
5858
}
5959
],
60+
"test.test[solomon-HistResponse-default.txt]": [
61+
{
62+
"uri": "file://test.test_solomon-HistResponse-default.txt_/results.txt"
63+
},
64+
{
65+
"uri": "file://test.test_solomon-HistResponse-default.txt_/opt.yql"
66+
},
67+
{
68+
"uri": "file://test.test_solomon-HistResponse-default.txt_/plan.txt"
69+
}
70+
],
6071
"test.test[solomon-InvalidProject-]": [
6172
{
6273
"uri": "file://test.test_solomon-InvalidProject-_/extracted"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
(
2+
(let $1 (Configure! world (DataSource '"config") '"DqEngine" '"force"))
3+
(let $2 (DataSink 'result))
4+
(let $3 (DataType 'String))
5+
(let $4 (StructType '('"kind" $3) '('"labels" (DictType $3 $3)) '('"ts" (DataType 'Datetime)) '('type $3) '('"value" (DataType 'Double))))
6+
(let $5 '('"kind" '"labels" '"value" '"ts" 'type))
7+
(let $6 (SoSourceSettings world '"hist" (SecureParam '"cluster:default_local_solomon") $4 $5 '() '"2023-12-08T14:40:39Z" '"2023-12-08T14:45:39Z" '"histogram_percentile(95, {})" (Bool '"false") '"AVG" '"PREVIOUS" (Uint32 '"15")))
8+
(let $7 (DqStage '((DqSource (DataSource '"solomon" '"local_solomon") $6)) (lambda '($10) $10) '('('"_logical_id" '0))))
9+
(let $8 (DqStage '((DqCnUnionAll (TDqOutput $7 '"0"))) (lambda '($11) $11) '('('"_logical_id" '0))))
10+
(let $9 (ResPull! $1 $2 (Key) (DqCnResult (TDqOutput $8 '"0") '()) '('('type) '('autoref)) '"dq"))
11+
(return (Commit! (Commit! $9 $2) (DataSink '"solomon" '"local_solomon")))
12+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
{
2+
"Detailed" = {
3+
"Operations" = [
4+
{
5+
"Id" = 8u;
6+
"Name" = "DqStage";
7+
"Streams" = {
8+
"Program" = []
9+
}
10+
};
11+
{
12+
"Id" = 6u;
13+
"Name" = "DqStage";
14+
"Streams" = {
15+
"Program" = []
16+
};
17+
"DependsOn" = [
18+
8u
19+
]
20+
};
21+
{
22+
"Id" = 3u;
23+
"Name" = "ResPull!";
24+
"DependsOn" = [
25+
6u
26+
]
27+
};
28+
{
29+
"Id" = 1u;
30+
"Name" = "Commit!";
31+
"DependsOn" = [
32+
3u
33+
]
34+
}
35+
];
36+
"OperationRoot" = 1u;
37+
"Providers" = [];
38+
"OperationStats" = {
39+
"Commit!" = 1u;
40+
"DqStage" = 2u;
41+
"ResPull!" = 1u
42+
}
43+
};
44+
"Basic" = {
45+
"nodes" = [
46+
{
47+
"id" = 8u;
48+
"level" = 1u;
49+
"name" = "DqStage #8";
50+
"type" = "op"
51+
};
52+
{
53+
"id" = 6u;
54+
"level" = 2u;
55+
"name" = "DqStage #6";
56+
"type" = "op"
57+
};
58+
{
59+
"id" = 3u;
60+
"level" = 3u;
61+
"name" = "ResPull!";
62+
"type" = "op"
63+
};
64+
{
65+
"id" = 1u;
66+
"level" = 4u;
67+
"name" = "Commit!";
68+
"type" = "op"
69+
}
70+
];
71+
"links" = [
72+
{
73+
"source" = 8u;
74+
"target" = 6u
75+
};
76+
{
77+
"source" = 6u;
78+
"target" = 3u
79+
};
80+
{
81+
"source" = 3u;
82+
"target" = 1u
83+
}
84+
]
85+
}
86+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[{"Write"=[{"Type"=["ListType";["StructType";[["kind";["DataType";"String"]];["labels";["DictType";["DataType";"String"];["DataType";"String"]]];["ts";["DataType";"Datetime"]];["type";["DataType";"String"]];["value";["DataType";"Double"]]]]];"Data"=[["MY_KIND";[["downsampling.aggregation";"AVG"];["downsampling.fill";"PREVIOUS"];["downsampling.gridMillis";"int 15000"];["from";"2023-12-08T14:40:39.000000Z"];["downsampling.disabled";"bool False"];["program";"program length 28"];["project";"hist"];["to";"2023-12-08T14:45:39.000000Z"]];"0";"MY_TYPE";"100"];["MY_KIND";[["downsampling.aggregation";"AVG"];["downsampling.fill";"PREVIOUS"];["downsampling.gridMillis";"int 15000"];["from";"2023-12-08T14:40:39.000000Z"];["downsampling.disabled";"bool False"];["program";"program length 28"];["project";"hist"];["to";"2023-12-08T14:45:39.000000Z"]];"0";"MY_TYPE";"200"];["MY_KIND";[["downsampling.aggregation";"AVG"];["downsampling.fill";"PREVIOUS"];["downsampling.gridMillis";"int 15000"];["from";"2023-12-08T14:40:39.000000Z"];["downsampling.disabled";"bool False"];["program";"program length 28"];["project";"hist"];["to";"2023-12-08T14:45:39.000000Z"]];"0";"MY_TYPE";"300"]]}]}]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
SELECT * FROM local_solomon.hist WITH (
2+
program = @@histogram_percentile(95, {})@@,
3+
from = "2023-12-08T14:40:39Z",
4+
to = "2023-12-08T14:45:39Z"
5+
);

ydb/library/yql/tools/solomon_emulator/lib/webapp.py

+13-10
Original file line numberDiff line numberDiff line change
@@ -134,17 +134,20 @@ async def sensors_data(request):
134134

135135
labels = _dict_to_labels(await request.json())
136136
labels["project"] = project
137-
return web.json_response({"vector": [
138-
{
139-
"timeseries": {
140-
"kind": "MY_KIND",
141-
"type": "MY_TYPE",
142-
"labels": labels,
143-
"timestamps": [1, 2, 3],
144-
"values": [100, 200, 300],
145-
}
137+
timeseries = {
138+
"timeseries": {
139+
"kind": "MY_KIND",
140+
"type": "MY_TYPE",
141+
"labels": labels,
142+
"timestamps": [1, 2, 3],
143+
"values": [100, 200, 300],
146144
}
147-
]})
145+
}
146+
147+
if project == "hist":
148+
return web.json_response(timeseries)
149+
150+
return web.json_response({"vector": [timeseries]})
148151

149152

150153
@routes.get("/metrics")

0 commit comments

Comments
 (0)