aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoruzhastik <uzhas@ydb.tech>2024-11-28 22:12:39 +0300
committerGitHub <noreply@github.com>2024-11-28 22:12:39 +0300
commit7fefa31ac12ac7076e1c5f55b225c8b54093bafe (patch)
tree0d308b4482533a0fff7369e9a8e455be41397b0b
parentc58de5230a00ce649643e0fdea64594ffb1f5792 (diff)
downloadydb-7fefa31ac12ac7076e1c5f55b225c8b54093bafe.tar.gz
fix histogram response parsing (#11494)
-rw-r--r--ydb/library/yql/providers/solomon/async_io/dq_solomon_read_actor.cpp6
-rw-r--r--ydb/library/yql/tests/sql/solomon/canondata/result.json11
-rw-r--r--ydb/library/yql/tests/sql/solomon/canondata/test.test_solomon-HistResponse-default.txt_/opt.yql12
-rw-r--r--ydb/library/yql/tests/sql/solomon/canondata/test.test_solomon-HistResponse-default.txt_/plan.txt86
-rw-r--r--ydb/library/yql/tests/sql/solomon/canondata/test.test_solomon-HistResponse-default.txt_/results.txt1
-rw-r--r--ydb/library/yql/tests/sql/suites/solomon/HistResponse.sql5
-rw-r--r--ydb/library/yql/tools/solomon_emulator/lib/webapp.py23
7 files changed, 134 insertions, 10 deletions
diff --git a/ydb/library/yql/providers/solomon/async_io/dq_solomon_read_actor.cpp b/ydb/library/yql/providers/solomon/async_io/dq_solomon_read_actor.cpp
index 931e56bbe5..b7d2ee16d0 100644
--- a/ydb/library/yql/providers/solomon/async_io/dq_solomon_read_actor.cpp
+++ b/ydb/library/yql/providers/solomon/async_io/dq_solomon_read_actor.cpp
@@ -359,6 +359,12 @@ private:
return;
}
+ if (json.IsMap() && !json.GetMapSafe().count("vector")) {
+ NJson::TJsonValue newJson;
+ newJson["vector"sv].AppendValue(std::move(json));
+ json = std::move(newJson);
+ }
+
Batch.push_back(json);
NotifyComputeActorWithData();
}
diff --git a/ydb/library/yql/tests/sql/solomon/canondata/result.json b/ydb/library/yql/tests/sql/solomon/canondata/result.json
index fe9baffb4a..1c8885744c 100644
--- a/ydb/library/yql/tests/sql/solomon/canondata/result.json
+++ b/ydb/library/yql/tests/sql/solomon/canondata/result.json
@@ -57,6 +57,17 @@
"uri": "file://test.test_solomon-DownsamplingValidSettings-default.txt_/plan.txt"
}
],
+ "test.test[solomon-HistResponse-default.txt]": [
+ {
+ "uri": "file://test.test_solomon-HistResponse-default.txt_/results.txt"
+ },
+ {
+ "uri": "file://test.test_solomon-HistResponse-default.txt_/opt.yql"
+ },
+ {
+ "uri": "file://test.test_solomon-HistResponse-default.txt_/plan.txt"
+ }
+ ],
"test.test[solomon-InvalidProject-]": [
{
"uri": "file://test.test_solomon-InvalidProject-_/extracted"
diff --git a/ydb/library/yql/tests/sql/solomon/canondata/test.test_solomon-HistResponse-default.txt_/opt.yql b/ydb/library/yql/tests/sql/solomon/canondata/test.test_solomon-HistResponse-default.txt_/opt.yql
new file mode 100644
index 0000000000..942954923c
--- /dev/null
+++ b/ydb/library/yql/tests/sql/solomon/canondata/test.test_solomon-HistResponse-default.txt_/opt.yql
@@ -0,0 +1,12 @@
+(
+(let $1 (Configure! world (DataSource '"config") '"DqEngine" '"force"))
+(let $2 (DataSink 'result))
+(let $3 (DataType 'String))
+(let $4 (StructType '('"kind" $3) '('"labels" (DictType $3 $3)) '('"ts" (DataType 'Datetime)) '('type $3) '('"value" (DataType 'Double))))
+(let $5 '('"kind" '"labels" '"value" '"ts" 'type))
+(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")))
+(let $7 (DqStage '((DqSource (DataSource '"solomon" '"local_solomon") $6)) (lambda '($10) $10) '('('"_logical_id" '0))))
+(let $8 (DqStage '((DqCnUnionAll (TDqOutput $7 '"0"))) (lambda '($11) $11) '('('"_logical_id" '0))))
+(let $9 (ResPull! $1 $2 (Key) (DqCnResult (TDqOutput $8 '"0") '()) '('('type) '('autoref)) '"dq"))
+(return (Commit! (Commit! $9 $2) (DataSink '"solomon" '"local_solomon")))
+) \ No newline at end of file
diff --git a/ydb/library/yql/tests/sql/solomon/canondata/test.test_solomon-HistResponse-default.txt_/plan.txt b/ydb/library/yql/tests/sql/solomon/canondata/test.test_solomon-HistResponse-default.txt_/plan.txt
new file mode 100644
index 0000000000..806e0fb634
--- /dev/null
+++ b/ydb/library/yql/tests/sql/solomon/canondata/test.test_solomon-HistResponse-default.txt_/plan.txt
@@ -0,0 +1,86 @@
+{
+ "Detailed" = {
+ "Operations" = [
+ {
+ "Id" = 8u;
+ "Name" = "DqStage";
+ "Streams" = {
+ "Program" = []
+ }
+ };
+ {
+ "Id" = 6u;
+ "Name" = "DqStage";
+ "Streams" = {
+ "Program" = []
+ };
+ "DependsOn" = [
+ 8u
+ ]
+ };
+ {
+ "Id" = 3u;
+ "Name" = "ResPull!";
+ "DependsOn" = [
+ 6u
+ ]
+ };
+ {
+ "Id" = 1u;
+ "Name" = "Commit!";
+ "DependsOn" = [
+ 3u
+ ]
+ }
+ ];
+ "OperationRoot" = 1u;
+ "Providers" = [];
+ "OperationStats" = {
+ "Commit!" = 1u;
+ "DqStage" = 2u;
+ "ResPull!" = 1u
+ }
+ };
+ "Basic" = {
+ "nodes" = [
+ {
+ "id" = 8u;
+ "level" = 1u;
+ "name" = "DqStage #8";
+ "type" = "op"
+ };
+ {
+ "id" = 6u;
+ "level" = 2u;
+ "name" = "DqStage #6";
+ "type" = "op"
+ };
+ {
+ "id" = 3u;
+ "level" = 3u;
+ "name" = "ResPull!";
+ "type" = "op"
+ };
+ {
+ "id" = 1u;
+ "level" = 4u;
+ "name" = "Commit!";
+ "type" = "op"
+ }
+ ];
+ "links" = [
+ {
+ "source" = 8u;
+ "target" = 6u
+ };
+ {
+ "source" = 6u;
+ "target" = 3u
+ };
+ {
+ "source" = 3u;
+ "target" = 1u
+ }
+ ]
+ }
+} \ No newline at end of file
diff --git a/ydb/library/yql/tests/sql/solomon/canondata/test.test_solomon-HistResponse-default.txt_/results.txt b/ydb/library/yql/tests/sql/solomon/canondata/test.test_solomon-HistResponse-default.txt_/results.txt
new file mode 100644
index 0000000000..59e1b5a0a9
--- /dev/null
+++ b/ydb/library/yql/tests/sql/solomon/canondata/test.test_solomon-HistResponse-default.txt_/results.txt
@@ -0,0 +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"]]}]}] \ No newline at end of file
diff --git a/ydb/library/yql/tests/sql/suites/solomon/HistResponse.sql b/ydb/library/yql/tests/sql/suites/solomon/HistResponse.sql
new file mode 100644
index 0000000000..762da54aab
--- /dev/null
+++ b/ydb/library/yql/tests/sql/suites/solomon/HistResponse.sql
@@ -0,0 +1,5 @@
+SELECT * FROM local_solomon.hist WITH (
+ program = @@histogram_percentile(95, {})@@,
+ from = "2023-12-08T14:40:39Z",
+ to = "2023-12-08T14:45:39Z"
+);
diff --git a/ydb/library/yql/tools/solomon_emulator/lib/webapp.py b/ydb/library/yql/tools/solomon_emulator/lib/webapp.py
index d5cad86bc2..1004bdd915 100644
--- a/ydb/library/yql/tools/solomon_emulator/lib/webapp.py
+++ b/ydb/library/yql/tools/solomon_emulator/lib/webapp.py
@@ -134,17 +134,20 @@ async def sensors_data(request):
labels = _dict_to_labels(await request.json())
labels["project"] = project
- return web.json_response({"vector": [
- {
- "timeseries": {
- "kind": "MY_KIND",
- "type": "MY_TYPE",
- "labels": labels,
- "timestamps": [1, 2, 3],
- "values": [100, 200, 300],
- }
+ timeseries = {
+ "timeseries": {
+ "kind": "MY_KIND",
+ "type": "MY_TYPE",
+ "labels": labels,
+ "timestamps": [1, 2, 3],
+ "values": [100, 200, 300],
}
- ]})
+ }
+
+ if project == "hist":
+ return web.json_response(timeseries)
+
+ return web.json_response({"vector": [timeseries]})
@routes.get("/metrics")